이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "wiring.h"
#include<bits/stdc++.h>
using namespace std;
long long min_total_length(vector<int> r, vector<int> b) {
    long long hi1=r.size(), hi2=b.size();
    long long d1=0, d2=0;
    vector<long long> vi;
    set<long long> si1, si2;
    set<long long, greater<long long> > si3, si4;
    for(long long i=0; i<hi1; i++)
        si1.insert(r[i]), si3.insert(r[i]);
    for(long long i=0; i<hi2; i++)
        si2.insert(b[i]), si4.insert(b[i]);
    while(d1<hi1 && d2<hi2){
        if(r[d1]<b[d2])
            vi.push_back(r[d1]), d1++;
        else
            vi.push_back(b[d2]), d2++;
    }
    while(d1<hi1)
        vi.push_back(r[d1]), d1++;
    while(d2<hi2)
        vi.push_back(b[d2]), d2++;
    long long tot=0;
    for(long long i=0; i<vi.size(); i++){
        if(si1.find(vi[i])!=si1.end()){
            long long yo=*si2.lower_bound(vi[i]);
            tot+=abs(yo-vi[i]);
            si2.erase(yo);
            si1.erase(vi[i]);
        }
        else if(si2.find(vi[i])!=si2.end()){
            long long yo=*si1.lower_bound(vi[i]);
            tot+=abs(yo-vi[i]);
            si2.erase(vi[i]);
            si1.erase(yo);
        }
        if(si1.empty() || si2.empty()){
            for(auto x:si1){
                long long yo1=*si2.lower_bound(x), yo2=*si4.lower_bound(x);
                tot+=min(abs(yo1-x), abs(yo2-x));
            }
            for(auto x:si2){
                long long yo1=*si1.lower_bound(x), yo2=*si3.lower_bound(x);
                tot+=min(abs(yo1-x), abs(yo2-x));
            }
            break;
        }
    }
	return tot;
}
컴파일 시 표준 에러 (stderr) 메시지
wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:25:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for(long long i=0; i<vi.size(); i++){
      |                        ~^~~~~~~~~~| # | 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... |