Submission #108066

#TimeUsernameProblemLanguageResultExecution timeMemory
108066autumn_eelPalembang Bridges (APIO15_bridge)C++14
22 / 100
79 ms4840 KiB
#include <bits/stdc++.h> #define rep(i,n)for(int i=0;i<(n);i++) using namespace std; typedef long long ll; char p[200000][2],q[200000][2]; int s[200000],t[200000]; int main(){ int K,n;cin>>K>>n; if(K!=1)abort(); vector<int>v; ll sum=0; rep(i,n){ scanf("%s%d%s%d",p[i],&s[i],q[i],&t[i]); if(p[i][0]==q[i][0]){ sum+=abs(s[i]-t[i]); continue; } sum++; v.push_back(s[i]); v.push_back(t[i]); } sort(v.begin(),v.end()); int md=v[v.size()/2]; for(int i:v)sum+=abs(i-md); cout<<sum<<endl; }

Compilation message (stderr)

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