Submission #1017742

#TimeUsernameProblemLanguageResultExecution timeMemory
1017742aufanPalembang Bridges (APIO15_bridge)C++17
22 / 100
34 ms6408 KiB
#include <bits/stdc++.h> #define int long long #define fi first #define se second using namespace std; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int k, n; cin >> k >> n; int ans = 0; vector<int> a, b; for (int i = 0; i < n; i++) { char p, q; int s, t; cin >> p >> s >> q >> t; if (p == q) { ans += abs(s - t); } else { if (p == 'A') { a.push_back(s); b.push_back(t); } else { a.push_back(t); b.push_back(s); } } } if (k == 1) { int m = (int)a.size(); vector<int> c; for (int i = 0; i < m; i++) { c.push_back(a[i]); c.push_back(b[i]); } sort(c.begin(), c.end()); ans += m; for (int i = 0; i < 2 * m; i++) { ans += abs(c[i] - c[m]); } cout << ans << '\n'; } else if (k == 2) { } 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...