제출 #582814

#제출 시각아이디문제언어결과실행 시간메모리
582814Justin1Palembang Bridges (APIO15_bridge)C++14
22 / 100
114 ms4036 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; ll cal(vector<ppl> & city, vector<ll> & median) { ll ans = 0; 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; } return ans; } 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}); } } cout << ans + cal(city,median) << "\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...