# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
342962 |
2021-01-03T09:27:05 Z |
David_M |
Money (IZhO17_money) |
C++14 |
|
1 ms |
364 KB |
#include <bits/stdc++.h>
using namespace std;
const int N=1000006;
int i,n,s,a[N],l[N],r[N],ans,x;
pair<int, int> p[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=1; i<=n; i++)r[p[i].second]=p[i+1].first,l[p[i].second]=p[i-1].first;
for (i=n; i>=2; i--)ans+=(l[i]!=a[i-1]),x=l[i],l[i]=a[r[i]],r[i]=a[x];
cout<<ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
0 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
0 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
0 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
0 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |