# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
109684 | 2019-05-07T13:23:59 Z | tincamatei | Two Dishes (JOI19_dishes) | C++14 | 123 ms | 57976 KB |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 1000000; const int SUBTASK = 2000; struct Dish { int len, art; long long limit; } v1[1+MAX_N], v2[1+MAX_N]; long long sp1[1+MAX_N], sp2[1+MAX_N]; long long dp[1+SUBTASK][1+SUBTASK]; bool dish[1+SUBTASK][1+SUBTASK]; int main() { #ifdef HOME FILE *fin = fopen("input.in", "r"); FILE *fout = fopen("output.out", "w"); #else FILE *fin = stdin; FILE *fout = stdout; #endif int n, m; fscanf(fin, "%d%d", &n, &m); for(int i = 1; i <= n; ++i) { fscanf(fin, "%d%lld%d", &v1[i].len, &v1[i].limit, &v1[i].art); sp1[i] = sp1[i - 1] + v1[i].len; if(sp1[i] <= v1[i].limit) dp[i][0] = dp[i - 1][0] + v1[i].art; else dp[i][0] = dp[i - 1][0]; dish[i][0] = 0; } for(int i = 1; i <= m; ++i) { fscanf(fin, "%d%lld%d", &v2[i].len, &v2[i].limit, &v2[i].art); sp2[i] = sp2[i - 1] + v2[i].len; if(sp2[i] <= v2[i].limit) dp[0][i] = dp[0][i - 1] + v2[i].art; else dp[0][i] = dp[0][i - 1]; dish[0][i] = 1; } for(int i = 1; i <= n; ++i) for(int j = 1; j <= m; ++j) { long long t = sp1[i] + sp2[j]; long long c1 = dp[i - 1][j], c2 = dp[i][j - 1]; if(t <= v1[i].limit) c1 += v1[i].art; if(t <= v2[j].limit) c2 += v2[j].art; if(c1 > c2) dish[i][j] = 0; else dish[i][j] = 1; dp[i][j] = max(c1, c2); } fprintf(fout, "%lld", dp[n][m]); fclose(fin); fclose(fout); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 111 ms | 57848 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 512 KB | Output is correct |
3 | Correct | 2 ms | 512 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 3 ms | 384 KB | Output is correct |
9 | Correct | 3 ms | 512 KB | Output is correct |
10 | Correct | 3 ms | 384 KB | Output is correct |
11 | Correct | 2 ms | 512 KB | Output is correct |
12 | Correct | 3 ms | 384 KB | Output is correct |
13 | Correct | 2 ms | 384 KB | Output is correct |
14 | Correct | 2 ms | 512 KB | Output is correct |
15 | Correct | 2 ms | 384 KB | Output is correct |
16 | Correct | 3 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 512 KB | Output is correct |
3 | Correct | 2 ms | 512 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 3 ms | 384 KB | Output is correct |
9 | Correct | 3 ms | 512 KB | Output is correct |
10 | Correct | 3 ms | 384 KB | Output is correct |
11 | Correct | 2 ms | 512 KB | Output is correct |
12 | Correct | 3 ms | 384 KB | Output is correct |
13 | Correct | 2 ms | 384 KB | Output is correct |
14 | Correct | 2 ms | 512 KB | Output is correct |
15 | Correct | 2 ms | 384 KB | Output is correct |
16 | Correct | 3 ms | 384 KB | Output is correct |
17 | Correct | 48 ms | 35756 KB | Output is correct |
18 | Correct | 41 ms | 35804 KB | Output is correct |
19 | Correct | 47 ms | 35832 KB | Output is correct |
20 | Correct | 43 ms | 35836 KB | Output is correct |
21 | Correct | 38 ms | 34440 KB | Output is correct |
22 | Correct | 47 ms | 35648 KB | Output is correct |
23 | Correct | 46 ms | 35704 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 512 KB | Output is correct |
3 | Correct | 2 ms | 512 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 3 ms | 384 KB | Output is correct |
9 | Correct | 3 ms | 512 KB | Output is correct |
10 | Correct | 3 ms | 384 KB | Output is correct |
11 | Correct | 2 ms | 512 KB | Output is correct |
12 | Correct | 3 ms | 384 KB | Output is correct |
13 | Correct | 2 ms | 384 KB | Output is correct |
14 | Correct | 2 ms | 512 KB | Output is correct |
15 | Correct | 2 ms | 384 KB | Output is correct |
16 | Correct | 3 ms | 384 KB | Output is correct |
17 | Correct | 48 ms | 35756 KB | Output is correct |
18 | Correct | 41 ms | 35804 KB | Output is correct |
19 | Correct | 47 ms | 35832 KB | Output is correct |
20 | Correct | 43 ms | 35836 KB | Output is correct |
21 | Correct | 38 ms | 34440 KB | Output is correct |
22 | Correct | 47 ms | 35648 KB | Output is correct |
23 | Correct | 46 ms | 35704 KB | Output is correct |
24 | Runtime error | 123 ms | 57976 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
25 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 512 KB | Output is correct |
3 | Correct | 2 ms | 512 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 3 ms | 384 KB | Output is correct |
9 | Correct | 3 ms | 512 KB | Output is correct |
10 | Correct | 3 ms | 384 KB | Output is correct |
11 | Correct | 2 ms | 512 KB | Output is correct |
12 | Correct | 3 ms | 384 KB | Output is correct |
13 | Correct | 2 ms | 384 KB | Output is correct |
14 | Correct | 2 ms | 512 KB | Output is correct |
15 | Correct | 2 ms | 384 KB | Output is correct |
16 | Correct | 3 ms | 384 KB | Output is correct |
17 | Correct | 48 ms | 35756 KB | Output is correct |
18 | Correct | 41 ms | 35804 KB | Output is correct |
19 | Correct | 47 ms | 35832 KB | Output is correct |
20 | Correct | 43 ms | 35836 KB | Output is correct |
21 | Correct | 38 ms | 34440 KB | Output is correct |
22 | Correct | 47 ms | 35648 KB | Output is correct |
23 | Correct | 46 ms | 35704 KB | Output is correct |
24 | Runtime error | 123 ms | 57976 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
25 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 512 KB | Output is correct |
3 | Correct | 2 ms | 512 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 3 ms | 384 KB | Output is correct |
9 | Correct | 3 ms | 512 KB | Output is correct |
10 | Correct | 3 ms | 384 KB | Output is correct |
11 | Correct | 2 ms | 512 KB | Output is correct |
12 | Correct | 3 ms | 384 KB | Output is correct |
13 | Correct | 2 ms | 384 KB | Output is correct |
14 | Correct | 2 ms | 512 KB | Output is correct |
15 | Correct | 2 ms | 384 KB | Output is correct |
16 | Correct | 3 ms | 384 KB | Output is correct |
17 | Correct | 48 ms | 35756 KB | Output is correct |
18 | Correct | 41 ms | 35804 KB | Output is correct |
19 | Correct | 47 ms | 35832 KB | Output is correct |
20 | Correct | 43 ms | 35836 KB | Output is correct |
21 | Correct | 38 ms | 34440 KB | Output is correct |
22 | Correct | 47 ms | 35648 KB | Output is correct |
23 | Correct | 46 ms | 35704 KB | Output is correct |
24 | Runtime error | 123 ms | 57976 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
25 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 111 ms | 57848 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 111 ms | 57848 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |