Submission #14451

#TimeUsernameProblemLanguageResultExecution timeMemory
14451dohyun0324Palembang Bridges (APIO15_bridge)C++98
22 / 100
76 ms2680 KiB
#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)

bridge.cpp: In function 'int main()':
bridge.cpp:16:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d",&k,&n);
                         ^
bridge.cpp:19:46: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf(" %c %d %c %d",&c1,&x1,&c2,&x2);
                                              ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...