#include <iostream>
#include <map>
using namespace std;
int main() {
int N;
cin >> N;
int H[N];
for (int i = 0; i < N; i++)
cin >> H[i];
map<int, int> arrows;
for (int i = 0; i < N; i++) {
if (arrows.find(H[i]) != arrows.end() && arrows[H[i]] > 0)
arrows[H[i]]--;
arrows[H[i]-1]++;
}
int ans = 0;
for (auto it = arrows.begin(); it != arrows.end(); it++)
ans += it->second;
cout << ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
364 KB |
Output is correct |
2 |
Correct |
2 ms |
364 KB |
Output is correct |
3 |
Correct |
3 ms |
364 KB |
Output is correct |
4 |
Correct |
4 ms |
364 KB |
Output is correct |
5 |
Correct |
454 ms |
7276 KB |
Output is correct |
6 |
Correct |
449 ms |
7404 KB |
Output is correct |
7 |
Correct |
350 ms |
6208 KB |
Output is correct |
8 |
Correct |
364 ms |
6048 KB |
Output is correct |
9 |
Correct |
401 ms |
6764 KB |
Output is correct |
10 |
Correct |
389 ms |
6764 KB |
Output is correct |