# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
40836 | Hassoony | Vudu (COCI15_vudu) | C++14 | 1081 ms | 65536 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef double D;
const ll inf=(1ll<<61);
const int mod=1e9+7;
const int MX=1e6+9;
int n,bit[MX];
int a[MX];
ll p;
map<ll,int>hashy;
void add(int x){
while(x<MX){
bit[x]++;
x+=x&-x;
}
}
int get(int x){
int ret=0;
while(x){
ret+=bit[x];
x-=x&-x;
}
return ret;
}
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++){
scanf("%d",&a[i]);
}
ll sum=0;
scanf("%lld",&p);
for(int i=1;i<=n;i++){
sum+=a[i];
sum-=p;
hashy[sum]=1;
}
hashy[0]=1;
int tt=0;
for(auto pp:hashy){
hashy[pp.first]=++tt;
}
add(hashy[0]);
ll ans=0;
int x;
for(int i=1;i<=n;i++){
sum+=a[i];
sum-=p;
x=hashy[sum];
// cout<<prf[i]<<" ";
ans+=get(x);
add(x);
}
// cout<<endl;
cout<<ans<<endl;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |