Submission #710277

# Submission time Handle Problem Language Result Execution time Memory
710277 2023-03-15T06:33:40 Z zyq_ Money (IZhO17_money) C++17
0 / 100
1 ms 320 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long

int N, inp;
vector<int> v;
vector<int> cur;
set<int> s;
int ans;

int32_t main() {
    ios::sync_with_stdio(0);
    cin >> N;
    for(int a=0; a<N; a++){
        cin >> inp;
        v.push_back(inp);
        if(a == 0){
            cur.push_back(inp);
            continue;
        }
        if(inp < cur.back()){
            ans++;
            while(!cur.empty()){
                s.insert(cur.back());
                cur.pop_back();
            }
            cur.push_back(inp);
            continue;
        }
        //check if there is num
        if(s.lower_bound(inp) != s.upper_bound(cur.back())){
            ans++;
            while(!cur.empty()){
                s.insert(cur.back());
                cur.pop_back();
            }
            cur.push_back(inp);
            continue;
        }
        cur.push_back(inp);
    }
    cout << ans+1;
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Incorrect 1 ms 212 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Incorrect 1 ms 212 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Incorrect 1 ms 212 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Incorrect 1 ms 212 KB Output isn't correct
9 Halted 0 ms 0 KB -