#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> heights(N);
for (int i = 0; i < N; ++i) {
cin >> heights[i];
}
unordered_map<int, int> arrows;
int num_arrows = 0;
for (int i = 0; i < N; ++i) {
int h = heights[i];
if (arrows[h] > 0) {
arrows[h]--;
arrows[h - 1]++;
} else {
num_arrows++;
arrows[h - 1]++;
}
}
cout << num_arrows << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
2 ms |
452 KB |
Output is correct |
4 |
Correct |
2 ms |
336 KB |
Output is correct |
5 |
Correct |
132 ms |
3524 KB |
Output is correct |
6 |
Correct |
131 ms |
3896 KB |
Output is correct |
7 |
Correct |
101 ms |
3296 KB |
Output is correct |
8 |
Correct |
108 ms |
3256 KB |
Output is correct |
9 |
Correct |
115 ms |
3416 KB |
Output is correct |
10 |
Correct |
140 ms |
3532 KB |
Output is correct |