제출 #491764

#제출 시각아이디문제언어결과실행 시간메모리
491764WhiteMoney (IZhO17_money)C++14
0 / 100
1 ms332 KiB
#pragma GCC optimize ("Ofast") #include<bits/stdc++.h> #define endl "\n" using namespace std; int a[1000001],b[1000001],v[1000001]; bool bqh[1000001]; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n,br=0,now; cin>>n; for(int i=1;i<=n;i++){ cin>>a[i]; v[i]=a[i]; } sort(v,v+n+1); //cout<<v[1]<<v[2]<<v[3]<<endl; bool yes; for(int i=1;i<n;i++){ if(a[i]!=v[i]){ yes=false; now=i; for(int j=i+1;j<=n;j++){ if(a[j]==v[i])yes=true; if(yes==true){ if(a[j]==v[i]){ b[now]=v[i]; bqh[j]=true; now++; }else{ while(j<=n && a[j]>a[j-1]){ b[now]=a[j]; bqh[j]=true; now++; j++; } if(j==n+1 && i<n-1 && a[i]==v[i+1])br--; yes=false; } } } //cout<<"OOOOOO"<<now<<endl; for(int j=i;j<=n;j++){ if(bqh[j]==false){ b[now]=a[j]; now++; } } br++; //cout<<i<<"dwa"<<br<<endl; //cout<<b[1]<<b[2]<<endl; for(int j=i;j<=n;j++){ a[j]=b[j]; bqh[j]=false; } } } br++; cout<<br<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...