Submission #433808

#TimeUsernameProblemLanguageResultExecution timeMemory
433808oscar1fBoat (APIO16_boat)C++17
9 / 100
2069 ms8184 KiB
#include<bits/stdc++.h> using namespace std; const int MAX_ECOLE=501,INFINI=1000*1000*1000+7; int nbEcole; map<pair<int,int>,int> memo; int mini[MAX_ECOLE],maxi[MAX_ECOLE]; int dyna(int idEcole,int maxMaint) { if (idEcole==nbEcole+1) { return 1; } int val=memo[make_pair(idEcole,maxMaint)]; if (val!=0) { return val; } val=dyna(idEcole+1,maxMaint); for (int i=max(maxMaint+1,mini[idEcole]);i<=maxi[idEcole];i++) { val+=dyna(idEcole+1,i); val%=INFINI; } memo[make_pair(idEcole,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...