# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
39813 | 2018-01-19T11:40:43 Z | 14kg | Boat (APIO16_boat) | C++11 | 8 ms | 9172 KB |
#include <stdio.h> #include <set> #include <algorithm> #include <map> #define N 501 #define INF 1000000000 #define MOD 1000000007 using namespace std; int n, r_len; long long dp[N][N * 4]; pair<int, int> in[N], r[N * 4]; set<int> S; map<int, int> M; void r_push(int x, int y) { if (x > y) return; r[++r_len] = { x,y }; if (x == y) M[x] = r_len; } int main() { int path = INF; long long sum; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d %d", &in[i].first, &in[i].second); S.insert(in[i].first), S.insert(in[i].second); } for (auto i : S) r_push(path + 1, i - 1), r_push(i, i), path = i; for (int i = 1; i <= n; i++) in[i] = { M[in[i].first],M[in[i].second] }; dp[0][0] = 1; for (int i = 1; i <= n; i++) { sum = dp[i][0] = 1; for (int j = 1; j <= r_len; j++) { dp[i][j] = dp[i - 1][j]; if (in[i].first <= j && j <= in[i].second) { dp[i][j] += sum * (long long)(r[j].second - r[j].first + 1); dp[i][j] %= MOD; } sum = (sum + dp[i - 1][j]) % MOD; } } sum = 0; for (int i = 1; i <= r_len; i++) sum = (sum + dp[n][i]) % MOD; printf("%lld", sum); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 9040 KB | Output is correct |
2 | Correct | 7 ms | 9040 KB | Output is correct |
3 | Correct | 0 ms | 9040 KB | Output is correct |
4 | Correct | 8 ms | 9040 KB | Output is correct |
5 | Correct | 7 ms | 9040 KB | Output is correct |
6 | Correct | 0 ms | 9040 KB | Output is correct |
7 | Correct | 0 ms | 9040 KB | Output is correct |
8 | Correct | 3 ms | 9040 KB | Output is correct |
9 | Correct | 7 ms | 9040 KB | Output is correct |
10 | Correct | 0 ms | 9040 KB | Output is correct |
11 | Correct | 3 ms | 9040 KB | Output is correct |
12 | Correct | 3 ms | 9040 KB | Output is correct |
13 | Correct | 0 ms | 9040 KB | Output is correct |
14 | Correct | 4 ms | 9040 KB | Output is correct |
15 | Correct | 0 ms | 9040 KB | Output is correct |
16 | Correct | 2 ms | 9040 KB | Output is correct |
17 | Correct | 2 ms | 9040 KB | Output is correct |
18 | Correct | 1 ms | 9040 KB | Output is correct |
19 | Correct | 3 ms | 9040 KB | Output is correct |
20 | Correct | 2 ms | 9040 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 9040 KB | Output is correct |
2 | Correct | 7 ms | 9040 KB | Output is correct |
3 | Correct | 0 ms | 9040 KB | Output is correct |
4 | Correct | 8 ms | 9040 KB | Output is correct |
5 | Correct | 7 ms | 9040 KB | Output is correct |
6 | Correct | 0 ms | 9040 KB | Output is correct |
7 | Correct | 0 ms | 9040 KB | Output is correct |
8 | Correct | 3 ms | 9040 KB | Output is correct |
9 | Correct | 7 ms | 9040 KB | Output is correct |
10 | Correct | 0 ms | 9040 KB | Output is correct |
11 | Correct | 3 ms | 9040 KB | Output is correct |
12 | Correct | 3 ms | 9040 KB | Output is correct |
13 | Correct | 0 ms | 9040 KB | Output is correct |
14 | Correct | 4 ms | 9040 KB | Output is correct |
15 | Correct | 0 ms | 9040 KB | Output is correct |
16 | Correct | 2 ms | 9040 KB | Output is correct |
17 | Correct | 2 ms | 9040 KB | Output is correct |
18 | Correct | 1 ms | 9040 KB | Output is correct |
19 | Correct | 3 ms | 9040 KB | Output is correct |
20 | Correct | 2 ms | 9040 KB | Output is correct |
21 | Incorrect | 5 ms | 9172 KB | Output isn't correct |
22 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 9040 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 9040 KB | Output is correct |
2 | Correct | 7 ms | 9040 KB | Output is correct |
3 | Correct | 0 ms | 9040 KB | Output is correct |
4 | Correct | 8 ms | 9040 KB | Output is correct |
5 | Correct | 7 ms | 9040 KB | Output is correct |
6 | Correct | 0 ms | 9040 KB | Output is correct |
7 | Correct | 0 ms | 9040 KB | Output is correct |
8 | Correct | 3 ms | 9040 KB | Output is correct |
9 | Correct | 7 ms | 9040 KB | Output is correct |
10 | Correct | 0 ms | 9040 KB | Output is correct |
11 | Correct | 3 ms | 9040 KB | Output is correct |
12 | Correct | 3 ms | 9040 KB | Output is correct |
13 | Correct | 0 ms | 9040 KB | Output is correct |
14 | Correct | 4 ms | 9040 KB | Output is correct |
15 | Correct | 0 ms | 9040 KB | Output is correct |
16 | Correct | 2 ms | 9040 KB | Output is correct |
17 | Correct | 2 ms | 9040 KB | Output is correct |
18 | Correct | 1 ms | 9040 KB | Output is correct |
19 | Correct | 3 ms | 9040 KB | Output is correct |
20 | Correct | 2 ms | 9040 KB | Output is correct |
21 | Incorrect | 5 ms | 9172 KB | Output isn't correct |
22 | Halted | 0 ms | 0 KB | - |