제출 #895420

#제출 시각아이디문제언어결과실행 시간메모리
895420WobertPalembang Bridges (APIO15_bridge)C++17
22 / 100
33 ms3556 KiB
#include "bits/stdc++.h" #ifdef LOCAL #include "dbg.h" #else #define dbg(...) 0 #endif #define fox(i, n) for (int i = 0; i < (n); ++i) #define rep(i, a, b) for (int i = (a); i < (b); ++i) #define rin(i, a, b) for (int i = (a); i <= (b); ++i) #define rrep(i, a, b) for (int i = (a); i >= (b); --i) #define fore(x, v) for (auto &&x : v) #define forp(a, b, v) for (auto &&[a, b] : v) #define pb push_back #define eb emplace_back #define F first #define S second #define all(x) begin(x), end(x) #define EL "\n" using namespace std; using vi = vector<int>; using ll = long long; using vll = vector<ll>; using pii = pair<int, int>; using pll = pair<ll, ll>; using vpii = vector<pii>; using vpll = vector<pll>; template<class T> int sz(T& container) { return (int) container.size(); } template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; } template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; } ll cdiv(ll a, ll b) { return a/b+((a^b)>0&&a%b); } ll fdiv(ll a, ll b) { return a/b-((a^b)<0&&a%b); } //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); //ll urand(int a, int b) { return rng() % (b-a+1) + a; } //const vector<pii> deltas = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}}; //const int INF = 0x3f3f3f3f; void solve() { int k, n; cin >> k >> n; ll ans = 0; vi v; fox(_, n) { char c, d; int x, y; cin >> c >> x >> d >> y; if (c == d) { ans += abs(x-y); continue; } ans += 1; v.pb(x); v.pb(y); } sort(all(v)); if (!v.empty()) { int med = v[sz(v)/2]; fore(x, v) ans += abs(med-x); } cout << ans << EL; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); // int t; // cin >> t; // while (t--) solve(); return 0; }
#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...