# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
37561 | Abelyan | Money (IZhO17_money) | C++14 | 0 ms | 10964 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
const int N=1000006;
pair <int,int> a[N];
bool r[N];
int main(){
ios_base::sync_with_stdio(false);
freopen("money.in","r",stdin);
freopen("money.out","w",stdout);
int n;
cin>>n;
for (int i = 0; i < n; i++){
int k;
cin>>k;
a[i].first=k;
a[i].second=-i;
}
sort(a,a+n);
int ans=1;
r[-a[0].second+1]=true;
for (int i = 1; i < n; i++){
if (r[-a[i].second]){
r[-a[i-1].second+1]=false;
r[-a[i].second+1]=true;
}
else{
if (-a[i].second < -a[i - 1].second){
r[-a[i - 1].second + 1] = false;
r[-a[i].second + 1] = true;
}
else{
r[-a[i].second + 1] = true;
}
ans++;
}
}
cout<<ans<<endl;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |