# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
257895 | daniel920712 | Boat (APIO16_boat) | C++14 | 2086 ms | 8312 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <set>
#include <map>
using namespace std;
long long MOD=1e9+7;
map < pair < long long , long long > , long long > all;
long long N;
long long a[505],b[505];
long long F(long long x,long long y)
{
long long i;
//printf("%lld %lld\n",x,y);
if(x==0) return y!=1e9+5;
if(all.find(make_pair(x,y))!=all.end()) return all[make_pair(x,y)];
all[make_pair(x,y)]=F(x-1,y);
for(i=a[x];i<=min(b[x],y-1);i++)
{
all[make_pair(x,y)]+=F(x-1,i);
all[make_pair(x,y)]%=MOD;
}
//printf("%lld %lld %lld\n",x,y,all[make_pair(x,y)]);
return all[make_pair(x,y)];
}
int main()
{
long long N,M,i;
scanf("%lld",&N);
for(i=1;i<=N;i++) scanf("%lld %lld",&a[i],&b[i]);
printf("%lld\n",F(N,1e9+5));
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |