Submission #758107

# Submission time Handle Problem Language Result Execution time Memory
758107 2023-06-14T07:31:58 Z vjudge1 Money (IZhO17_money) C++17
0 / 100
1 ms 212 KB
#include"bits/stdc++.h"
using namespace std;
#define ll long long
const ll mod = 1000000007;

int b[1000001];

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++)
        cin >> a[i];
    set<int> s;
    s.insert(-1);
    b[1] = 1e6;
    bool bad = 0;
    int l = 0, r = 1, ans = 1;
    while(r < n) {
        if(a[r] >= a[r - 1]) {
            int g = *s.lower_bound(-a[l]) * -1;
            if(a[r] <= b[g]) {
                b[a[r]] = b[g];
                b[a[r - 1]] = a[r];
                b[g] = a[l];
                s.insert(-a[r]);
                s.insert(-a[r - 1]);
            }
        }
        else {
            l = r;
            ans++;
        }
        r++;
    }
    cout << ans;

    return 0;
}

Compilation message

money.cpp: In function 'int main()':
money.cpp:19:10: warning: unused variable 'bad' [-Wunused-variable]
   19 |     bool bad = 0;
      |          ^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -