Submission #705824

# Submission time Handle Problem Language Result Execution time Memory
705824 2023-03-05T11:39:27 Z delrey Baloni (COCI15_baloni) C++14
100 / 100
706 ms 96816 KB
#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
1 Correct 21 ms 47308 KB Output is correct
2 Correct 21 ms 47316 KB Output is correct
3 Correct 24 ms 47416 KB Output is correct
4 Correct 23 ms 47444 KB Output is correct
5 Correct 626 ms 91788 KB Output is correct
6 Correct 706 ms 96816 KB Output is correct
7 Correct 554 ms 88052 KB Output is correct
8 Correct 562 ms 87548 KB Output is correct
9 Correct 597 ms 90020 KB Output is correct
10 Correct 624 ms 91528 KB Output is correct