#include<ext/pb_ds/assoc_container.hpp>
#include<bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
typedef tree<pair<ll, int>, null_type, less<pair<ll, int>>, rb_tree_tag, tree_order_statistics_node_update> ost;
main() {
int n; cin >> n;
vector<int> nums(n);
for(int & i : nums) cin >> i;
ll p; cin >> p;
ost t;
ll sum = 0;
ll ans = 0;
for(int i = 0; i < n; i++) {
sum += nums[i];
ll goal = p * (i + 1);
ans += i - t.order_of_key({goal - sum, 0});
t.insert({goal - sum, i});
}
cout << ans << endl;
}
Compilation message
vudu.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
8 | main() {
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
852 KB |
Output isn't correct |
2 |
Incorrect |
3 ms |
724 KB |
Output isn't correct |
3 |
Incorrect |
4 ms |
696 KB |
Output isn't correct |
4 |
Incorrect |
916 ms |
65536 KB |
Output isn't correct |
5 |
Incorrect |
440 ms |
41972 KB |
Output isn't correct |
6 |
Incorrect |
737 ms |
65464 KB |
Output isn't correct |
7 |
Incorrect |
728 ms |
65536 KB |
Output isn't correct |
8 |
Incorrect |
640 ms |
58976 KB |
Output isn't correct |
9 |
Runtime error |
786 ms |
65536 KB |
Execution killed with signal 9 |
10 |
Incorrect |
773 ms |
65536 KB |
Output isn't correct |