Submission #143819

# Submission time Handle Problem Language Result Execution time Memory
143819 2019-08-15T09:27:13 Z MladenP Money (IZhO17_money) C++17
0 / 100
1500 ms 376 KB
#include <bits/stdc++.h>
#define MAXN 1000010
#define PRINT(x) cerr<<#x<<'='<<x<<endl;
using namespace std;
int a[MAXN], bit[MAXN], N, rez;
int query(int idx) {
    int rez = 0;
    for( ; idx ; idx -= idx&-idx) rez += bit[idx];
    return rez;
}
void update(int idx, int val) {
    for( ; idx < MAXN; idx += idx&-idx) bit[idx] += val;
}
int main() {
    cin >> N;
    rez = 1;
    for(int i = 1; i <= N; i++) {
        cin >> a[i];
        if(a[i-1] > a[i] || query(a[i]-1) > query(a[i-1])) rez++;
        update(a[i-1], +1);
    }
    cout << rez;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 1563 ms 376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1563 ms 376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1563 ms 376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1563 ms 376 KB Time limit exceeded
2 Halted 0 ms 0 KB -