# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
84329 | zoooma13 | Baloni (COCI15_baloni) | C++14 | 2080 ms | 132096 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>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define MAX_N 1000006
int N;
vector <int> A;
set<int> os[MAX_N];
multiset <int> ms;
int main()
{
scanf("%d",&N); assert(N < MAX_N);
A.resize(N ,0);
for(int i=0; i<N; i++)
{
scanf("%d",&A[i]);
os[A[i]].insert(i);
ms.insert(A[i]);
}
int Ans = 0;
set<int>::iterator it;
while(!ms.empty())
{
int i = *prev(ms.end());
int j = -1;
while(true)
{
it = os[i].upper_bound(j);
if(it == os[i].end())
break;
j = *it;
ms.erase(ms.find(i));
os[i].erase(it);
i--;
}
Ans++;
}
cout << Ans << endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |