Submission #37368

# Submission time Handle Problem Language Result Execution time Memory
37368 2017-12-24T17:36:04 Z HardNut Money (IZhO17_money) C++14
9 / 100
0 ms 6084 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 1e6 + 5;

typedef long long ll;

int n, a[N], ans, lst;
set<pair<int, int>> st;

int main() {
//    freopen("money.in", "r", stdin);
//    freopen("money.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for (int i = 1; i <= n; i++) {
        st.insert({a[i], i});
        if (lst == a[i])
            continue;
        lst = a[i];
        auto id = st.find({a[i], i});
        if (id == st.begin()) {
            ans++;
            continue;
        }
        id--;
        if ((*id).second == i - 1) {
            continue;
        }
        id = st.lower_bound({a[i], -1});
        if (id == st.begin()) {
            ans++;
            continue;
        }
        id--;
        if ((*id).second == i - 1) {
            st.erase({a[i], i});
            continue;
        }
        ans++;
    }
    cout << ans;
}
/**
6
1 5 2 5 5 6
**/
# Verdict Execution time Memory Grader output
1 Correct 0 ms 6084 KB Output is correct
2 Correct 0 ms 6084 KB Output is correct
3 Correct 0 ms 6084 KB Output is correct
4 Correct 0 ms 6084 KB Output is correct
5 Correct 0 ms 6084 KB Output is correct
6 Correct 0 ms 6084 KB Output is correct
7 Correct 0 ms 6084 KB Output is correct
8 Correct 0 ms 6084 KB Output is correct
9 Correct 0 ms 6084 KB Output is correct
10 Correct 0 ms 6084 KB Output is correct
11 Correct 0 ms 6084 KB Output is correct
12 Correct 0 ms 6084 KB Output is correct
13 Correct 0 ms 6084 KB Output is correct
14 Correct 0 ms 6084 KB Output is correct
15 Correct 0 ms 6084 KB Output is correct
16 Correct 0 ms 6084 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 6084 KB Output is correct
2 Correct 0 ms 6084 KB Output is correct
3 Correct 0 ms 6084 KB Output is correct
4 Correct 0 ms 6084 KB Output is correct
5 Correct 0 ms 6084 KB Output is correct
6 Correct 0 ms 6084 KB Output is correct
7 Correct 0 ms 6084 KB Output is correct
8 Correct 0 ms 6084 KB Output is correct
9 Correct 0 ms 6084 KB Output is correct
10 Correct 0 ms 6084 KB Output is correct
11 Correct 0 ms 6084 KB Output is correct
12 Correct 0 ms 6084 KB Output is correct
13 Correct 0 ms 6084 KB Output is correct
14 Correct 0 ms 6084 KB Output is correct
15 Correct 0 ms 6084 KB Output is correct
16 Correct 0 ms 6084 KB Output is correct
17 Correct 0 ms 6084 KB Output is correct
18 Correct 0 ms 6084 KB Output is correct
19 Correct 0 ms 6084 KB Output is correct
20 Incorrect 0 ms 6084 KB Output isn't correct
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 6084 KB Output is correct
2 Correct 0 ms 6084 KB Output is correct
3 Correct 0 ms 6084 KB Output is correct
4 Correct 0 ms 6084 KB Output is correct
5 Correct 0 ms 6084 KB Output is correct
6 Correct 0 ms 6084 KB Output is correct
7 Correct 0 ms 6084 KB Output is correct
8 Correct 0 ms 6084 KB Output is correct
9 Correct 0 ms 6084 KB Output is correct
10 Correct 0 ms 6084 KB Output is correct
11 Correct 0 ms 6084 KB Output is correct
12 Correct 0 ms 6084 KB Output is correct
13 Correct 0 ms 6084 KB Output is correct
14 Correct 0 ms 6084 KB Output is correct
15 Correct 0 ms 6084 KB Output is correct
16 Correct 0 ms 6084 KB Output is correct
17 Correct 0 ms 6084 KB Output is correct
18 Correct 0 ms 6084 KB Output is correct
19 Correct 0 ms 6084 KB Output is correct
20 Incorrect 0 ms 6084 KB Output isn't correct
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 6084 KB Output is correct
2 Correct 0 ms 6084 KB Output is correct
3 Correct 0 ms 6084 KB Output is correct
4 Correct 0 ms 6084 KB Output is correct
5 Correct 0 ms 6084 KB Output is correct
6 Correct 0 ms 6084 KB Output is correct
7 Correct 0 ms 6084 KB Output is correct
8 Correct 0 ms 6084 KB Output is correct
9 Correct 0 ms 6084 KB Output is correct
10 Correct 0 ms 6084 KB Output is correct
11 Correct 0 ms 6084 KB Output is correct
12 Correct 0 ms 6084 KB Output is correct
13 Correct 0 ms 6084 KB Output is correct
14 Correct 0 ms 6084 KB Output is correct
15 Correct 0 ms 6084 KB Output is correct
16 Correct 0 ms 6084 KB Output is correct
17 Correct 0 ms 6084 KB Output is correct
18 Correct 0 ms 6084 KB Output is correct
19 Correct 0 ms 6084 KB Output is correct
20 Incorrect 0 ms 6084 KB Output isn't correct
21 Halted 0 ms 0 KB -