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;
using ll=long long;
int k, n;
const int N=1e5+13;
int a[N];
ll res;
char c1, c2;
int x, y;
vector<int> v;
void scan(){
cin >> k >> n;
for(int i=1; i<=n; i++){
cin >> c1 >> x >> c2 >> y;
if(c1==c2){
res+=abs(x-y);
}
else{
v.push_back(x);
v.push_back(y);
++res;
}
}
sort(begin(v), end(v));
}
void solve(){
for(int c: v){
res+=abs(c-v[v.size()/2-1]);
}
cout << res;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
scan();
solve();
}
# | 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... |