# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
456190 | nonsensenonsense1 | Palembang Bridges (APIO15_bridge) | C++17 | 1 ms | 332 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 <cstdio>
#include <algorithm>
#include <vector>
const int N = 100000;
int n, task;
std::vector<int> a;
int main()
{
scanf("%d%d", &task, &n);
long long ans_add = 0;
for (int i = 0; i < n; ++i) {
char type1, type2;
int l, r;
scanf(" %c%d %c%d", &type1, &l, &type2, &r);
if (l > r) std::swap(l, r);
if (type1 == type2) ans_add += r - l;
else {
++ans_add;
a.push_back(l);
a.push_back(r);
}
}
std::sort(a.begin(), a.end());
long long ans = 0;
for (int i = 0; i <= (int)a.size() / 2; ++i) ans += a[a.size() / 2] - a[i];
for (int i = (int)a.size() / 2 + 1; i < (int)a.size(); ++i) ans += a[i] - a[a.size() / 2];
printf("%lld\n", ans_add + ans);
return 0;
}
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... |