Submission #154278

#TimeUsernameProblemLanguageResultExecution timeMemory
154278RobertDobraBaloni (COCI15_baloni)C++14
0 / 100
2079 ms10860 KiB
#include <iostream> using namespace std; int n,m,i,j,k,h,z,v[1000010],y[1000010]; short ok[1000010]; int main(){ cin>>n; for (i=1;i<=n;i++){ cin>>v[i]; y[i]=i; } for (i=1;i<n;i++) for (j=i+1;j<=n;j++) if (v[i]<v[j]){ swap(v[i],v[j]); swap(y[i],y[j]); } for (i=1;i<=n;i++) if (!ok[i]){ k++; ok[i]=1; h=v[i]-1; z=y[i]; for (j=i+1;j<=n && h<=v[j];j++) if (v[j]==h && y[j]>z && !ok[j]){ ok[j]=1; h--; z=y[j]; } } cout<<k; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...