Submission #755533

#TimeUsernameProblemLanguageResultExecution timeMemory
755533PanosPaskWiring (IOI17_wiring)C++14
0 / 100
1 ms300 KiB
#include "wiring.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; int n, m; long long min_total_length(std::vector<int> r, std::vector<int> b) { n = r.size(); m = b.size(); if (r.back() < b.front()) { ll ans = 0; int rfocal = r.back(); int bfocal = b.front(); int i = 0; while (i < n && i < m) { int rpoint = r[n - 1 - i]; int bpoint = b[i]; if (abs(rpoint - bpoint) < abs(rpoint - bfocal) + abs(bpoint - rfocal)) { ans += abs(rpoint - bpoint); i++; } else break; } for (int cur = i; cur < n; cur++) ans += abs(r[n - 1 - i] - bfocal); for (int cur = i; cur < m; cur++) ans += abs(b[i] - rfocal); return ans; } return -1; }
#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...