# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1158708 | emptypringlescan | Wiring (IOI17_wiring) | C++20 | 1096 ms | 7608 KiB |
#include <bits/stdc++.h>
#include "wiring.h"
using namespace std;
vector<pair<long long,int> > arr;
long long cost(int l, int r){
long long ret=0;
if(arr[l].second==arr[r].second) return 1e16;
int c1=l,c2=r;
long long v1=0,v2=0;
while(arr[c1].second==arr[l].second||arr[c2].second==arr[r].second){
if(arr[c1].second!=arr[l].second) ret+=arr[c2].first-v1;
else if(arr[c2].second!=arr[r].second) ret+=v2-arr[c1].first;
else{
ret+=arr[c2].first-arr[c1].first;
v1=arr[c1].first; v2=arr[c2].first;
}
c1++; c2--;
}
return ret;
}
long long min_total_length(vector<int> r, vector<int> b){
arr.push_back({-1,-1});
int c1=0,c2=0;
while(c1<(int)r.size()||c2<(int)b.size()){
if(c1==(int)r.size()){
arr.push_back({b[c2],1});
c2++;
}
else if(c2==(int)b.size()){
arr.push_back({r[c1],0});
# | 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... |