# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
23584 |
2017-05-12T17:45:02 Z |
repeating |
Boat (APIO16_boat) |
C++11 |
|
2000 ms |
524288 KB |
#include <bits/stdc++.h>
#define F first
#define S second
#define P push
#define pb push_back
#define MEM(dp,i) memset(dp,i,sizeof(dp))
#define W while
#define R return
#define C continue
#define SI size()
#define ll long long
#define pll pair<ll,ll>
#define SF(x) scanf("%I64d",&x)
using namespace std;
const long long INF = 2e9;
long long MOD = 1e9+7;
ll n;
ll a[555];
ll b[555];
vector<ll> dp[555];
ll DP(ll x,ll last){
if(x==n)R 1;
if(last>b[x])R DP(x+1,last);
ll p=DP(x+1,last);
last=max(last,a[x]);
ll &ret=dp[x][last-a[x]];
if(ret!=-1)R ret+p;
ret=0;
if(last<=b[x])
ret=DP(x,last+1);
ret%=MOD;
R ret+p;
}
int main(){
cin>>n;
for(int i=0;i<n;i++){
cin>>a[i]>>b[i];
for(int j=a[i];j<=b[i];j++)
dp[i].pb(-1);
}
cout<<(DP(0,1)-1)%MOD;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2040 KB |
Output is correct |
2 |
Correct |
0 ms |
2040 KB |
Output is correct |
3 |
Correct |
0 ms |
2040 KB |
Output is correct |
4 |
Correct |
0 ms |
2040 KB |
Output is correct |
5 |
Correct |
0 ms |
2040 KB |
Output is correct |
6 |
Correct |
0 ms |
2040 KB |
Output is correct |
7 |
Correct |
0 ms |
2040 KB |
Output is correct |
8 |
Correct |
0 ms |
2040 KB |
Output is correct |
9 |
Correct |
0 ms |
2040 KB |
Output is correct |
10 |
Correct |
0 ms |
2040 KB |
Output is correct |
11 |
Correct |
0 ms |
2040 KB |
Output is correct |
12 |
Correct |
0 ms |
2040 KB |
Output is correct |
13 |
Correct |
0 ms |
2040 KB |
Output is correct |
14 |
Correct |
0 ms |
2040 KB |
Output is correct |
15 |
Correct |
0 ms |
2040 KB |
Output is correct |
16 |
Correct |
0 ms |
2040 KB |
Output is correct |
17 |
Correct |
0 ms |
2040 KB |
Output is correct |
18 |
Correct |
0 ms |
2040 KB |
Output is correct |
19 |
Correct |
0 ms |
2040 KB |
Output is correct |
20 |
Correct |
0 ms |
2040 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2040 KB |
Output is correct |
2 |
Correct |
0 ms |
2040 KB |
Output is correct |
3 |
Correct |
0 ms |
2040 KB |
Output is correct |
4 |
Correct |
0 ms |
2040 KB |
Output is correct |
5 |
Correct |
0 ms |
2040 KB |
Output is correct |
6 |
Correct |
0 ms |
2040 KB |
Output is correct |
7 |
Correct |
0 ms |
2040 KB |
Output is correct |
8 |
Correct |
0 ms |
2040 KB |
Output is correct |
9 |
Correct |
0 ms |
2040 KB |
Output is correct |
10 |
Correct |
0 ms |
2040 KB |
Output is correct |
11 |
Correct |
0 ms |
2040 KB |
Output is correct |
12 |
Correct |
0 ms |
2040 KB |
Output is correct |
13 |
Correct |
0 ms |
2040 KB |
Output is correct |
14 |
Correct |
0 ms |
2040 KB |
Output is correct |
15 |
Correct |
0 ms |
2040 KB |
Output is correct |
16 |
Correct |
0 ms |
2040 KB |
Output is correct |
17 |
Correct |
0 ms |
2040 KB |
Output is correct |
18 |
Correct |
0 ms |
2040 KB |
Output is correct |
19 |
Correct |
0 ms |
2040 KB |
Output is correct |
20 |
Correct |
0 ms |
2040 KB |
Output is correct |
21 |
Correct |
1083 ms |
12248 KB |
Output is correct |
22 |
Correct |
1163 ms |
12076 KB |
Output is correct |
23 |
Correct |
1073 ms |
11556 KB |
Output is correct |
24 |
Correct |
1533 ms |
12664 KB |
Output is correct |
25 |
Correct |
1113 ms |
12492 KB |
Output is correct |
26 |
Correct |
1863 ms |
10076 KB |
Output is correct |
27 |
Execution timed out |
2000 ms |
10076 KB |
Execution timed out |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Memory limit exceeded |
173 ms |
524288 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2040 KB |
Output is correct |
2 |
Correct |
0 ms |
2040 KB |
Output is correct |
3 |
Correct |
0 ms |
2040 KB |
Output is correct |
4 |
Correct |
0 ms |
2040 KB |
Output is correct |
5 |
Correct |
0 ms |
2040 KB |
Output is correct |
6 |
Correct |
0 ms |
2040 KB |
Output is correct |
7 |
Correct |
0 ms |
2040 KB |
Output is correct |
8 |
Correct |
0 ms |
2040 KB |
Output is correct |
9 |
Correct |
0 ms |
2040 KB |
Output is correct |
10 |
Correct |
0 ms |
2040 KB |
Output is correct |
11 |
Correct |
0 ms |
2040 KB |
Output is correct |
12 |
Correct |
0 ms |
2040 KB |
Output is correct |
13 |
Correct |
0 ms |
2040 KB |
Output is correct |
14 |
Correct |
0 ms |
2040 KB |
Output is correct |
15 |
Correct |
0 ms |
2040 KB |
Output is correct |
16 |
Correct |
0 ms |
2040 KB |
Output is correct |
17 |
Correct |
0 ms |
2040 KB |
Output is correct |
18 |
Correct |
0 ms |
2040 KB |
Output is correct |
19 |
Correct |
0 ms |
2040 KB |
Output is correct |
20 |
Correct |
0 ms |
2040 KB |
Output is correct |
21 |
Correct |
1083 ms |
12248 KB |
Output is correct |
22 |
Correct |
1163 ms |
12076 KB |
Output is correct |
23 |
Correct |
1073 ms |
11556 KB |
Output is correct |
24 |
Correct |
1533 ms |
12664 KB |
Output is correct |
25 |
Correct |
1113 ms |
12492 KB |
Output is correct |
26 |
Correct |
1863 ms |
10076 KB |
Output is correct |
27 |
Execution timed out |
2000 ms |
10076 KB |
Execution timed out |
28 |
Halted |
0 ms |
0 KB |
- |