답안 #49423

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
49423 2018-05-28T16:37:04 Z rzbt Vudu (COCI15_vudu) C++14
42 / 140
1000 ms 65536 KB
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define MAXN 1000005
typedef long long ll;
using namespace std;


ll n,p,res;
ll niz[MAXN];
ll bit[MAXN];
void update(ll p,ll x){
    for(;p<MAXN;p+=(p&(-p)))
        bit[p]+=x;
}
ll dobij(ll p){
    ll z=0;
    for(;p>0;p-=(p&(-p)))
        z+=bit[p];
    return z;
}
set<ll> s;
map<ll,ll> m;

int main()
{
    scanf("%lld", &n);
    for(ll i=1;i<=n;i++)
        scanf("%lld",niz+i);
    ll tzbir=0;
    scanf("%lld",&p);
    for(ll i=1;i<=n;i++){
        tzbir+=niz[i]-p;
        s.insert(tzbir);
    }
    ll tbr=0;
    for(auto x:s){
        tbr++;
        m[x]=tbr;
    }
    tzbir=0;
    for(ll i=1;i<=n;i++){
        tzbir+=niz[i]-p;
        if(tzbir>=0)res++;
        ll t=m[tzbir];
        res+=dobij(t);
        update(t,1);
    }
    printf("%lld",res);


    return 0;
}








Compilation message

vudu.cpp: In function 'int main()':
vudu.cpp:30:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld", &n);
     ~~~~~^~~~~~~~~~~~
vudu.cpp:32:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld",niz+i);
         ~~~~~^~~~~~~~~~~~~~
vudu.cpp:34:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&p);
     ~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 1272 KB Output is correct
2 Correct 7 ms 1272 KB Output is correct
3 Correct 6 ms 1272 KB Output is correct
4 Execution timed out 1091 ms 65536 KB Time limit exceeded
5 Execution timed out 1095 ms 65536 KB Time limit exceeded
6 Execution timed out 1063 ms 65536 KB Time limit exceeded
7 Execution timed out 1036 ms 65536 KB Time limit exceeded
8 Execution timed out 1077 ms 65536 KB Time limit exceeded
9 Execution timed out 1026 ms 65536 KB Time limit exceeded
10 Execution timed out 1048 ms 65536 KB Time limit exceeded