'commit'
This commit is contained in:
33
LuoGu/RuMen/P1897.cpp
Normal file
33
LuoGu/RuMen/P1897.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int f = 0, maxf = 0, n; //n统计要下的人数,f统计要下的层数
|
||||
map<int, bool> fp;
|
||||
int j;
|
||||
|
||||
|
||||
int main() {
|
||||
ios::sync_with_stdio(false); //读入输出优化的强迫症
|
||||
//初始化
|
||||
fp.clear();
|
||||
//键盘读取n
|
||||
cin >> n;
|
||||
//循环读取n个人员的数据
|
||||
for (int i = 0; i < n; i++) {
|
||||
cin >> j;
|
||||
//如果此楼层出现过,或者是零层,那么继续下一个
|
||||
if (fp[j] || j == 0) continue;
|
||||
//计算最高的层数
|
||||
if (j > maxf) maxf = j;
|
||||
// 标识此层需要开门
|
||||
fp[j] = true;
|
||||
//开门次数
|
||||
f++;
|
||||
}
|
||||
//输出结果 n:代理n个人,每人下电梯需要1秋,计n秒。
|
||||
// 上一层6秒,下一层4秒,就是说一层需要的总时长10秒,计10*maxf
|
||||
// f:开一次门需要5秒,计f*5
|
||||
cout << n + f * 5 + 10 * maxf;
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user