Submission #720740

#TimeUsernameProblemLanguageResultExecution timeMemory
720740mseebacherPalembang Bridges (APIO15_bridge)C++17
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> using namespace std; // Idee 1 -> Set mit Wert|Index pair // Idee 2 -> SegTree damit struct Platz{ char type; int c; }; void solve(){ int k; cin >> k; int n; cin >> n; vector<Platz> home(n); vector<Platz> arbeit(n); for(int i = 0;i<n;i++){ cin >> home[i].type >> home[i].c >> arbeit[i].type >> arbeit[i].c; } long long ans = 1e18; for(int i = 0;i<n;i++){ for(int h = i+1;h<n;h++){ long long sum = 0; for(int j = 0;j<n;j++){ if(home[j].type == arbeit[j].type){ sum += abs(home[j].c-arbeit[j].c); }else{ sum += min(abs(home[j].c-home[i].c) + abs(arbeit[j].c - home[i].c), abs(home[j].c-home[h].c) + abs(arbeit[j].c - home[h].c))+1; } } ans = min(ans,sum); } } cout << ans; } int main(){ ios::sync_with_stdio(0); cin.tie(nullptr); cout << fixed << setprecision(8); solve(); }
#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...