# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
154278 | RobertDobra | Baloni (COCI15_baloni) | C++14 | 2079 ms | 10860 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>
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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |