# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
108811 | 2019-05-02T08:18:36 Z | antimirage | Two Dishes (JOI19_dishes) | C++14 | 53 ms | 32000 KB |
/** Elohim Essaim, Elohim Essaim I implore you... **/ #include <bits/stdc++.h> #define fr first #define sc second #define mk make_pair #define pb push_back #define all(s) s.begin(), s.end() using namespace std; const int N = 2e3 + 5; int n, m, a[N], b[N], p[N], q[N]; long long dp[N][N], pr1[N], pr2[N], s[N], t[N]; main(){ cin >> n >> m; for (int i = 1; i <= n; i++){ scanf("%d%lld%d", &a[i], &s[i], &p[i]); pr1[i] = pr1[i - 1] + a[i]; } for (int i = 1; i <= m; i++){ scanf("%d%lld%d", &b[i], &t[i], &q[i]); pr2[i] = pr2[i - 1] + b[i]; } memset(dp, -0x3f3f3f3f, sizeof(dp) ); dp[0][0] = 0; for (int i = 0; i <= n; i++) { for (int j = 0; j <= m; j++) { if (i + 1 <= n){ if (pr1[i + 1] + pr2[j] <= s[i + 1]) dp[i + 1][j] = max( dp[i + 1][j], dp[i][j] + p[i + 1] ); else dp[i + 1][j] = max( dp[i + 1][j], dp[i][j] ); } if (j + 1 <= m){ if (pr1[i] + pr2[j + 1] <= t[j + 1]) dp[i][j + 1] = max( dp[i][j + 1], dp[i][j] + q[j + 1] ); else dp[i][j + 1] = max( dp[i][j + 1], dp[i][j] ); } } } cout << dp[n][m] << endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 5 ms | 384 KB | Time limit exceeded (wall clock) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 31 ms | 31800 KB | Output is correct |
2 | Correct | 29 ms | 31812 KB | Output is correct |
3 | Correct | 32 ms | 31872 KB | Output is correct |
4 | Correct | 34 ms | 31864 KB | Output is correct |
5 | Correct | 33 ms | 31864 KB | Output is correct |
6 | Correct | 28 ms | 31864 KB | Output is correct |
7 | Correct | 26 ms | 31860 KB | Output is correct |
8 | Correct | 29 ms | 31864 KB | Output is correct |
9 | Correct | 28 ms | 31840 KB | Output is correct |
10 | Correct | 32 ms | 31872 KB | Output is correct |
11 | Correct | 27 ms | 31872 KB | Output is correct |
12 | Correct | 30 ms | 31836 KB | Output is correct |
13 | Correct | 29 ms | 31868 KB | Output is correct |
14 | Correct | 32 ms | 31864 KB | Output is correct |
15 | Correct | 34 ms | 31864 KB | Output is correct |
16 | Correct | 26 ms | 31872 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 31 ms | 31800 KB | Output is correct |
2 | Correct | 29 ms | 31812 KB | Output is correct |
3 | Correct | 32 ms | 31872 KB | Output is correct |
4 | Correct | 34 ms | 31864 KB | Output is correct |
5 | Correct | 33 ms | 31864 KB | Output is correct |
6 | Correct | 28 ms | 31864 KB | Output is correct |
7 | Correct | 26 ms | 31860 KB | Output is correct |
8 | Correct | 29 ms | 31864 KB | Output is correct |
9 | Correct | 28 ms | 31840 KB | Output is correct |
10 | Correct | 32 ms | 31872 KB | Output is correct |
11 | Correct | 27 ms | 31872 KB | Output is correct |
12 | Correct | 30 ms | 31836 KB | Output is correct |
13 | Correct | 29 ms | 31868 KB | Output is correct |
14 | Correct | 32 ms | 31864 KB | Output is correct |
15 | Correct | 34 ms | 31864 KB | Output is correct |
16 | Correct | 26 ms | 31872 KB | Output is correct |
17 | Correct | 53 ms | 31996 KB | Output is correct |
18 | Correct | 42 ms | 31992 KB | Output is correct |
19 | Correct | 51 ms | 31992 KB | Output is correct |
20 | Correct | 45 ms | 31992 KB | Output is correct |
21 | Correct | 46 ms | 31996 KB | Output is correct |
22 | Correct | 48 ms | 31864 KB | Output is correct |
23 | Correct | 47 ms | 32000 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 31 ms | 31800 KB | Output is correct |
2 | Correct | 29 ms | 31812 KB | Output is correct |
3 | Correct | 32 ms | 31872 KB | Output is correct |
4 | Correct | 34 ms | 31864 KB | Output is correct |
5 | Correct | 33 ms | 31864 KB | Output is correct |
6 | Correct | 28 ms | 31864 KB | Output is correct |
7 | Correct | 26 ms | 31860 KB | Output is correct |
8 | Correct | 29 ms | 31864 KB | Output is correct |
9 | Correct | 28 ms | 31840 KB | Output is correct |
10 | Correct | 32 ms | 31872 KB | Output is correct |
11 | Correct | 27 ms | 31872 KB | Output is correct |
12 | Correct | 30 ms | 31836 KB | Output is correct |
13 | Correct | 29 ms | 31868 KB | Output is correct |
14 | Correct | 32 ms | 31864 KB | Output is correct |
15 | Correct | 34 ms | 31864 KB | Output is correct |
16 | Correct | 26 ms | 31872 KB | Output is correct |
17 | Correct | 53 ms | 31996 KB | Output is correct |
18 | Correct | 42 ms | 31992 KB | Output is correct |
19 | Correct | 51 ms | 31992 KB | Output is correct |
20 | Correct | 45 ms | 31992 KB | Output is correct |
21 | Correct | 46 ms | 31996 KB | Output is correct |
22 | Correct | 48 ms | 31864 KB | Output is correct |
23 | Correct | 47 ms | 32000 KB | Output is correct |
24 | Execution timed out | 7 ms | 768 KB | Time limit exceeded (wall clock) |
25 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 31 ms | 31800 KB | Output is correct |
2 | Correct | 29 ms | 31812 KB | Output is correct |
3 | Correct | 32 ms | 31872 KB | Output is correct |
4 | Correct | 34 ms | 31864 KB | Output is correct |
5 | Correct | 33 ms | 31864 KB | Output is correct |
6 | Correct | 28 ms | 31864 KB | Output is correct |
7 | Correct | 26 ms | 31860 KB | Output is correct |
8 | Correct | 29 ms | 31864 KB | Output is correct |
9 | Correct | 28 ms | 31840 KB | Output is correct |
10 | Correct | 32 ms | 31872 KB | Output is correct |
11 | Correct | 27 ms | 31872 KB | Output is correct |
12 | Correct | 30 ms | 31836 KB | Output is correct |
13 | Correct | 29 ms | 31868 KB | Output is correct |
14 | Correct | 32 ms | 31864 KB | Output is correct |
15 | Correct | 34 ms | 31864 KB | Output is correct |
16 | Correct | 26 ms | 31872 KB | Output is correct |
17 | Correct | 53 ms | 31996 KB | Output is correct |
18 | Correct | 42 ms | 31992 KB | Output is correct |
19 | Correct | 51 ms | 31992 KB | Output is correct |
20 | Correct | 45 ms | 31992 KB | Output is correct |
21 | Correct | 46 ms | 31996 KB | Output is correct |
22 | Correct | 48 ms | 31864 KB | Output is correct |
23 | Correct | 47 ms | 32000 KB | Output is correct |
24 | Execution timed out | 7 ms | 768 KB | Time limit exceeded (wall clock) |
25 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 31 ms | 31800 KB | Output is correct |
2 | Correct | 29 ms | 31812 KB | Output is correct |
3 | Correct | 32 ms | 31872 KB | Output is correct |
4 | Correct | 34 ms | 31864 KB | Output is correct |
5 | Correct | 33 ms | 31864 KB | Output is correct |
6 | Correct | 28 ms | 31864 KB | Output is correct |
7 | Correct | 26 ms | 31860 KB | Output is correct |
8 | Correct | 29 ms | 31864 KB | Output is correct |
9 | Correct | 28 ms | 31840 KB | Output is correct |
10 | Correct | 32 ms | 31872 KB | Output is correct |
11 | Correct | 27 ms | 31872 KB | Output is correct |
12 | Correct | 30 ms | 31836 KB | Output is correct |
13 | Correct | 29 ms | 31868 KB | Output is correct |
14 | Correct | 32 ms | 31864 KB | Output is correct |
15 | Correct | 34 ms | 31864 KB | Output is correct |
16 | Correct | 26 ms | 31872 KB | Output is correct |
17 | Correct | 53 ms | 31996 KB | Output is correct |
18 | Correct | 42 ms | 31992 KB | Output is correct |
19 | Correct | 51 ms | 31992 KB | Output is correct |
20 | Correct | 45 ms | 31992 KB | Output is correct |
21 | Correct | 46 ms | 31996 KB | Output is correct |
22 | Correct | 48 ms | 31864 KB | Output is correct |
23 | Correct | 47 ms | 32000 KB | Output is correct |
24 | Execution timed out | 7 ms | 768 KB | Time limit exceeded (wall clock) |
25 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 5 ms | 384 KB | Time limit exceeded (wall clock) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 5 ms | 384 KB | Time limit exceeded (wall clock) |
2 | Halted | 0 ms | 0 KB | - |