Submission #380233

# Submission time Handle Problem Language Result Execution time Memory
380233 2021-03-20T16:00:30 Z vishesh312 Vudu (COCI15_vudu) C++17
112 / 140
673 ms 65540 KB
#include "bits/stdc++.h"
using namespace std;

using ll = long long;

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using ordered_set = tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) begin(x), end(x)
#define sz(x) (int)x.size()

const int mod = 1e9+7;

void solve(int tc) {
    int n;
    cin >> n;
    vector<ll> v(n+1);
    for (int i = 1; i <= n; ++i) cin >> v[i];
    ll p;
    cin >> p;
    ll ans = 0;
    ordered_set s;
    s.insert(-1);
    for (int i = 1; i <= n; ++i) {
        v[i] += v[i-1]-p;
        ans += s.order_of_key(v[i]);
        s.insert(v[i]-1);
    }
    cout << ans << '\n';
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int tc = 1;
    //cin >> tc;
    for (int i = 1; i <= tc; ++i) solve(i);
    return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 4 ms 876 KB Output is correct
2 Correct 3 ms 768 KB Output is correct
3 Correct 3 ms 748 KB Output is correct
4 Runtime error 673 ms 65540 KB Execution killed with signal 9
5 Correct 440 ms 38892 KB Output is correct
6 Correct 596 ms 60652 KB Output is correct
7 Correct 591 ms 63084 KB Output is correct
8 Correct 546 ms 54740 KB Output is correct
9 Runtime error 608 ms 65540 KB Execution killed with signal 9
10 Correct 589 ms 61548 KB Output is correct