Submission #91009

# Submission time Handle Problem Language Result Execution time Memory
91009 2018-12-25T15:00:27 Z popovicirobert Money (IZhO17_money) C++14
0 / 100
2 ms 708 KB
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
#define ld long double
// 217
// 44

using namespace std;

const int MAXN = (int) 1e6;

int arr[MAXN + 1];
int aib[MAXN + 1];

inline void update(int pos, int n) {
    for(int i = pos; i <= n; i += lsb(i)) {
        aib[i]++;
    }
}

inline int query(int pos) {
    int ans = 0;
    for(int i = pos; i > 0; i -= lsb(i)) {
        ans += aib[i];
    }
    return ans;
}

inline int sum(int l, int r) {
    if(l == r) {
        return 0;
    }
    return query(r - 1) - query(l);
}

int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i, n;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin >> n;
    for(i = 1; i <= n; i++) {
        cin >> arr[i];
    }
    int ans = 0;
    i = 1;
    while(i <= n) {
        int j = i + 1;
        ans++;
        while(j <= n && arr[j] >= arr[j - 1] && sum(arr[i], arr[j]) == 0) {
            j++;
        }
        while(i < j) {
            update(arr[i], n);
            i++;
        }
    }
    cout << ans;
    //cin.close();
    //cout.close();
    return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 416 KB Output is correct
3 Correct 2 ms 520 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 2 ms 604 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
7 Correct 2 ms 604 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 2 ms 708 KB Output is correct
10 Incorrect 2 ms 708 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 416 KB Output is correct
3 Correct 2 ms 520 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 2 ms 604 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
7 Correct 2 ms 604 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 2 ms 708 KB Output is correct
10 Incorrect 2 ms 708 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 416 KB Output is correct
3 Correct 2 ms 520 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 2 ms 604 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
7 Correct 2 ms 604 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 2 ms 708 KB Output is correct
10 Incorrect 2 ms 708 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 416 KB Output is correct
3 Correct 2 ms 520 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 2 ms 604 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
7 Correct 2 ms 604 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 2 ms 708 KB Output is correct
10 Incorrect 2 ms 708 KB Output isn't correct
11 Halted 0 ms 0 KB -