# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
968000 |
2024-04-23T06:50:17 Z |
jadai007 |
Vudu (COCI15_vudu) |
C++14 |
|
372 ms |
29764 KB |
#include<bits/stdc++.h>
using namespace std;
int n,k,arr[1000100], qs[1000100];
vector<int> v;
long long ans, fw[1000100];
void update(int idx, int val){
for(; idx <= n; idx+=(idx&-idx)) fw[idx]+=val;
}
int query(int idx){
int sum = 0;
for(; idx; idx-=(idx&-idx)) sum+=fw[idx];
return sum;
}
signed main(){
cin.tie(nullptr)->sync_with_stdio(false);
cin >> n;
for(int i = 1; i<=n; ++i) cin >> arr[i];
cin >> k;
for(int i = 1; i<=n; ++i) qs[i] = qs[i - 1] + arr[i];
for(int i = 0; i<=n; ++i) v.push_back(qs[i] - i*k);
sort(v.begin(), v.end());
v.erase(unique(v.begin(), v.end()));
//update(1, 1);
for(int i = 0; i<=n; ++i){
int id = lower_bound(v.begin(), v.end(), qs[i] - i*k) - v.begin();
ans+=query(id+1);
update(id+1, 1);
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4696 KB |
Output is correct |
2 |
Correct |
2 ms |
4700 KB |
Output is correct |
3 |
Correct |
2 ms |
4572 KB |
Output is correct |
4 |
Incorrect |
360 ms |
29372 KB |
Output isn't correct |
5 |
Incorrect |
170 ms |
22052 KB |
Output isn't correct |
6 |
Incorrect |
295 ms |
27324 KB |
Output isn't correct |
7 |
Incorrect |
301 ms |
27776 KB |
Output isn't correct |
8 |
Incorrect |
255 ms |
25628 KB |
Output isn't correct |
9 |
Incorrect |
372 ms |
29764 KB |
Output isn't correct |
10 |
Incorrect |
317 ms |
27304 KB |
Output isn't correct |