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 ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 100100;
ll s[maxn], f[maxn], n, k;
char szone[maxn], fzone[maxn];
int main() {
cin>>k>>n;
ll result = 0LL;
vector<ll>v;
vector<pair<ll,ll> > vv;
for(int i=1;i<=n;i++) {
cin>>szone[i]>>s[i];
cin>>fzone[i]>>f[i];
if(szone[i] == fzone[i]) result += abs(f[i] - s[i]);
if(szone[i] != fzone[i]) {
v.pb(s[i]);
v.pb(f[i]);
}
vv.pb(mp(min(s[i], f[i]), max(s[i], f[i])));
}
if(v.size() == 0) {
cout<<result;
return 0;
}
if(k == 1) {
ll mintemp = LLONG_MAX;
sort(v.begin(), v.end());
// 0 1 2 3
int half = v[0];
if(v.size() > 1)
half = v[v.size()/2-1];
else half = v.back();
for(int d=half-1;d<=half+1;d++) {
ll temp = 0LL;
for(int i=1;i<=n;i++) {
if(szone[i] != fzone[i]) {
temp += abs(f[i] - d) + abs(s[i] - d) + 1;
}
}
//cout<<d<<": "<<temp<<"\n";
mintemp = min(mintemp, temp);
}
result += mintemp;
cout<<result<<"\n";
return 0;
}
else if(k == 2) {
for(int i:v) {
}
}
return 0;
}
Compilation message (stderr)
bridge.cpp: In function 'int main()':
bridge.cpp:58:17: warning: unused variable 'i' [-Wunused-variable]
for(int i:v) {
^
# | 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... |