답안 #762742

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
762742 2023-06-21T17:22:01 Z ETheBest3 Vudu (COCI15_vudu) C++14
0 / 140
102 ms 23712 KB
#include<bits/stdc++.h>
#define endl "\n"
#define lli long long
using namespace std;
const lli MAXN=1000005;
lli N, a[MAXN], P, pref[MAXN], tree[MAXN], ss[MAXN], ans;
map<lli, lli> m;
void update(lli i, lli d){
    while(i<=N+1){
        tree[i]+=d;
        i+=i&(-i);
    }
    return;
}
lli query(lli i){
    lli otg=0;
    while(i>0){
        otg+=tree[i];
        i-=i&(-i);
    }
    return otg;
}
int main() {
    ios_base::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    cin>>N;
    for(lli i=1; i<=N; i++){
        cin>>a[i];
    }
    cin>>P;
    for(lli i=1; i<=N; i++){
        a[i]-=P;
        pref[i]=pref[i-1]+a[i];
        ss[i]=pref[i];
    }
    /*sort(ss, ss+N+1);
    lli k=1;
    for(lli i=0; i<=N; i++){
        if(i==0){
            m[ss[i]]=k;
            k++;
        }
        if(i!=0 and ss[i]==ss[i-1])continue;
        m[ss[i]]=k;
        k++;
    }
    update(m[0], 1);
    for(lli i=1; i<=N; i++){
        ans+=query(m[pref[i]]);
        update(m[pref[i]], 1);
    }*/
    cout<<ans<<endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 468 KB Output isn't correct
2 Incorrect 1 ms 468 KB Output isn't correct
3 Incorrect 1 ms 468 KB Output isn't correct
4 Incorrect 102 ms 22896 KB Output isn't correct
5 Incorrect 45 ms 13084 KB Output isn't correct
6 Incorrect 71 ms 20400 KB Output isn't correct
7 Incorrect 73 ms 21196 KB Output isn't correct
8 Incorrect 64 ms 18400 KB Output isn't correct
9 Incorrect 84 ms 23712 KB Output isn't correct
10 Incorrect 71 ms 20604 KB Output isn't correct