# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
875445 | 2023-11-19T17:35:29 Z | imarn | Vudu (COCI15_vudu) | C++14 | 174 ms | 15964 KB |
#include<stdio.h> #define ll long long using namespace std; const int N=1e6+5; ll a[N]{0}; ll cnt=0; void dac(int l,int r){ if(l>=r)return; int m=(l+r)>>1; dac(l,m);dac(m+1,r); int sz1=m-l+1,sz2=r-m; ll le[sz1],re[sz2]; for(int i=0;i<sz1;i++)le[i]=a[i+l]; for(int i=0;i<sz2;i++)re[i]=a[m+1+i]; int li=0,ri=0,mi=l; while(li<sz1&&ri<sz2){ if(le[li]<=re[ri])cnt+=sz2-ri,a[mi++]=le[li++]; else a[mi++]=re[ri++]; }while(li<sz1)a[mi++]=le[li++]; while(ri<sz2)a[mi++]=re[ri++]; } int main(){ int n;scanf("%d",&n); for(int i=1;i<=n;i++)scanf("%lld",&a[i]); ll p;scanf("%lld",&p); for(int i=1;i<=n;i++)a[i]+=a[i-1]-p; dac(0,n);printf("%lld",cnt); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 162 ms | 15336 KB | Output is correct |
5 | Correct | 96 ms | 9840 KB | Output is correct |
6 | Correct | 144 ms | 14164 KB | Output is correct |
7 | Correct | 144 ms | 14676 KB | Output is correct |
8 | Correct | 136 ms | 13648 KB | Output is correct |
9 | Correct | 174 ms | 15964 KB | Output is correct |
10 | Correct | 147 ms | 14412 KB | Output is correct |