제출 #342965

#제출 시각아이디문제언어결과실행 시간메모리
342965David_MMoney (IZhO17_money)C++14
0 / 100
1 ms364 KiB
#include <bits/stdc++.h> #define S second #define F first using namespace std; const int N=1000006; int i,n,s,a[N],ans,x; pair<int, int> p[N],l[N],r[N]; int main(){ cin>>n; for (i=1; i<=n; i++)cin>>a[i],p[i]={a[i],i}; sort(p+1, p+n+1); for (i=n; i>=1; i--)if(p[i].F==p[i+1].F)r[p[i].S]=r[p[i+1].S];else r[p[i].S]=p[i+1]; for (i=1; i<=n; i++)if(p[i].F==p[i-1].F)l[p[i].S]=l[p[i-1].S];else l[p[i].S]=p[i-1]; for (i=n; i>1; i--)ans+=(a[i]-a[i-1]&&l[i].F!=a[i-1]),r[l[i].S]=r[i],l[r[i].S]=l[i]; cout<<ans+1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...