Submission #914778

# Submission time Handle Problem Language Result Execution time Memory
914778 2024-01-22T16:31:12 Z mariamp1 Money (IZhO17_money) C++14
0 / 100
1 ms 348 KB
# include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pii pair <int, int>
#define pb push_back
const int N = 3e5 + 5;
int n, q, mn, r, mx;
main() {
    cin>>n;
    int a[n+1];
    set<int> s;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        mn = a[i];
        ans++;
        for (int j = i; j <= n; j++){
            if(a[j+1] < a[j]) { r = j; break; }
            mx = a[j + 1];
            auto it = s.lower_bound(mn);
            if (it != s.end() && *it < mx) { r = j; break; }
        }
        for(int j = i; j <= r; j++){
            s.insert(a[j]);
        }
        i = r;
    }
    cout << ans << endl;
}

Compilation message

money.cpp:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    9 | main() {
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -