Submission #111340

#TimeUsernameProblemLanguageResultExecution timeMemory
111340ppnxblstrPalembang Bridges (APIO15_bridge)C++14
22 / 100
57 ms1648 KiB
#include <bits/stdc++.h> using namespace std; char p[2]; char q[2]; int main(){ int k, n; scanf("%d%d",&k,&n); vector<int> v; int s, t; long long d = 0ll; for(int i = 1; i <= n; i++){ scanf("%s%d%s%d",p,&s,q,&t); if(p[0] == q[0]){ d += (long long)abs(s-t); }else{ v.push_back(s); v.push_back(t); } } sort(v.begin(), v.end()); if(k == 1){ int x = v[(v.size()-1)/2]; for(int i : v){ d += (long long)abs(i-x); } printf("%lld\n",d + v.size()/2); return 0; } } /* 1 5 B 0 A 4 B 1 B 3 A 5 B 7 B 2 A 6 B 1 A 7 */

Compilation message (stderr)

bridge.cpp: In function 'int main()':
bridge.cpp:7:10: 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:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%s%d%s%d",p,&s,q,&t);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#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...