# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
875538 |
2023-11-20T03:04:06 Z |
12345678 |
Vudu (COCI15_vudu) |
C++17 |
|
1000 ms |
65536 KB |
#include <bits/stdc++.h>
using namespace std;
const int nx=1e6+5;
long long n, p, qs[nx], t, res;
map<long long, int> mp;
struct fenwick
{
int d[nx];
void add(int idx)
{
for (int i=idx; i<=n; i+=(i&-i)) d[i]++;
}
int query(int idx)
{
int res=0;
for (int i=idx; i>0; i-=(i&-i)) res+=d[i];
return res;
}
} f;
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n;
mp[0]=0;
for (int i=1; i<=n; i++) cin>>qs[i], qs[i]+=qs[i-1];
cin>>p;
for (int i=0; i<n; i++) mp[qs[i]-i*p]=0;
for (auto &[x, y]:mp) mp[x]=++t;
f.add(mp[0]);
for (int i=1; i<=n; i++)
{
res+=f.query(mp[qs[i]-i*p]);
//cout<<i<<' '<<res<<'\n';
f.add(mp[qs[i]-i*p]);
}
cout<<res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1077 ms |
2908 KB |
Time limit exceeded |
2 |
Execution timed out |
1060 ms |
2652 KB |
Time limit exceeded |
3 |
Execution timed out |
1062 ms |
2652 KB |
Time limit exceeded |
4 |
Runtime error |
304 ms |
65536 KB |
Execution killed with signal 9 |
5 |
Execution timed out |
1102 ms |
47664 KB |
Time limit exceeded |
6 |
Execution timed out |
1014 ms |
65536 KB |
Time limit exceeded |
7 |
Runtime error |
363 ms |
65536 KB |
Execution killed with signal 9 |
8 |
Execution timed out |
1006 ms |
65380 KB |
Time limit exceeded |
9 |
Runtime error |
248 ms |
65536 KB |
Execution killed with signal 9 |
10 |
Execution timed out |
1068 ms |
65536 KB |
Time limit exceeded |