제출 #43683

#제출 시각아이디문제언어결과실행 시간메모리
43683RezwanArefin01Palembang Bridges (APIO15_bridge)C++14
0 / 100
2 ms556 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> ii; vector<ii> v; ll get(int x) { ll ret = 0; for(ii a : v) ret += abs(a.first - x) + abs(a.second - x); return ret; } int main(int argc, char const *argv[]) { #ifdef LOCAL_TESTING freopen("in", "r", stdin); #endif int k, n; cin >> k >> n; ll pre = 0; vector<int> pos; for(int i = 0; i < n; i++) { char p, q; int s, t; cin >> p >> s >> q >> t; if(p == q) pre += abs(s - t); else v.push_back({s, t}), pos.push_back(s), pos.push_back(t); } /*int m = pos.size(); sort(pos.begin(), pos.end()); ll mn = get(pos[m >> 1]); if(m/2+1 < m) mn = min(mn, get(pos[m/2 + 1])); cout << mn + v.size() + pre << endl;*/ }
#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...