이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
using namespace std;
struct ppl {
ll h,o; //house, office
};
ll n,m,k,x,y,z;
vector<ll> median;
vector<ppl> city;
char st, ed;
void sub1() {
ll ans = 0;
for (int i = 1; i <= n; i++) {
cin >> st >> x >> ed >> y;
if (st == ed) ans += abs(x-y);
else {
median.push_back(x);
median.push_back(y);
city.push_back({x,y});
}
}
sort(median.begin(),median.end());
ll bridge = median[median.size()/2];
for (auto i : city) ans += abs(i.h-bridge) + abs(i.o-bridge) + 1;
cout << ans << "\n";
}
void sub2() {
cout << "oh no :(";
}
signed main() {
cin >> m >> n;
if (m == 1) sub1();
else sub2();
}
# | 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... |