제출 #756889

#제출 시각아이디문제언어결과실행 시간메모리
756889Rafi22전선 연결 (IOI17_wiring)C++14
10 / 100
383 ms218292 KiB
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define st first #define nd second #define pb push_back #define sz(x) (int)(x).size() #define all(x) (x).begin(), (x).end() #define ll long long ll mod=1000000007; int inf=1000000007; ll infl=1000000000000000007; const int N=200007; ll DP[N][(1<<7)+7]; ll min_total_length(vector<int>r,vector<int>b) { vector<pair<ll,int>>V; int n=sz(r),m=sz(b); for(int i=0;i<n;i++) V.pb({r[i],1}); for(int i=0;i<m;i++) V.pb({b[i],2}); sort(all(V)); for(int i=0;i<n+m;i++) { for(int j=0;j<(1<<7);j++) DP[i+1][j]=infl; for(int j=1;j<(1<<7);j+=2) DP[i+1][j/2]=DP[i][j]; for(int j=0;j<(1<<7);j++) { for(int l=0;l<6;l++) { if(i-6+l>=0&&V[i].nd!=V[i-6+l].nd) { DP[i+1][j|(1<<l)|(1<<6)]=min(DP[i+1][j|(1<<l)|(1<<6)],DP[i+1][j]+V[i].st-V[i-6+l].st); } } } } return DP[n+m][(1<<7)-1]; } /* int main() { cout<<min_total_length({1, 2, 3, 7},{0, 4, 5, 9, 10})<<endl; 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...