#include <vector>
#include <algorithm>
#include <iostream>
#include <set>
#include <cmath>
#include <map>
#include <random>
#include <cassert>
#include <ctime>
#include <cstdlib>
#include <queue>
#include <limits.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
typedef
tree<
pair<int,int>,
null_type,
less<pair<int,int>>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
int get (set<pair<int,int>>& s, int x) {
int cntr = 0;
for (auto& i: s) {
if (i.first <= x) {
cntr++;
}
}
return cntr;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int N; cin >> N;
vector<int> arr(N); for (int i = 0; i < N; i++) cin >> arr[i];
vector<int> pref = {0}; for (int i = 0; i < N; i++) pref.push_back(pref.back() + arr[i]);
int P; cin >> P;
int c = 0;
ordered_set s;
for (int r = 0; r < N; r++) {
s.insert({pref[r] - P * r, r});
c += s.order_of_key(make_pair(pref[r + 1] - P * (r + 1) + 1, -1));
}
cout << c;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
852 KB |
Output is correct |
2 |
Correct |
4 ms |
668 KB |
Output is correct |
3 |
Correct |
3 ms |
724 KB |
Output is correct |
4 |
Execution timed out |
1089 ms |
65180 KB |
Time limit exceeded |
5 |
Incorrect |
632 ms |
39048 KB |
Output isn't correct |
6 |
Execution timed out |
1082 ms |
60780 KB |
Time limit exceeded |
7 |
Execution timed out |
1079 ms |
63284 KB |
Time limit exceeded |
8 |
Incorrect |
931 ms |
54928 KB |
Output isn't correct |
9 |
Execution timed out |
1090 ms |
65536 KB |
Time limit exceeded |
10 |
Execution timed out |
1093 ms |
61576 KB |
Time limit exceeded |