Submission #443379

# Submission time Handle Problem Language Result Execution time Memory
443379 2021-07-10T12:17:11 Z arujbansal Vudu (COCI15_vudu) C++17
42 / 140
1000 ms 65536 KB
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <array>
#include <stack>
#include <queue>
#include <random>
#include <numeric>
#include <functional>
#include <chrono>
#include <utility>
#include <iomanip>
#include <assert.h>

using namespace std;

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)

#define rng_init mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define rng_seed(x) mt19937 rng(x)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int) (x).size()
// #define int long long

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;

template<typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int MXN = 1e5 + 5, INF = 1e9 + 5;

void solve() {
    int N;
    cin >> N;

    vector<int> A(N);
    for (auto &x : A)
        cin >> x;

    int P;
    cin >> P;

    oset<pair<int, int>> st;
    int fake_id = 0;
    st.insert(make_pair(0, fake_id++));

    int sum = 0, ans = 0;
    for (auto &x : A) {
        sum += x - P;

        ans += st.order_of_key(make_pair(sum + 1, 0));

        st.insert(make_pair(sum, fake_id++));
    }

    cout << ans;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int TC = 1;
    // cin >> TC;
    while (TC--) solve();
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 844 KB Output is correct
2 Correct 3 ms 716 KB Output is correct
3 Correct 3 ms 716 KB Output is correct
4 Execution timed out 1079 ms 62572 KB Time limit exceeded
5 Incorrect 749 ms 41864 KB Output isn't correct
6 Execution timed out 1096 ms 65132 KB Time limit exceeded
7 Execution timed out 1086 ms 65536 KB Time limit exceeded
8 Execution timed out 1075 ms 59072 KB Time limit exceeded
9 Execution timed out 1098 ms 65536 KB Time limit exceeded
10 Execution timed out 1101 ms 65536 KB Time limit exceeded