// Online IDE - Code Editor, Compiler, Interpreter
#include<bits/stdc++.h>
using namespace std;
int main()
{
int top=0;
int x = 0;
cin >> x;
int arr[1000001] = {0};
vector<int> b(x);
for(int i = 0;i < x;i++)
cin >> b[i];
for(int a:b){
if(arr[a] > 0){
arr[a]--;
arr[a-1]++;
}else{
top++;
arr[a-1]++;
}
}cout << top;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
4176 KB |
Output is correct |
2 |
Correct |
5 ms |
4176 KB |
Output is correct |
3 |
Correct |
4 ms |
4176 KB |
Output is correct |
4 |
Correct |
5 ms |
4176 KB |
Output is correct |
5 |
Correct |
108 ms |
7248 KB |
Output is correct |
6 |
Correct |
122 ms |
7928 KB |
Output is correct |
7 |
Correct |
88 ms |
6992 KB |
Output is correct |
8 |
Correct |
88 ms |
7160 KB |
Output is correct |
9 |
Correct |
100 ms |
7248 KB |
Output is correct |
10 |
Correct |
98 ms |
7248 KB |
Output is correct |