Submission #123940

#TimeUsernameProblemLanguageResultExecution timeMemory
123940RafikHachanaBoat (APIO16_boat)C++14
0 / 100
2040 ms8184 KiB
#include<bits/stdc++.h> using namespace std; int n; vector<int> a,b; map<pair<int,int>,int> m; int dp(int i,int val) { //cout<<val<<endl; if(i==n) return (int)(val!=-1); if(m.find({i,val})!=m.end()) return m[{i,val}]; int r = dp(i+1,val); for(int j=max(val,a[i]);j<=b[i];j++) r+=dp(i+1,j+1); return m[{i,val}] = r; } int main() { cin>>n; a.resize(n); b.resize(n); for(int i=0;i<n;i++) { cin>>a[i]>>b[i]; } cout<<dp(0,-1)<<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...