이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define futaba ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rio return 0;
#define ll long long
#define fi first
#define se second
// Fun things are fun. //
int main() {
/* freopen(".txt", "r", stdin);
freopen(".txt", "w", stdout); */
futaba
ll k, n;
cin >> k >> n;
ll ans = 0;
if(k == 1) {
vector<ll> v;
vector<pair<ll, ll>> v2;
while(n--) {
char p;
cin >> p;
ll s;
cin >> s;
char q;
cin >> q;
ll t;
cin >> t;
if(p == q) ans += abs(s - t);
else {
v.push_back(abs(s - t) + 1);
v2.push_back({s, t});
}
}
sort(v.begin(), v.end());
ll x = v[(int)v.size() / 2];
for(auto i : v2) ans += (abs(i.fi - x) + abs(i.se - x)) + 1;
cout << ans << '\n';
}
rio
}
| # | 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... |