/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;
int main(){
int n, ans=0; cin>>n;
vector<bool>v(1e6, false);
while (n--){
int a; cin>>a;
if (v[a-1]==true){
v[a-1]=false;
if (a-2>=0) v[a-2]=true;
}else{
ans++;
if (a-2>=0) v[a-2]=true;
}
}cout<<ans<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
452 KB |
Output isn't correct |
5 |
Incorrect |
132 ms |
4024 KB |
Output isn't correct |
6 |
Incorrect |
135 ms |
3924 KB |
Output isn't correct |
7 |
Incorrect |
108 ms |
3156 KB |
Output isn't correct |
8 |
Incorrect |
113 ms |
3348 KB |
Output isn't correct |
9 |
Incorrect |
121 ms |
3596 KB |
Output isn't correct |
10 |
Incorrect |
119 ms |
3596 KB |
Output isn't correct |