#include <bits/stdc++.h>
using namespace std;
int minimumArrows(vector<int>& hs) {
unordered_map<int, int> arrows;
int ac = 0;
for (int h : hs) {
if (arrows[h] > 0) {
arrows[h]--;
arrows[h - 1]++;
} else {
ac++;
arrows[h - 1]++;
}
}
return ac;
}
int main() {
int N;
cin >> N;
vector<int> hs(N);
for (int i = 0; i < N; i++) {
cin >> hs[i];
}
cout << minimumArrows(hs) << 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 |
336 KB |
Output is correct |
4 |
Correct |
2 ms |
336 KB |
Output is correct |
5 |
Correct |
116 ms |
3408 KB |
Output is correct |
6 |
Correct |
169 ms |
3912 KB |
Output is correct |
7 |
Correct |
129 ms |
3292 KB |
Output is correct |
8 |
Correct |
96 ms |
3256 KB |
Output is correct |
9 |
Correct |
118 ms |
3408 KB |
Output is correct |
10 |
Correct |
105 ms |
3600 KB |
Output is correct |