# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
260153 | sckmd | Baloni (COCI15_baloni) | C++14 | 81 ms | 131076 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 MAXN 1000005
queue <int> ids[MAXN];
void go(int height,int prev)
{
if(!ids[height].size())return ;
int idx = ids[height].front();
if(idx < prev)return ;
ids[height].pop();
go(height-1,idx);
}
int solve()
{
int ans = 0;
for(int height = MAXN-1; height > 0;)
{
if(!ids[height].size()){height--;continue;}
go(height,-1);
ans++;
}
return ans;
}
int main()
{
ios_base::sync_with_stdio(false);
int n;
cin >> n;
for(int i = 1; i <= n; i++)
{
int h;
cin >> h;
ids[h].push(i);
}
cout << solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |