Submission #526089

# Submission time Handle Problem Language Result Execution time Memory
526089 2022-02-13T17:10:01 Z TheKingAleks Money (IZhO17_money) C++14
0 / 100
0 ms 204 KB
#include<bits/stdc++.h>
using namespace std;
const int MAX_N = 1e6+2;
const int INF = 1e9+7;
int a[MAX_N];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
    }
    multiset<int> s;
    s.insert(a[0]);
    for(int i=1; i<n; i++)
    {
        if(a[i] >= a[i-1])
        {
            s.insert(a[i]);
        }
        else break;
    }
    s.insert(INF);
    int idx = s.size();
    int ans = 1;
    while(idx < n)
    {
        vector<int> cur;
        int first_lower_bound = *(s.lower_bound(a[idx]+1));
        cur.push_back(a[idx]);
        idx++;
        ans++;
        while(idx < n)
        {
            if(a[idx] < a[idx-1]) break;
            int tmp = *(s.lower_bound(a[idx]+1));
            if(tmp != first_lower_bound)
            {
                break;
            }
            cur.push_back(a[idx]);
            idx++;
        }
        for(auto x: cur) s.insert(x);
    }
    cout<<ans<<endl;
}
/**
6
3 6 4 5 1 2
*/
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -