# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
967692 |
2024-04-22T16:05:26 Z |
jadai007 |
Vudu (COCI15_vudu) |
C++14 |
|
257 ms |
47412 KB |
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e6 + 1e4;
int n,k,arr[1000010], ans, qs[1000010], fw[N];
vector<int> vc;
void update(int idx, int val){
for(int i = idx; i<=N - 1; i+=(i&-i)) fw[i]+=val;
}
int query(int idx){
int sum = 0;
for(int i = idx; i>0; i-=(i&-i)) sum+=fw[i];
return sum;
}
signed main(){
cin.tie(nullptr)->sync_with_stdio(false);
cin >> n;
for(int i = 1; i<=n; ++i) cin >> arr[i];
for(int i = 1; i<=n; ++i) qs[i] = qs[i - 1] + arr[i];
cin >> k;
for(int i = 0; i<=n; ++i) vc.push_back(qs[i] - k*i);
sort(vc.begin(), vc.end());
vc.erase(unique(vc.begin(), vc.end()));
for(int i = 0; i<=n; ++i){
int idx = lower_bound(vc.begin(), vc.end(), qs[i] - k*i) - vc.begin();
ans+=query(idx+1);
update(idx+1, 1);
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
6748 KB |
Output is correct |
2 |
Correct |
2 ms |
6748 KB |
Output is correct |
3 |
Correct |
3 ms |
6748 KB |
Output is correct |
4 |
Correct |
257 ms |
31276 KB |
Output is correct |
5 |
Correct |
140 ms |
23756 KB |
Output is correct |
6 |
Runtime error |
132 ms |
47412 KB |
Execution killed with signal 11 |
7 |
Correct |
230 ms |
29224 KB |
Output is correct |
8 |
Correct |
190 ms |
28596 KB |
Output is correct |
9 |
Correct |
252 ms |
31732 KB |
Output is correct |
10 |
Correct |
216 ms |
29496 KB |
Output is correct |