# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
32179 | minchurl | Palembang Bridges (APIO15_bridge) | C++11 | 76 ms | 2672 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<stdio.h>
#include<math.h>
#include<algorithm>
#define MAX_N 100005
#define abs(x) ((x)>0?(x):(-(x)))
#define LL long long
using namespace std;
LL N,K;
LL arr[2*MAX_N],ans;
LL input(){
LL i,n,S,T,sum=0;
char P[2],Q[2];
n=0;
for(i=0;i<N;i++){
scanf("%s %lld %s %lld",P,&S,Q,&T);
if(P[0]==Q[0]){
sum+=abs(S-T);
}else{
arr[++n]=S;arr[++n]=T;
sum++;
}
}
N=n;
return sum;
}
LL bridge_only(){
LL i,x,sum=0;
sort(arr+1,arr+N+1);
x=N/2;
for(i=1;i<=N;i++) sum+=abs(arr[i]-arr[x]);
return sum;
}
int main(){
LL base;
scanf("%lld %lld",&K,&N);
base=input();
ans=bridge_only()+base;
if(K==1){
printf("%lld\n",ans);
return 0;
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |