# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
123286 | 2019-07-01T05:45:13 Z | 김세빈(#3018) | Two Dishes (JOI19_dishes) | C++14 | 55 ms | 32140 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll A[2020], S[2020], P[2020]; ll B[2020], T[2020], Q[2020]; ll D[2020][2020]; ll n, m; int main() { ll i, j; scanf("%lld%lld", &n, &m); for(i=1; i<=n; i++){ scanf("%lld%lld%lld", A + i, S + i, P + i); A[i] += A[i - 1]; } for(i=1; i<=m; i++){ scanf("%lld%lld%lld", B + i, T + i, Q + i); B[i] += B[i - 1]; } for(i=1; i<=n; i++){ S[i] = upper_bound(B, B + m + 1, S[i] - A[i]) - B; } for(i=1; i<=m; i++){ T[i] = upper_bound(A, A + n + 1, T[i] - B[i]) - A; } for(i=0; i<=n; i++){ for(j=0; j<=m; j++){ if(i || j) D[i][j] = -1e18; if(j) D[i][j] = max(D[i][j], D[i][j - 1] + (i < T[j] ? Q[j] : 0)); if(i) D[i][j] = max(D[i][j], D[i - 1][j] + (j < S[i] ? P[i] : 0)); // printf("%lld ", D[i][j]); } // printf("\n"); } printf("%lld\n", D[n][m]); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 4 ms | 764 KB | Time limit exceeded (wall clock) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 372 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 348 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 3 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 372 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 348 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 3 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Correct | 2 ms | 376 KB | Output is correct |
17 | Correct | 53 ms | 32140 KB | Output is correct |
18 | Correct | 55 ms | 32104 KB | Output is correct |
19 | Correct | 53 ms | 32120 KB | Output is correct |
20 | Correct | 51 ms | 32120 KB | Output is correct |
21 | Correct | 52 ms | 30972 KB | Output is correct |
22 | Correct | 53 ms | 32120 KB | Output is correct |
23 | Correct | 52 ms | 32064 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 372 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 348 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 3 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Correct | 2 ms | 376 KB | Output is correct |
17 | Correct | 53 ms | 32140 KB | Output is correct |
18 | Correct | 55 ms | 32104 KB | Output is correct |
19 | Correct | 53 ms | 32120 KB | Output is correct |
20 | Correct | 51 ms | 32120 KB | Output is correct |
21 | Correct | 52 ms | 30972 KB | Output is correct |
22 | Correct | 53 ms | 32120 KB | Output is correct |
23 | Correct | 52 ms | 32064 KB | Output is correct |
24 | Execution timed out | 4 ms | 680 KB | Time limit exceeded (wall clock) |
25 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 372 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 348 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 3 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Correct | 2 ms | 376 KB | Output is correct |
17 | Correct | 53 ms | 32140 KB | Output is correct |
18 | Correct | 55 ms | 32104 KB | Output is correct |
19 | Correct | 53 ms | 32120 KB | Output is correct |
20 | Correct | 51 ms | 32120 KB | Output is correct |
21 | Correct | 52 ms | 30972 KB | Output is correct |
22 | Correct | 53 ms | 32120 KB | Output is correct |
23 | Correct | 52 ms | 32064 KB | Output is correct |
24 | Execution timed out | 4 ms | 680 KB | Time limit exceeded (wall clock) |
25 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 372 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 348 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 3 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Correct | 2 ms | 376 KB | Output is correct |
17 | Correct | 53 ms | 32140 KB | Output is correct |
18 | Correct | 55 ms | 32104 KB | Output is correct |
19 | Correct | 53 ms | 32120 KB | Output is correct |
20 | Correct | 51 ms | 32120 KB | Output is correct |
21 | Correct | 52 ms | 30972 KB | Output is correct |
22 | Correct | 53 ms | 32120 KB | Output is correct |
23 | Correct | 52 ms | 32064 KB | Output is correct |
24 | Execution timed out | 4 ms | 680 KB | Time limit exceeded (wall clock) |
25 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 4 ms | 764 KB | Time limit exceeded (wall clock) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 4 ms | 764 KB | Time limit exceeded (wall clock) |
2 | Halted | 0 ms | 0 KB | - |