# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
14451 | dohyun0324 | Palembang Bridges (APIO15_bridge) | C++98 | 76 ms | 2680 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<algorithm>
using namespace std;
char c1,c2;
long long dap;
int w2,k,n,x1,x2,w,arr[200010];
struct data{
int x,y;
bool operator<(const data&r)const{
return (x+y)<r.x+r.y;
}
}a[100010];
int main()
{
int i;
scanf("%d %d",&k,&n);
for(i=1;i<=n;i++)
{
scanf(" %c %d %c %d",&c1,&x1,&c2,&x2);
if(c1==c2) dap+=abs(x2-x1);
else{w++; a[w].x=x1; a[w].y=x2; arr[++w2]=x1; arr[++w2]=x2;}
}
sort(a+1,a+w+1); sort(arr+1,arr+w2+1);
if(k==1)
{
for(i=1;i<=w2;i++) dap+=abs(arr[i]-arr[w]);
}
else
{
}
printf("%lld",dap+w);
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... |