Submission #123945

#TimeUsernameProblemLanguageResultExecution timeMemory
123945RafikHachanaBoat (APIO16_boat)C++14
9 / 100
2064 ms8388 KiB
#include<bits/stdc++.h> using namespace std; #define mod (int)(1e9+7) 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)%mod; for(int j=max(val,a[i]);j<=b[i];j++) r+=(dp(i+1,j+1))%mod; return m[{i,val}] = r%mod; } 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)%mod<<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...