# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
875340 | serifefedartar | Vudu (COCI15_vudu) | C++17 | 431 ms | 65536 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define fast ios::sync_with_stdio(0);cin.tie(0);
#define s second
#define f first
typedef long long ll;
const ll MOD = 998244353;
const ll LOGN = 20;
const ll MAXN = 1e6 + 10;
vector<int> A;
tree<pair<ll,int>, null_type, less<pair<ll,int>>, rb_tree_tag, tree_order_statistics_node_update> s;
ll pref[MAXN];
int main() {
fast
int N;
ll P;
cin >> N;
A = vector<int>(N+1);
for (int i = 1; i <= N; i++)
cin >> A[i];
for (int i = 1; i <= N; i++)
pref[i] = pref[i-1] + A[i];
cin >> P;
int ans = 0;
for (ll i = 1; i <= N; i++) {
s.insert(make_pair(P * i - pref[i-1], i));
ans += s.size() - s.order_of_key(make_pair(P * i - pref[i] + P, -1));
}
cout << ans << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |