#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll asize=1e6+5;
ll x[asize];
bool y[asize];
int main(){
ll n,k,ans;
cin>>n;
ans=n;
for(ll i=0;i<asize;i++)x[i]=1e9;
for(ll i=0;i<n;i++){
cin>>k;
if(y[k]==1)ans--;
x[k]=min(x[k],i);
y[k]=1;
}
for(ll i=1;i<asize;i++){
if(y[i]&&y[i-1]&&x[i]<x[i-1])ans--;
}
cout<<ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
10 ms |
8192 KB |
Output isn't correct |
2 |
Incorrect |
11 ms |
8192 KB |
Output isn't correct |
3 |
Incorrect |
11 ms |
8192 KB |
Output isn't correct |
4 |
Incorrect |
11 ms |
8192 KB |
Output isn't correct |
5 |
Incorrect |
277 ms |
8312 KB |
Output isn't correct |
6 |
Incorrect |
281 ms |
8192 KB |
Output isn't correct |
7 |
Incorrect |
229 ms |
8192 KB |
Output isn't correct |
8 |
Incorrect |
231 ms |
8312 KB |
Output isn't correct |
9 |
Incorrect |
256 ms |
8228 KB |
Output isn't correct |
10 |
Incorrect |
255 ms |
8312 KB |
Output isn't correct |