Submission #920036

#TimeUsernameProblemLanguageResultExecution timeMemory
920036AiperiiiPalembang Bridges (APIO15_bridge)C++14
8 / 100
2017 ms2904 KiB
#include <bits/stdc++.h> #define int long long #define ff first #define ss second #define pb push_back #define all(x) x.begin(),x.end() using namespace std; signed main(){ ios_base::sync_with_stdio(); cin.tie(0);cout.tie(0); int k,n; cin>>k>>n; vector <char> t1(n),t2(n); vector <int> x(n),y(n); for(int i=0;i<n;i++){ cin>>t1[i]>>x[i]>>t2[i]>>y[i]; } int mn=1e18; for(int i=0;i<n;i++){ int ans=0; for(int j=0;j<n;j++){ if(t1[j]==t2[j])ans+=abs(x[j]-y[j]); else{ ans+=abs(x[j]-x[i]); ans+=abs(y[j]-x[i]); ans++; } } mn=min(mn,ans); } cout<<mn<<"\n"; } /* 1 5 B 0 A 4 B 1 B 3 A 5 B 7 B 2 A 6 B 1 A 7 */
#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...