Submission #797415

#TimeUsernameProblemLanguageResultExecution timeMemory
797415acatmeowmeowPalembang Bridges (APIO15_bridge)C++11
22 / 100
32 ms6600 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int N = 1e5; int k, n, s[N + 5], t[N + 5]; char p[N + 5], q[N + 5]; namespace sub2 { void main(int n, int k, int s[], int t[], char p[], char q[]) { vector<int> arr; int init = 0; for (int i = 1; i <= n; i++) { if (p[i] == q[i]) init += abs(s[i] - t[i]); else arr.push_back(s[i]), arr.push_back(t[i]), init++; } sort(arr.begin(), arr.end()); int ans = 0, mid = arr.size()/2; for (auto&v : arr) ans += abs(v - arr[mid]); cout << init + ans << '\n'; } } signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> k >> n; for (int i = 1; i <= n; i++) cin >> p[i] >> s[i] >> q[i] >> t[i]; if (k == 1) sub2::main(n, k, s, t, p, q); else cout << 0 << '\n'; 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...