#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int n, a, ans, h[1000005];
int main() {
fastio; cin >> n;
FOR(i, 1, n) {
cin >> a;
if (h[a+1] > 0) h[a+1]--;
h[a]++;
}
FOR(i, 1, 1000000) ans += h[i];
cout << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
384 KB |
Output is correct |
3 |
Correct |
6 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
384 KB |
Output is correct |
5 |
Correct |
70 ms |
384 KB |
Output is correct |
6 |
Correct |
68 ms |
504 KB |
Output is correct |
7 |
Correct |
58 ms |
384 KB |
Output is correct |
8 |
Correct |
61 ms |
504 KB |
Output is correct |
9 |
Correct |
67 ms |
384 KB |
Output is correct |
10 |
Correct |
63 ms |
384 KB |
Output is correct |