# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
40867 | XmtosX | Baloni (COCI15_baloni) | C++14 | 2094 ms | 131072 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;
int n,h,ans;
set <int> s[1000006];
int main()
{
scanf("%d",&n);
for (int i=0;i<n;i++)
{
scanf("%d",&h);
s[h].insert(i);
}
for (int i=0;i<=1e6;i++)
s[i].insert(n);
for (int i=1e6;i>0;i--)
{
while (s[i].size()>1)
{
ans++;
int x= (*s[i].begin());
s[i].erase(s[i].begin());
int a=i-1;
while (s[a].lower_bound(x)!=(--s[a].end()))
{
x= (*s[a].lower_bound(x));
s[a].erase(x);
a--;
}
}
}
cout <<ans;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |