Submission #9814921


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);
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n,k;cin>>n>>k;
    ll a[n+1];
    vector<ll> v;
    v.push_back(0);
    ll sum=0;
    ll ans=0;
    rep(i,1,n+1){
        cin>>a[i];
        sum+=a[i];
        ll t=sum-i*k;
        ll y=upper_bound(v.begin(),v.end(),t)-v.begin();
        ans+=y;
        v.insert(v.begin()+y,t);
    }
    cout<<ans<<endl;
}


Submission Info

Submission Time
Task E - Meaningful Mean
User ttttan
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2011 Byte
Status TLE
Exec Time 2103 ms
Memory 3568 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 600
Status
AC × 3
AC × 10
TLE × 13
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 30 ms 3568 KB
b06 TLE 2103 ms 2292 KB
b07 TLE 2103 ms 2292 KB
b08 TLE 2103 ms 3444 KB
b09 TLE 2103 ms 3444 KB
b10 TLE 2103 ms 2292 KB
b11 AC 1 ms 256 KB
b12 AC 1 ms 256 KB
b13 AC 638 ms 1912 KB
b14 TLE 2103 ms 3444 KB
b15 TLE 2103 ms 2292 KB
b16 AC 30 ms 3568 KB
b17 AC 1009 ms 3568 KB
b18 TLE 2103 ms 3444 KB
b19 TLE 2103 ms 2292 KB
b20 TLE 2103 ms 3444 KB
b21 TLE 2053 ms 3568 KB
b22 TLE 2103 ms 2292 KB
b23 TLE 2103 ms 3444 KB