# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
970657 | kilkuwu | Palembang Bridges (APIO15_bridge) | C++17 | 32 ms | 3544 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define nl '\n'
signed main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int k, n;
std::cin >> k >> n;
int cnt = 0;
std::vector<int> x_vals;
int64_t ans = 0;
for (int i = 0; i < n; i++) {
char p, q;
int s, t;
std::cin >> p >> s >> q >> t;
if (p == q) {
ans += std::abs(t - s);
} else {
x_vals.push_back(s);
x_vals.push_back(t);
ans++;
}
}
std::sort(x_vals.begin(), x_vals.end());
int med = x_vals.size() / 2;
for (int i = 0; i < (int) x_vals.size(); i++) {
ans += std::abs(x_vals[i] - x_vals[med]);
}
std::cout << ans << nl;
}
/*
1 5
B 0 A 4
B 1 B 3
A 5 B 7
B 2 A 6
B 1 A 7
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |