# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
26193 | 2017-06-28T10:04:40 Z | Extazy | Boat (APIO16_boat) | C++14 | 2000 ms | 7480 KB |
#include <bits/stdc++.h> using namespace std; const int N = 517; const int MOD = (1e9) + 7; int n,a[N],b[N]; unordered_map < int, int > state[N]; int recurse(int pos, int last) { if(pos>n) { return ((last!=0) ? 1 : 0); } if(state[pos].find(last)!=state[pos].end()) { return state[pos][last]; } long long ans=recurse(pos+1,last),i; for(i=max(last+1,a[pos]);i<=b[pos];i++) { ans+=recurse(pos+1,i); } ans%=MOD; state[pos][last]=ans; return ans; } int main() { int i; scanf("%d", &n); for(i=1;i<=n;i++) { scanf("%d %d", &a[i], &b[i]); } printf("%d\n", recurse(1,0)); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 33 ms | 7480 KB | Output is correct |
2 | Correct | 39 ms | 7480 KB | Output is correct |
3 | Correct | 36 ms | 7480 KB | Output is correct |
4 | Correct | 26 ms | 7480 KB | Output is correct |
5 | Correct | 39 ms | 7480 KB | Output is correct |
6 | Correct | 39 ms | 7480 KB | Output is correct |
7 | Correct | 36 ms | 7480 KB | Output is correct |
8 | Correct | 26 ms | 7480 KB | Output is correct |
9 | Correct | 36 ms | 7480 KB | Output is correct |
10 | Correct | 39 ms | 7480 KB | Output is correct |
11 | Correct | 36 ms | 7480 KB | Output is correct |
12 | Correct | 39 ms | 7480 KB | Output is correct |
13 | Correct | 36 ms | 7480 KB | Output is correct |
14 | Correct | 46 ms | 7480 KB | Output is correct |
15 | Correct | 39 ms | 7480 KB | Output is correct |
16 | Correct | 9 ms | 3508 KB | Output is correct |
17 | Correct | 9 ms | 3640 KB | Output is correct |
18 | Correct | 9 ms | 3640 KB | Output is correct |
19 | Correct | 9 ms | 3640 KB | Output is correct |
20 | Correct | 3 ms | 3508 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 33 ms | 7480 KB | Output is correct |
2 | Correct | 39 ms | 7480 KB | Output is correct |
3 | Correct | 36 ms | 7480 KB | Output is correct |
4 | Correct | 26 ms | 7480 KB | Output is correct |
5 | Correct | 39 ms | 7480 KB | Output is correct |
6 | Correct | 39 ms | 7480 KB | Output is correct |
7 | Correct | 36 ms | 7480 KB | Output is correct |
8 | Correct | 26 ms | 7480 KB | Output is correct |
9 | Correct | 36 ms | 7480 KB | Output is correct |
10 | Correct | 39 ms | 7480 KB | Output is correct |
11 | Correct | 36 ms | 7480 KB | Output is correct |
12 | Correct | 39 ms | 7480 KB | Output is correct |
13 | Correct | 36 ms | 7480 KB | Output is correct |
14 | Correct | 46 ms | 7480 KB | Output is correct |
15 | Correct | 39 ms | 7480 KB | Output is correct |
16 | Correct | 9 ms | 3508 KB | Output is correct |
17 | Correct | 9 ms | 3640 KB | Output is correct |
18 | Correct | 9 ms | 3640 KB | Output is correct |
19 | Correct | 9 ms | 3640 KB | Output is correct |
20 | Correct | 3 ms | 3508 KB | Output is correct |
21 | Execution timed out | 2000 ms | 6112 KB | Execution timed out |
22 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2000 ms | 2056 KB | Execution timed out |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 33 ms | 7480 KB | Output is correct |
2 | Correct | 39 ms | 7480 KB | Output is correct |
3 | Correct | 36 ms | 7480 KB | Output is correct |
4 | Correct | 26 ms | 7480 KB | Output is correct |
5 | Correct | 39 ms | 7480 KB | Output is correct |
6 | Correct | 39 ms | 7480 KB | Output is correct |
7 | Correct | 36 ms | 7480 KB | Output is correct |
8 | Correct | 26 ms | 7480 KB | Output is correct |
9 | Correct | 36 ms | 7480 KB | Output is correct |
10 | Correct | 39 ms | 7480 KB | Output is correct |
11 | Correct | 36 ms | 7480 KB | Output is correct |
12 | Correct | 39 ms | 7480 KB | Output is correct |
13 | Correct | 36 ms | 7480 KB | Output is correct |
14 | Correct | 46 ms | 7480 KB | Output is correct |
15 | Correct | 39 ms | 7480 KB | Output is correct |
16 | Correct | 9 ms | 3508 KB | Output is correct |
17 | Correct | 9 ms | 3640 KB | Output is correct |
18 | Correct | 9 ms | 3640 KB | Output is correct |
19 | Correct | 9 ms | 3640 KB | Output is correct |
20 | Correct | 3 ms | 3508 KB | Output is correct |
21 | Execution timed out | 2000 ms | 6112 KB | Execution timed out |
22 | Halted | 0 ms | 0 KB | - |