| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1345919 | killerzaluu | Palembang Bridges (APIO15_bridge) | C++20 | 1 ms | 344 KiB |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int k, n;
cin >> k >> n;
long long ans = 0;
vector<long long> v;
for (int i = 1; i <= n; i++) {
string a, b;
cin >> a >> b;
char p = a[0];
long long s = stoll(a.substr(1));
char q = b[0];
long long t = stoll(b.substr(1));
if (p == q) {
ans += llabs(s - t);
} else {
ans++;
v.push_back(s);
v.push_back(t);
}
}
if (!v.empty()) {
sort(v.begin(), v.end());
long long x = v[(int)v.size() / 2];
for (long long z : v) ans += llabs(z - x);
}
cout << ans << '\n';
return 0;
}| # | 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... | ||||
