제출 #1090989

#제출 시각아이디문제언어결과실행 시간메모리
1090989elotelo966전선 연결 (IOI17_wiring)C++17
13 / 100
27 ms19548 KiB
#include <bits/stdc++.h> #include "wiring.h" using namespace std; #define OYY LLONG_MAX #define mod 1000000007 #define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define FOR for(int i=1;i<=n;i++) #define mid (start+end)/2 #define lim 2000005 #define fi first #define se second typedef long long lo; int a[lim],bt[lim]; long long min_total_length(std::vector<int> r, std::vector<int> b) { int n=r.size(); int m=b.size(); for(int i=0;i<n;i++)a[i+1]=r[i]; for(int i=0;i<m;i++)bt[i+1]=b[i]; if(n>m){ swap(n,m); swap(a,bt); } lo cev=0; FOR{ cev+=abs(a[i]-bt[i]); } int cur=1; for(int i=n+1;i<=m;i++){ while(cur<n && a[cur]<bt[i])cur++; int tut=abs(a[cur]-bt[i]); if(cur!=1)tut=min(tut,abs(a[cur-1]-bt[i])); cev+=tut; } return cev; }
#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...