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 int long long
#define iris 998244353
using namespace std;
vector<int> ouo;
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
int i,k,n,x,y,sum;
char a,b;
cin>>k>>n;
sum=0;
for(i=0;i<n;i++)
{
cin>>a>>x>>b>>y;
if(a==b)
{
sum+=abs(x-y);
}
else
{
sum++;
ouo.emplace_back(x);
ouo.emplace_back(y);
}
}
sort(ouo.begin(),ouo.end());
if(ouo.size())
x=ouo[ouo.size()/2];
for(int aoi:ouo)
{
sum+=abs(aoi-x);
}
cout<<sum<<'\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... |