# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
705824 | delrey | Baloni (COCI15_baloni) | C++14 | 706 ms | 96816 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[1000000];
bool dp[1000000];
set <int> p[1000010];
int main()
{
cin>>n;
for(int i = 0; i < n; i++)
{
cin>>h[i];
p[h[i]].insert(i);
}
for(int i = n - 1; i >= 0; i--)
{
auto it = p[h[i] - 1].upper_bound(i);
dp[i] = true;
if(it != p[h[i] - 1].end())
{
dp[*it] = false;
p[h[i] - 1].erase(it);
}
}
int res = 0;
for(int i = 0; i < n; i++)
res += dp[i];
cout<<res<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |