Submission #9815004


Source Code Expand

#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=9000000000000000000;
long double pi=3.14159265358979323846L;
double eps=1e-12;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll popcount(ll n){
    ll ret=0;
    while(n>0){
        ret+=n%2;
        n/=2;
    }
    return ret;
}
ll gya[1000010];
ll kai[1000010];
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll bit[800010];
ll u;
void bitinit(ll n){
    ll y=1;
    rep(i,0,69){
        
        if(y>=n){
            u=y;
            break;
        }
        y*=2;
    }
    fill(bit,bit+u+10,0);
}
void add(ll n,ll x){
    ll i=n;
    bit[i]+=x;
    bit[i]%=mod;
    while(i<u){
        i+=i&(-i);
        bit[i]+=x;
        bit[i]%=mod;
    }
}
ll sum(ll n){
    ll i=n;
    ll ret=0;
    while(i>0){
        ret+=bit[i];
        i-=i&(-i);
        ret%=mod;
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n,k;cin>>n>>k;
    ll a[n+1];
    vector<pll> v;
    v.push_back({0,0});
    ll summ=0;
    ll ans=0;
    rep(i,1,n+1){
        cin>>a[i];
        summ+=a[i];
        ll t=summ-i*k;
        v.push_back({t,i});
    }
    sort(v.begin(),v.end());
    bitinit(n+1);
    ll num;
    rep(i,0,n+1){
        ll now=v[i].second;
        if(now==0){
            num=i;
            continue;
        }
        ll t=sum(now);
        ans+=t;
        add(now,1);
    }
    ans+=n-num;
    cout<<ans<<endl;
}


Submission Info

Submission Time
Task E - Meaningful Mean
User ttttan
Language C++14 (GCC 5.4.1)
Score 600
Code Size 2722 Byte
Status AC
Exec Time 95 ms
Memory 10220 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 3
AC × 23
Set Name Test Cases
Sample a01, a02, a03
All a01, a02, a03, b04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23
Case Name Status Exec Time Memory
a01 AC 1 ms 256 KB
a02 AC 1 ms 256 KB
a03 AC 1 ms 256 KB
b04 AC 1 ms 256 KB
b05 AC 82 ms 9196 KB
b06 AC 78 ms 9452 KB
b07 AC 94 ms 9196 KB
b08 AC 95 ms 9196 KB
b09 AC 80 ms 9196 KB
b10 AC 86 ms 9196 KB
b11 AC 1 ms 256 KB
b12 AC 1 ms 256 KB
b13 AC 31 ms 3056 KB
b14 AC 88 ms 10092 KB
b15 AC 72 ms 9836 KB
b16 AC 80 ms 9196 KB
b17 AC 88 ms 10220 KB
b18 AC 88 ms 9196 KB
b19 AC 78 ms 9836 KB
b20 AC 91 ms 9836 KB
b21 AC 86 ms 10092 KB
b22 AC 94 ms 9580 KB
b23 AC 92 ms 9836 KB