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"
#define ll long long int
#define pb push_back
#define pii pair<int,int>
#define ff first
#define ss second
#define sz size()
const int N = 2e5 + 1;
using namespace std;
ll n, k, x[N], y[N], gos;
char s[N], d[N];
vector <int> v;
int main(){
ios::sync_with_stdio(false); cin.tie(nullptr);
//freopen("input.in", "r", stdin);
//freopen("output.out", "w", stdout);
cin >> k >> n;
for(int i = 1; i <= n; i++){
cin >> s[i] >> x[i] >> d[i] >> y[i];
if(s[i] != d[i]){
gos++;
v.pb(x[i]);
v.pb(y[i]);
}
else {
gos += abs (x[i] - y[i]);
}
}
sort(v.begin(), v.end());
int n1 = v.sz/2;
int med = v[n1];
for(auto i: v){
gos += abs(med-i);
}
cout << gos;
}
# | 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... |