#include <iostream>
#include <unordered_map>
#include <vector>
using namespace std;
int Phsics(int n, const vector<int>& arrows) {
unordered_map<int, int> count;
int arrows_needed = 0;
for (int arrow : arrows) {
if (count[arrow] > 0) {
count[arrow]--;
count[arrow - 1]++;
} else {
arrows_needed++;
count[arrow - 1]++;
}
}
return arrows_needed;
}
int main() {
int n;
cin >> n;
vector<int> arrows(n);
for (int i = 0; i < n; i++) {
cin >> arrows[i];
}
cout << Phsics(n, 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 |
336 KB |
Output is correct |
4 |
Correct |
2 ms |
336 KB |
Output is correct |
5 |
Correct |
117 ms |
3408 KB |
Output is correct |
6 |
Correct |
120 ms |
3896 KB |
Output is correct |
7 |
Correct |
99 ms |
3288 KB |
Output is correct |
8 |
Correct |
99 ms |
3260 KB |
Output is correct |
9 |
Correct |
116 ms |
3656 KB |
Output is correct |
10 |
Correct |
115 ms |
3408 KB |
Output is correct |