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;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int K, people;
cin>>K>>people;
vector<int> values;
int output = 0;
while( people-- ){
char p, q;
int s, t;
cin>>p>>s>>q>>t;
if( p != q ){ values.push_back(s); values.push_back(t); }
else{ output += abs(s-t); }
}
sort(values.begin(), values.end());
if( !values.empty() ){
int m = values[(((int)values.size()+1)/2)-1];
for( int x : values ) output += abs(x-m);
}
output += (int)values.size()/2;
cout<<output<<'\n';
return 0;
}
# | 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... |