Submission #836409

#TimeUsernameProblemLanguageResultExecution timeMemory
836409oscar1fRoller Coaster Railroad (IOI16_railroad)C++17
34 / 100
61 ms8760 KiB
#include<bits/stdc++.h> #include "railroad.h" using namespace std; using ll=long long; const ll MAX_TRANSFO=16,INFINI=(ll)1000*1000*1000*1000*1000*1000; ll nbTransfo; ll memo[(1<<MAX_TRANSFO)][MAX_TRANSFO]; ll seuil[MAX_TRANSFO],valNouv[MAX_TRANSFO]; ll dyna(ll etat,ll dernPris) { if (etat==(1<<nbTransfo)-1) { return 0; } if (memo[etat][dernPris]!=INFINI) { return memo[etat][dernPris]; } ll anci; if (etat==0) { anci=0; } else { anci=valNouv[dernPris]; } //cout<<etat<<" "<<dernPris<<" "<<anci<<endl; for (ll i=0;i<nbTransfo;i++) { if ((etat>>i)%2==0) { memo[etat][dernPris]=min(memo[etat][dernPris],dyna(etat+(1<<i),i)+max(anci-seuil[i],(ll)0)); } } return memo[etat][dernPris]; } ll plan_roller_coaster(vector<int> s,vector<int> t) { nbTransfo=s.size(); for (ll i=0;i<nbTransfo;i++) { seuil[i]=s[i]; valNouv[i]=t[i]; } for (int i=0;i<(1<<nbTransfo);i++) { for (int j=0;j<nbTransfo;j++) { memo[i][j]=INFINI; } } 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...