# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
318050 |
2020-10-31T10:42:11 Z |
Dymo |
Vudu (COCI15_vudu) |
C++14 |
|
938 ms |
32520 KB |
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
#define endl "\n"
const ll maxn=5e5+50;
const ll mod =998244353 ;
const ll base=3e18;
vector<ll> vt;
ll st[2][4*maxn];
ll a[maxn];
void update(ll id,ll left,ll right,ll x,ll diff,ll t )
{
if (x>right||x<left) return ;
if (right==left )
{
st[t][id]+=diff;
return ;
}
ll mid=(left+right)/2;
update(id*2,left,mid, x, diff,t);
update(id*2+1, mid+1, right, x, diff,t);
st[t][id]=(st[t][id*2]+st[t][id*2+1]);
}
ll get(ll id,ll left,ll right,ll x,ll y,ll t)
{
if (x>right||y<left||x> y) return 0;
if (x<=left&&y>=right)
{
return st[t][id];
}
ll mid=(left+right)/2;
return get(id*2,left,mid, x, y, t )+get(id*2+1, mid+1, right, x, y, t);
}
ll f[maxn];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
vector<ll> vt;
vt.pb(-1e17);
vt.pb(0);
ll n;
ll p;
cin>>n;
for (ll i=1;i<=n;i++) cin>>a[i], f[i]=f[i-1]+a[i];
cin>>p ;
for (ll i=1;i<=n;i++)
{
vt.pb(f[i]-i*p);
}
sort(vt.begin(),vt.end());
vt.resize(unique(vt.begin(),vt.end())-vt.begin());
auto h=lower_bound(vt.begin(),vt.end(),0)-vt.begin();
// for (auto to:)
update(1,1,vt.size(),h,1,0);
ll ans=0;
for (ll i=1;i<=n;i++)
{
auto h=lower_bound(vt.begin(),vt.end(),f[i]-i*p)-vt.begin();
ans=ans+get(1,1,vt.size(),1,h,0);
// cout <<h<<endl;
// if (a[i]>=p) ans++;
update(1,1,vt.size(),h,1,0);
}
cout <<ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
748 KB |
Output is correct |
2 |
Correct |
4 ms |
748 KB |
Output is correct |
3 |
Correct |
4 ms |
748 KB |
Output is correct |
4 |
Incorrect |
938 ms |
32340 KB |
Output isn't correct |
5 |
Incorrect |
485 ms |
28992 KB |
Output isn't correct |
6 |
Incorrect |
798 ms |
31432 KB |
Output isn't correct |
7 |
Incorrect |
800 ms |
31652 KB |
Output isn't correct |
8 |
Incorrect |
701 ms |
30788 KB |
Output isn't correct |
9 |
Incorrect |
907 ms |
32520 KB |
Output isn't correct |
10 |
Incorrect |
784 ms |
31556 KB |
Output isn't correct |