# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
15860 | myungwoo | Palembang Bridges (APIO15_bridge) | C++14 | 0 ms | 2020 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>
using namespace std;
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
typedef long long lld;
int K, N;
int main()
{
scanf("%d%d", &K, &N);
vector <int> arr;
lld ans = 0;
for (int i=1;i<=N;i++){
char p, q; int a, b;
scanf(" %c%d %c%d", &p, &a, &q, &b);
if (p == q){
ans += abs(a-b);
continue;
}
ans++;
arr.pb(a); arr.pb(b);
}
sort(all(arr));
int x = arr[sz(arr)/2];
for (int t: arr) ans += abs(t - x);
printf("%lld\n", ans);
}
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... |