# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
20240 | baneling100 | Palembang Bridges (APIO15_bridge) | C++98 | 0 ms | 2676 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 <stdlib.h>
#include <algorithm>
#define N_MAX 100000
using namespace std;
int K, N, A[(N_MAX<<1)+1];
int M, Left[N_MAX+1], Right[N_MAX+1];
long long Ans;
int main(void) {
int i, x, y;
char t1, t2;
scanf("%d %d ",&K,&N);
for(i=1 ; i<=N ; i++) {
scanf("%c %d %c %d ",&t1,&x,&t2,&y);
if(t1==t2) Ans+=abs(x-y);
else {
Left[++M]=min(x,y);
Right[ M]=max(x,y);
}
}
if(K==1) {
for(i=1 ; i<=M ; i++) {
A[2*i-1]=Left[i];
A[2*i ]=Right[i];
}
sort(A+1,A+(M<<1)+1);
for(i=1 ; i<=M ; i++)
Ans+=(long long)abs(A[M]-Left[i])+abs(A[M]-Right[i])+1;
printf("%d",Ans);
}
else {
}
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... |