제출 #256611

#제출 시각아이디문제언어결과실행 시간메모리
256611Plasmatic전선 연결 (IOI17_wiring)C++11
13 / 100
43 ms4344 KiB
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; long long min_total_length(std::vector<int> r, std::vector<int> b) { if (r.size() > b.size()) r.swap(b); long long res = 0; for (int i = 0; i < (int)r.size(); i++) res += abs(r[i] - b[i]); int sz = r.size(); r.insert(r.begin(), -INF); r.push_back(INF); for (int i = sz; i < (int)b.size(); i++) { auto nx = lower_bound(r.begin(), r.end(), b[i]), pr = nx - 1; int mn = INT_MAX; if (*nx != INF) mn = min(mn, *nx - b[i]); if (*pr != -INF) mn = min(mn, b[i] - *pr); res += mn; } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...