제출 #837145

#제출 시각아이디문제언어결과실행 시간메모리
837145vjudge1Palembang Bridges (APIO15_bridge)C++17
0 / 100
1 ms340 KiB
#include <bits/stdc++.h> using namespace std; #define futaba ios_base::sync_with_stdio(false); cin.tie(NULL); #define rio return 0; #define ll long long #define fi first #define se second // Fun things are fun. // int main() { /* freopen(".txt", "r", stdin); freopen(".txt", "w", stdout); */ futaba ll k, n; cin >> k >> n; ll ans = 0; if(k == 1) { vector<ll> v; vector<pair<ll, ll>> v2; while(n--) { char p; cin >> p; ll s; cin >> s; char q; cin >> q; ll t; cin >> t; if(p == q) ans += abs(s - t); else { v.push_back(abs(s - t) + 1); v2.push_back({s, t}); } } sort(v.begin(), v.end()); ll x = v[(int)v.size() / 2]; for(auto i : v2) ans += (abs(i.fi - x) + abs(i.se - x)) + 1; cout << ans << '\n'; } rio }
#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...