# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
968054 |
2024-04-23T07:26:59 Z |
vjudge1 |
Vudu (COCI15_vudu) |
C++17 |
|
1000 ms |
52408 KB |
#include<bits/stdc++.h>
using namespace std;
int n;
map<int, int> fw;
long long ans;
void update(int idx, int val){
for(; idx <= n; idx+=(idx&-idx)) fw[idx]+=val;
}
long long query(int idx){
long long sum = 0;
for(; idx; idx-=(idx&-idx)) sum+=fw[idx];
return sum;
}
signed main(){
cin.tie(nullptr)->sync_with_stdio(false);
cin >> n;
long long qs[n+1], k;
vector<long long> v;
memset(qs, 0, sizeof(qs));
for(int i = 1; i<=n; ++i) cin >> qs[i];
cin >> k;
for(int i = 1; i<=n; ++i) qs[i]+=qs[i - 1];
for(int i = 1; i<=n; ++i) v.push_back(qs[i] - i*k);
sort(v.begin(), v.end());
v.erase(unique(v.begin(), v.end()));
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 |
6 ms |
860 KB |
Output is correct |
2 |
Correct |
5 ms |
604 KB |
Output is correct |
3 |
Correct |
4 ms |
604 KB |
Output is correct |
4 |
Execution timed out |
1075 ms |
50068 KB |
Time limit exceeded |
5 |
Correct |
784 ms |
36464 KB |
Output is correct |
6 |
Runtime error |
127 ms |
31036 KB |
Execution killed with signal 11 |
7 |
Execution timed out |
1061 ms |
51660 KB |
Time limit exceeded |
8 |
Execution timed out |
1067 ms |
48064 KB |
Time limit exceeded |
9 |
Execution timed out |
1053 ms |
52408 KB |
Time limit exceeded |
10 |
Execution timed out |
1031 ms |
48784 KB |
Time limit exceeded |