# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1088442 | Sunbae | Palembang Bridges (APIO15_bridge) | C++17 | 32 ms | 3432 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>
typedef long long ll;
using namespace std;
int a[200000];
signed main(){
int k, n, m = 0; scanf("%d %d", &k, &n);
ll tot = 0, s[2] = {0, 0};
for(int i = 0; i<n; ++i){
char c[2]; int p[2]; scanf(" %c %d %c %d", c, p, c+1, p+1);
if(c[0] == c[1]) tot += abs(p[0]-p[1]);
else {a[m++] = p[0]; a[m++] = p[1];}
}
sort(a, a+m);
for(int j = 0; j<2; ++j) for(int i = 0; i<m; ++i) s[j] += abs(a[i] - a[m/2 - j]);
printf("%lld", tot + min(s[0], s[1]) + m/2);
}
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... |