#include <bits/stdc++.h>
#define ccd ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
using namespace std;
/* ------------------------ hi lol ------------------------ */
// author : mzv
int n,x,arrow[1'000'000],ans=0;
int main() {
ccd
memset(arrow,0,sizeof(arrow));
cin >> n;
for (int i=1;i<=n;i++) {
cin >> x;
if (arrow[x]>0) {
arrow[x]--; // ad arrow tinggi x, langsung meledak
}
arrow[x-1]++; // balon ke x kena, arrow jatuh ke x-1
}
for (int i=0;i<=n;i++) {
ans += arrow[i];
}
cout << ans << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4180 KB |
Output is correct |
2 |
Correct |
2 ms |
4180 KB |
Output is correct |
3 |
Correct |
3 ms |
4180 KB |
Output is correct |
4 |
Correct |
3 ms |
4180 KB |
Output is correct |
5 |
Correct |
71 ms |
4416 KB |
Output is correct |
6 |
Correct |
59 ms |
4512 KB |
Output is correct |
7 |
Correct |
47 ms |
4428 KB |
Output is correct |
8 |
Correct |
48 ms |
4436 KB |
Output is correct |
9 |
Correct |
58 ms |
4424 KB |
Output is correct |
10 |
Correct |
61 ms |
4508 KB |
Output is correct |