Submission #43380

#TimeUsernameProblemLanguageResultExecution timeMemory
43380top34051Palembang Bridges (APIO15_bridge)C++14
8 / 100
28 ms2304 KiB
#include<bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; int n,k,sz; int pos[maxn]; int main() { long long ans = 0; scanf("%d%d",&k,&n); for(int i=1;i<=n;i++) { int x, y; char t1, t2; scanf(" %c%d %c%d",&t1,&x,&t2,&y); if(t1==t2) ans += abs(y-x); else { pos[sz++] = x; pos[sz++] = y; ans++; } } sort(&pos[0],&pos[sz]); int opt = pos[sz/2]; // printf("opt %d\n",opt); for(int i=0;i<sz;i++) ans += abs(opt-pos[i]); printf("%lld",ans); }

Compilation message (stderr)

bridge.cpp: In function 'int main()':
bridge.cpp:8:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&k,&n);
                        ^
bridge.cpp:12:42: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf(" %c%d %c%d",&t1,&x,&t2,&y);
                                          ^
#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...