# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
84328 | zoooma13 | Baloni (COCI15_baloni) | C++14 | 38 ms | 1128 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 MAX_N 5003
int N;
vector <int> A;
int par[MAX_N];
int pat[MAX_N];
int bef[MAX_N];
bool bad[MAX_N];
int main()
{
scanf("%d",&N); assert(N < MAX_N);
A.resize(N ,0);
for(int i=0; i<N; i++)
scanf("%d",&A[i]);
int Ans = 0;
while(!A.empty())
{
memset(par ,0 ,sizeof par);
memset(pat ,0 ,sizeof pat);
memset(bef ,-1 ,sizeof bef);
memset(bad ,0 ,sizeof bad);
for(int i=0; i<A.size(); i++)
{
par[i] = bef[A[i]+1];
pat[i] = (~bef[A[i]+1] ? pat[ bef[A[i]+1] ]+1 : 1);
bef[A[i]] = i;
}
int now = max_element(pat ,pat+A.size()) - pat;
for( ; ~now; now = par[now])
bad[now] = 1;
vector <int> NA;
for(int i=0; i<A.size(); i++)
if(!bad[i])
NA.push_back(A[i]);
A = NA;
Ans++;
}
cout << Ans << endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |