이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pp=pair<int,int>;
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)((x).size()))
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rrep(i,n) for(int i=1; i<=(n); ++i)
#define x first
#define y second
ll min_total_length(vector<int> vr, vector<int> vb) {
vector<pp> a;
for(int x:vr) a.eb(x, 0);
for(int x:vb) a.eb(x, 1);
sort(all(a));
int n = sz(a);
int rc = sz(vr), bc = sz(vb);
ll ans = 0;
if (rc > bc) {
int df = rc-bc;
rep(i, df) ans += vb[0]-vr[i];
rep(i, bc) ans += vb[i]-vr[df+i];
} else {
int df = bc-rc;
rep(i, rc) ans += vb[i]-vr[i];
rep(i, df) ans += vb[rc+i]-vr[rc-1];
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
wiring.cpp: In function 'll min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:19:6: warning: unused variable 'n' [-Wunused-variable]
int n = sz(a);
^
# | 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... |