제출 #74064

#제출 시각아이디문제언어결과실행 시간메모리
74064renatsj전선 연결 (IOI17_wiring)C++14
0 / 100
3 ms652 KiB
#include<bits/stdc++.h> #include "wiring.h" using namespace std; long long i,j,k,a,n,m,cur,sk,l,ab[200005],rez; vector<long long> xx,mas; long long min_total_length(vector<int> r,vector<int> b) { n=r.size(); m=b.size(); i=0; j=0; sk=0; cur=-1; while (i<n&&j<m) { if (r[i]<b[j]) { if (cur==0) { sk++; } else { if (sk>0) { xx.push_back(sk); } sk=1; cur=0; } mas.push_back(r[i]); i++; } else { if (cur==1) { sk++; } else { if (sk>0) { xx.push_back(sk); } sk=1; cur=1; } mas.push_back(b[j]); j++; } } ab[0]=mas[0]; i=1; while (i<n+m) { ab[i]=ab[i-1]+mas[i]; i++; } j=0; a=0; k=1; l=xx[0]; i=xx[0]; while (i<n+m) { if (l>0) { rez+=mas[i]; rez-=mas[j]; j++; l--; } a++; if (a>=xx[k]) { if (l>0) { while (l>0) { rez+=mas[i-a+1]-mas[j]; j++; l--; } l=0; } else { j=i; } k++; } i++; } cout << rez; return 0; }
#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...