#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 + 100;
#define int long long
vector<int> A;
tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> s;
int pref[MAXN];
signed main() {
fast
int N, 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 (int 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 |
1 |
Correct |
3 ms |
860 KB |
Output is correct |
2 |
Correct |
2 ms |
860 KB |
Output is correct |
3 |
Correct |
2 ms |
860 KB |
Output is correct |
4 |
Runtime error |
400 ms |
65536 KB |
Execution killed with signal 9 |
5 |
Correct |
245 ms |
45244 KB |
Output is correct |
6 |
Runtime error |
383 ms |
65536 KB |
Execution killed with signal 9 |
7 |
Runtime error |
346 ms |
65536 KB |
Execution killed with signal 9 |
8 |
Correct |
361 ms |
60924 KB |
Output is correct |
9 |
Runtime error |
348 ms |
65536 KB |
Execution killed with signal 9 |
10 |
Runtime error |
364 ms |
65536 KB |
Execution killed with signal 9 |