제출 #127086

#제출 시각아이디문제언어결과실행 시간메모리
127086chubyxdxd전선 연결 (IOI17_wiring)C++11
0 / 100
27 ms1656 KiB
#include "wiring.h" #include <bits/stdc++.h> using namespace std; long long min_total_length(std::vector<int> r, std::vector<int> b) { int tamr=r.size(); int tamb=b.size(); int c=0; if(r[tamr-1]<b[0]){ int i=0; int j=tamr-1; int k=j; int l=i; int sw=0; //int c=0; int a,d,e; while(sw<(min(tamr,tamb))){ a=abs(r[j]-b[i]); d=abs(r[j]-b[l]); e=abs(b[i]-r[k]); //cout<<a<<"<"<<d<<"+"<<e<<endl; c+=min(a,d+e); //cout<<c<<endl; i++; j--; sw++; } //cout<<j<<" "<<i<<endl; if(tamb<tamr){ //j++; for(int h=j;h>=0;h--){ c+=abs(r[h]-b[l]); } } else{ //i--; //cout<<tamb<<endl; for(int h=i;h<tamb;h++){ c+=abs(b[i]-r[k]); //cout<<r[h]<<"-"<<b[k]<<"="<<c<<endl; //cout<<c<<endl; } } //cout<<c<<endl; return c; } return c; }
#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...