Submission #2208878


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=10000;
const ll INF=1000000000;
const int MAX=100001;
const double EPS=1e-10;
using namespace std;
struct BIT{
    vector<int>bit;
    int n=1;
    void init(int m){
        while(n<m){
            n*=2;
        }
        bit.resize(n+1);
    }
    int sum(int i){
        int s=0;
        while(i>0){
            s+=bit[i];
            i-=i&-i;
        }
        return s;
    }
    void add(int i,int x){
        while(i<=n){
            bit[i]+=x;
            i+=i&-i;
        }
    }
};
ll b[200010];
map<ll,int> m;
void compress(int n){
    vector<int> v;
    for(int i=0;i<=n;i++){
        v.push_back(b[i]);
    }
    sort(v.begin(),v.end());
    for(int i=0;i<(int)v.size();i++){
        m[v[i]]=i+1;
    }
}
int main() {
    int n;ll k;ll a[200010];
    cin>>n>>k;
    ll sum=0;
    b[0]=0;
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i]);
        sum+=a[i];
        b[i]=sum-i*k;
    }
    compress(n);
    BIT bit;
    bit.init(n+1);
    int ans=0;
    for(int i=0;i<=n;i++){
        int x=m[b[i]];
        ans+=bit.sum(x);
        bit.add(x,1);
    }
    cout<<ans<<endl;
    
}






Submission Info

Submission Time
Task E - Meaningful Mean
User TAISA_
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1286 Byte
Status WA
Exec Time 2104 ms
Memory 18916 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:52:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld",&a[i]);
                            ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 600
Status
AC × 3
AC × 7
WA × 2
TLE × 14
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 WA 36 ms 4472 KB
b06 AC 159 ms 16868 KB
b07 TLE 2104 ms 10596 KB
b08 TLE 2104 ms 10596 KB
b09 WA 171 ms 16868 KB
b10 TLE 2104 ms 16868 KB
b11 AC 1 ms 256 KB
b12 TLE 2103 ms 256 KB
b13 TLE 2104 ms 6364 KB
b14 TLE 2104 ms 16868 KB
b15 AC 119 ms 10596 KB
b16 TLE 2104 ms 18916 KB
b17 TLE 2104 ms 16868 KB
b18 TLE 2104 ms 16868 KB
b19 TLE 2104 ms 16868 KB
b20 TLE 2104 ms 4472 KB
b21 TLE 2104 ms 4472 KB
b22 TLE 2104 ms 16868 KB
b23 TLE 2104 ms 16868 KB