Submission #501356

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
5013562022-01-02 21:22:53Abrar_Al_SamitBoat (APIO16_boat)C++17
9 / 100
2077 ms8240 KiB
#include<bits/stdc++.h>
using namespace std;
const int MX = 505;
const int Mod = 1e9 + 7;
int a[MX], b[MX];
map<pair<int,int>,int>dp;
int n;
int solve(int i, int prev) {
if(i>n) return (prev!=0);
if(dp.count(make_pair(i, prev))) return dp[make_pair(i, prev)];
int ret = 0;
ret = solve(i+1, prev);
for(int cur=max(a[i], prev+1); cur<=b[i]; ++cur) {
ret += solve(i+1, cur);
if(ret>=Mod) ret -= Mod;
}
return dp[make_pair(i, prev)] = ret;
}
void PlayGround() {
cin >> n;
for(int i=1; i<=n; ++i) {
cin >> a[i] >> b[i];
}
cout << solve(1, 0) << endl;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
PlayGround();
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...