# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1144696 | SmuggingSpun | Palembang Bridges (APIO15_bridge) | C++20 | 27 ms | 1476 KiB |
#include<bits/stdc++.h>
#define taskname "C"
using namespace std;
typedef long long ll;
int k, n;
namespace sub12{
void solve(){
ll ans = 0;
vector<int>p;
for(int i = 0; i < n; i++){
char a, b;
int xa, xb;
cin >> a >> xa >> b >> xb;
if(a == b){
ans += abs(xa - xb);
}
else{
p.emplace_back(xa);
p.emplace_back(xb);
ans++;
}
}
if(!p.empty()){
sort(p.begin(), p.end());
int median = p[int(p.size()) >> 1];
for(int& x : p){
ans += abs(median - x);
}
}
cout << ans;
}
}
namespace sub345{
void solve(){
}
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if(fopen(taskname".inp", "r")){
freopen(taskname".inp", "r", stdin);
}
cin >> k >> n;
if(k == 1){
sub12::solve();
}
else{
sub345::solve();
}
}
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... |