Submission #404615

#TimeUsernameProblemLanguageResultExecution timeMemory
404615sadPalembang Bridges (APIO15_bridge)C++14
0 / 100
1 ms288 KiB
#include <bits/stdc++.h> #define ll long long #define fi first #define se second #define pb push_back using namespace std; int k,n;ll re=0; map<int,int>st,en; ll no=0,fin=0; int main() { cin>>k>>n;ll w=0; for(int i=0;i<n;i++) { char a,b; int x,y; cin>>a>>x>>b>>y; re+=abs(x-y); if(a==b)continue;re++; if(x>y)swap(x,y); st[x]++; st[y];no++; en[y]++;w+=x; } ll mn=1e17; int last=0; for(auto it:st) { w+=fin*(it.fi-last); w-=no*(it.fi-last); fin+=en[it.fi]; no-=st[it.fi]; mn=min(mn,w);last=it.fi; // cout<<it.fi<<" "<<w<<endl; } re+=mn*2; cout<<re; }

Compilation message (stderr)

bridge.cpp: In function 'int main()':
bridge.cpp:19:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   19 |         if(a==b)continue;re++;
      |         ^~
bridge.cpp:19:26: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   19 |         if(a==b)continue;re++;
      |                          ^~
#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...