# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
40869 | XmtosX | Baloni (COCI15_baloni) | C++14 | 1531 ms | 104344 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,maxx;
set <int> s[1000006];
set <int> ::iterator it;
int main()
{
scanf("%d",&n);
for (int i=0;i<n;i++)
{
scanf("%d",&h);
s[h].insert(i);
maxx=max(maxx,h);
}
for (int i=0;i<=maxx;i++)
s[i].insert(n);
for (int i=maxx;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 ((it=s[a].lower_bound(x))!=(--s[a].end()))
{
x= (*it);
s[a].erase(it);
a--;
}
}
}
printf("%d",ans);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |