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<iostream>
#include<algorithm>
#include<cstring>
#include<iomanip>
#include<map>
#include<utility>
#include<unordered_map>
#include<vector>
#include<set>
#define pii pair<int,int>
#define F first
#define S second
#define ll long long
#define pb push_back
using namespace std;
const int N = (int)1e5 + 5, mod = (ll)1e9 + 7;
int n, k, x, y;
char ch, hc;
int sm = 0, sm2 = (ll)1e9 + 18;
vector<int> vc;
int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> k >> n;
//if(k == 2 && n < 101)sub();
// cerr << "\n enteres #sub1 \n";
for(int i = 1; i <= n; i ++){
cin >> ch >> x >> hc >> y;
if(ch == hc) sm += abs(x - y);
else sm ++, vc.pb(x), vc.pb(y);
}
sort(vc.begin(), vc.end());
int pos = vc[(vc.size() - 1) / 2];
for(auto x : vc)sm += abs(x - pos);
cout << sm << endl;
}
# | 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... |