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 fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);
using namespace std;
struct line{
char x,z;
long long y,t;
}a[100009];
vector<long long>b;
long long pf[200009];
int main()
{
fastio
int k,n;
cin>>k>>n;
long long ans=0;
for (int i=1;i<=n;i++){
cin>>a[i].x>>a[i].y>>a[i].z>>a[i].t;
if (a[i].x!=a[i].z){
b.push_back(a[i].y);
b.push_back(a[i].t);
ans++;
}
else {
ans+=abs(a[i].y-a[i].t);
}
}
if (k==1){
sort(b.begin(),b.end());
int d=(int)b.size();
d/=2;
for (int i=0;i<(int)b.size();i++){
if (b[i]<=b[d]){
ans=ans+b[d]-b[i];
}
else ans=ans+b[i]-b[d];
}
cout<<ans;
}
}
# | 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... |