제출 #1070697

#제출 시각아이디문제언어결과실행 시간메모리
1070697oscar1f전선 연결 (IOI17_wiring)C++17
7 / 100
1069 ms262144 KiB
#include<bits/stdc++.h> #include "wiring.h" using namespace std; using ll=long long; const ll TAILLE_MAX=100*1000+5,INFINI=(ll)1000*1000*1000*1000*1000; ll nbRouge,nbBleu; vector<ll> posBleu,posRouge; unordered_map<ll,ll> memo; ll dyna(ll idRouge,ll idBleu) { if (idRouge==nbRouge and idBleu==nbBleu) { return 0; } if (idRouge==nbRouge or idBleu==nbBleu) { return INFINI; } ll caseTab=idRouge*TAILLE_MAX+idBleu; ll ans=memo[caseTab]; if (ans!=0) { return ans; } ans=abs(posRouge[idRouge]-posBleu[idBleu])+min(min(dyna(idRouge,idBleu+1),dyna(idRouge+1,idBleu)),dyna(idRouge+1,idBleu+1)); memo[caseTab]=ans; //cout<<idRouge<<" "<<idBleu<<" : "<<ans<<endl; return ans; } ll min_total_length(vector<int> r,vector<int> b) { nbRouge=r.size(); nbBleu=b.size(); for (auto i:r) { posRouge.push_back(i); } for (auto i:b) { posBleu.push_back(i); } return dyna(0,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...