Submission #433830

#TimeUsernameProblemLanguageResultExecution timeMemory
433830oscar1fBoat (APIO16_boat)C++17
9 / 100
2089 ms524292 KiB
#include<bits/stdc++.h> using namespace std; const int MAX_ECOLE=501,INFINI=1000*1000*1000+7; int nbEcole; unordered_map<long long,int> memo; int mini[MAX_ECOLE],maxi[MAX_ECOLE]; int dyna(int idEcole,int maxMaint) { if (idEcole==nbEcole+1) { return 1; } int val=memo[(long long)idEcole*(long long)INFINI+(long long)maxMaint]; if (val!=0) { return val; } val=dyna(idEcole+1,maxMaint); if (maxMaint<maxi[idEcole]) { if (maxMaint<mini[idEcole]) { val+=dyna(idEcole,mini[idEcole]); val%=INFINI; } else { val+=dyna(idEcole,maxMaint+1); val%=INFINI; } } memo[(long long)idEcole*(long long)INFINI+(long long)maxMaint]=val; return val; } int main() { ios_base::sync_with_stdio(false); cin>>nbEcole; for (int i=1;i<=nbEcole;i++) { cin>>mini[i]>>maxi[i]; } cout<<(dyna(1,-1)+INFINI-1)%INFINI<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...