# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
84359 | zoooma13 | Baloni (COCI15_baloni) | C++14 | 1571 ms | 89220 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 1000006
int N ,A;
set<int> ss[MAX_N];
int cnt[MAX_N];
vector <int> nxt;
int main()
{
scanf("%d",&N);
for(int i=0; i<N; i++)
{
scanf("%d",&A);
ss[A].insert(i);
if(!cnt[A]++)
nxt.push_back(A);
}
sort(nxt.begin() ,nxt.end());
int Ans = 0;
for(int pt = nxt.size()-1; ~pt;)
{
int i = nxt[pt] ,j = -1;
while(true)
{
auto it = ss[i].upper_bound(j);
if(it == ss[i].end())
break;
j = *it;
ss[i].erase(it);
--cnt[i--];
}
while(~pt && !cnt[nxt[pt]])
pt--;
Ans++;
}
cout << Ans << endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |