Submission #582812

#TimeUsernameProblemLanguageResultExecution timeMemory
582812Justin1Palembang Bridges (APIO15_bridge)C++14
22 / 100
109 ms3856 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; struct ppl { ll h,o; //house, office }; ll n,m,k,x,y,z; vector<ll> median; vector<ppl> city; char st, ed; void sub1() { ll ans = 0; for (int i = 1; i <= n; i++) { cin >> st >> x >> ed >> y; if (st == ed) ans += abs(x-y); else { median.push_back(x); median.push_back(y); city.push_back({x,y}); } } sort(median.begin(),median.end()); if (median.size()) { ll bridge = median[median.size()/2]; for (auto i : city) ans += abs(i.h-bridge) + abs(i.o-bridge) + 1; } cout << ans << "\n"; } void sub2() { cout << "oh no :("; } signed main() { cin >> m >> n; if (m == 1) sub1(); else sub2(); }
#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...