# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
94480 |
2019-01-19T10:00:59 Z |
theknife2001 |
Vudu (COCI15_vudu) |
C++11 |
|
1000 ms |
66560 KB |
#include <bits/stdc++.h>
#define ll long long
#define mid (l+r)/2
using namespace std;
map < ll , int > mp;
const int N=1e6+55;
int tree[N];
ll sum[N];
ll a[N];
int n;
int query(int x)
{
if(x<=0)
return 0;
return query(x-(x&(-x)))+tree[x];
}
void update(int x)
{
if(x>n)
return ;
tree[x]++;
update(x+(x&(-x)));
}
int main()
{
ios::sync_with_stdio(false);
cin>>n;
for(int i=0;i<n;i++)
cin>>a[i];
int p;
cin>>p;
for(int i=n-1;i>=0;i--)
{
sum[i]=a[i]-p;
if(i!=n-1)
sum[i]+=sum[i+1];
a[i]=sum[i];
}
sort(a,a+n);
int cnt=1;
for(int i=0;i<n;i++)
{
if(mp[a[i]]==0)
mp[a[i]]=cnt++;
}
ll ans=0;
for(int i=n-1;i>=0;i--)
{
if(sum[i]>=0)
ans++;
ans+=query(mp[sum[i]]);
update(mp[sum[i]]);
}
cout<<ans<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
1016 KB |
Output is correct |
2 |
Correct |
5 ms |
764 KB |
Output is correct |
3 |
Correct |
5 ms |
760 KB |
Output is correct |
4 |
Runtime error |
651 ms |
66560 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
5 |
Correct |
811 ms |
45548 KB |
Output is correct |
6 |
Runtime error |
621 ms |
66560 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
7 |
Runtime error |
621 ms |
66560 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
8 |
Execution timed out |
1081 ms |
63804 KB |
Time limit exceeded |
9 |
Runtime error |
628 ms |
66560 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
10 |
Runtime error |
627 ms |
66560 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |