# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
985844 | irmuun | Money (IZhO17_money) | C++17 | 1 ms | 348 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<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
int main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int n;
cin>>n;
int a[n+5];
for(int i=1;i<=n;i++){
cin>>a[i];
}
int l=1;
vector<int>v={0,(int)2e9};
int ans=1;
for(int i=2;i<=n;i++){
if(a[i-1]>a[i]){
ans++;
l=i;
}
else{
bool can=false;
for(int j=0;j<v.size()-1;j++){
if(v[j]<=a[l]&&a[i]<=v[j+1]){
can=true;
}
}
if(!can){
for(int j=l;j<i;j++){
v.pb(a[j]);
}
sort(all(v));
ans++;
l=i;
}
}
}
cout<<ans;
}
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... |