# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
932188 | 2024-02-23T05:14:37 Z | sleepntsheep | Palembang Bridges (APIO15_bridge) | C++17 | 1 ms | 348 KB |
#include<stdio.h> unsigned X=12345;int rand_(){return(X*=3)>>1;} int abs(int a){return a<0?-a:a;} int(*compar)(int,int); void sort(int*aa,int l,int r){ while(l<r){int i=l,j=l,k=r,tmp,p=aa[l+rand_()%(r-l)]; while(j<k)switch(compar(aa[j],p)){case 0:++j;break;case -1:tmp=aa[j],aa[j]=aa[i],aa[i]=tmp,++i,++j;break;case 1:tmp=aa[j],aa[j]=aa[--k],aa[k]=tmp;break;}sort(aa,l,i);l=k;} } int c0(int a,int b){return a<b?-1:a>b?1:0;} int a[1<<18],k,n0,n;char p,q;long long z; long long chk(int x){long long z=0;for(int i=0;i<n;++i)z+=abs(a[i]-x);return 0;} int main(){ scanf("%d%d",&k,&n0);for(int w,e,i=0;i<n0;++i){scanf(" %c%d %c%d",&p,&w,&q,&e);if(p-q)a[n++]=w,a[n++]=e,++z;else z+=abs(w-e);} compar=c0;sort(a,0,n); if(k==1){printf("%lld",z+chk(a[n/2]));return 0;} if(n<=100){ } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Incorrect | 0 ms | 348 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Incorrect | 1 ms | 348 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |