Submission #426073

#TimeUsernameProblemLanguageResultExecution timeMemory
426073ioiWiring (IOI17_wiring)C++14
13 / 100
31 ms3760 KiB
#include "wiring.h" #include<bits/stdc++.h> using namespace std ; long long min_total_length(std::vector<int> r, std::vector<int> b) { long long ret = 0 ; if(r.size() > b.size()){ int p = r.size() - 1 ; for(int i = b.size() - 1 ; i >= 0 ; i --) ret += b[i] - r[p--]; int R = r.size() , B = b.size(); for(int i = R - B - 1 ; i >= 0 ; i --) ret += b[0] - r[i]; } else { int p1 = r.size() , p2 = b.size() ; while(p1 > -1 && p2 > -1){ ret += b[p2] - r[p1]; p2 -- , p1 -- ; } long long sum = 0 ; while(p2 > -1){ sum += b[p2--]; } ret += (sum - (b.size() - r.size()) * r.back()) ; } return ret; }
#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...