Submission #259388

# Submission time Handle Problem Language Result Execution time Memory
259388 2020-08-07T17:34:59 Z keko37 Two Dishes (JOI19_dishes) C++14
10 / 100
64 ms 64888 KB
#include<bits/stdc++.h>

using namespace std;

typedef long long llint;

const int MAXN = 2005;

int n, m;
llint a[MAXN], b[MAXN], s[MAXN], t[MAXN], p[MAXN], q[MAXN];
llint suma[MAXN], sumb[MAXN];
llint dp[MAXN][MAXN];

llint calc (int i, int j) {
    if (dp[i][j] != -1) return dp[i][j];
    llint res = 0;
    if (i <= n) res = max(res, calc(i + 1, j) + (suma[i] + sumb[j - 1] <= s[i]) * p[i]);
    if (j <= m) res = max(res, calc(i, j + 1) + (suma[i - 1] + sumb[j] <= t[j]) * q[j]);
    return dp[i][j] = res;
}

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    memset(dp, -1, sizeof dp);
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        cin >> a[i] >> s[i] >> p[i];
        suma[i] = suma[i - 1] + a[i];
    }
    for (int i = 1; i <= m; i++) {
        cin >> b[i] >> t[i] >> q[i];
        sumb[i] = sumb[i - 1] + b[i];
    }
    cout << calc(1, 1);
    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 58 ms 64888 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 17 ms 31872 KB Output is correct
2 Correct 17 ms 31864 KB Output is correct
3 Correct 21 ms 31872 KB Output is correct
4 Correct 17 ms 31864 KB Output is correct
5 Correct 17 ms 31872 KB Output is correct
6 Correct 17 ms 31872 KB Output is correct
7 Correct 19 ms 31872 KB Output is correct
8 Correct 17 ms 31872 KB Output is correct
9 Correct 17 ms 31872 KB Output is correct
10 Correct 17 ms 31872 KB Output is correct
11 Correct 17 ms 31872 KB Output is correct
12 Correct 17 ms 31872 KB Output is correct
13 Correct 22 ms 31872 KB Output is correct
14 Correct 18 ms 31872 KB Output is correct
15 Correct 19 ms 31872 KB Output is correct
16 Correct 19 ms 31872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 31872 KB Output is correct
2 Correct 17 ms 31864 KB Output is correct
3 Correct 21 ms 31872 KB Output is correct
4 Correct 17 ms 31864 KB Output is correct
5 Correct 17 ms 31872 KB Output is correct
6 Correct 17 ms 31872 KB Output is correct
7 Correct 19 ms 31872 KB Output is correct
8 Correct 17 ms 31872 KB Output is correct
9 Correct 17 ms 31872 KB Output is correct
10 Correct 17 ms 31872 KB Output is correct
11 Correct 17 ms 31872 KB Output is correct
12 Correct 17 ms 31872 KB Output is correct
13 Correct 22 ms 31872 KB Output is correct
14 Correct 18 ms 31872 KB Output is correct
15 Correct 19 ms 31872 KB Output is correct
16 Correct 19 ms 31872 KB Output is correct
17 Correct 64 ms 32248 KB Output is correct
18 Correct 59 ms 32256 KB Output is correct
19 Correct 60 ms 32248 KB Output is correct
20 Correct 57 ms 32256 KB Output is correct
21 Correct 58 ms 32256 KB Output is correct
22 Correct 59 ms 32128 KB Output is correct
23 Correct 61 ms 32248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 31872 KB Output is correct
2 Correct 17 ms 31864 KB Output is correct
3 Correct 21 ms 31872 KB Output is correct
4 Correct 17 ms 31864 KB Output is correct
5 Correct 17 ms 31872 KB Output is correct
6 Correct 17 ms 31872 KB Output is correct
7 Correct 19 ms 31872 KB Output is correct
8 Correct 17 ms 31872 KB Output is correct
9 Correct 17 ms 31872 KB Output is correct
10 Correct 17 ms 31872 KB Output is correct
11 Correct 17 ms 31872 KB Output is correct
12 Correct 17 ms 31872 KB Output is correct
13 Correct 22 ms 31872 KB Output is correct
14 Correct 18 ms 31872 KB Output is correct
15 Correct 19 ms 31872 KB Output is correct
16 Correct 19 ms 31872 KB Output is correct
17 Correct 64 ms 32248 KB Output is correct
18 Correct 59 ms 32256 KB Output is correct
19 Correct 60 ms 32248 KB Output is correct
20 Correct 57 ms 32256 KB Output is correct
21 Correct 58 ms 32256 KB Output is correct
22 Correct 59 ms 32128 KB Output is correct
23 Correct 61 ms 32248 KB Output is correct
24 Runtime error 57 ms 64888 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 17 ms 31872 KB Output is correct
2 Correct 17 ms 31864 KB Output is correct
3 Correct 21 ms 31872 KB Output is correct
4 Correct 17 ms 31864 KB Output is correct
5 Correct 17 ms 31872 KB Output is correct
6 Correct 17 ms 31872 KB Output is correct
7 Correct 19 ms 31872 KB Output is correct
8 Correct 17 ms 31872 KB Output is correct
9 Correct 17 ms 31872 KB Output is correct
10 Correct 17 ms 31872 KB Output is correct
11 Correct 17 ms 31872 KB Output is correct
12 Correct 17 ms 31872 KB Output is correct
13 Correct 22 ms 31872 KB Output is correct
14 Correct 18 ms 31872 KB Output is correct
15 Correct 19 ms 31872 KB Output is correct
16 Correct 19 ms 31872 KB Output is correct
17 Correct 64 ms 32248 KB Output is correct
18 Correct 59 ms 32256 KB Output is correct
19 Correct 60 ms 32248 KB Output is correct
20 Correct 57 ms 32256 KB Output is correct
21 Correct 58 ms 32256 KB Output is correct
22 Correct 59 ms 32128 KB Output is correct
23 Correct 61 ms 32248 KB Output is correct
24 Runtime error 57 ms 64888 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 17 ms 31872 KB Output is correct
2 Correct 17 ms 31864 KB Output is correct
3 Correct 21 ms 31872 KB Output is correct
4 Correct 17 ms 31864 KB Output is correct
5 Correct 17 ms 31872 KB Output is correct
6 Correct 17 ms 31872 KB Output is correct
7 Correct 19 ms 31872 KB Output is correct
8 Correct 17 ms 31872 KB Output is correct
9 Correct 17 ms 31872 KB Output is correct
10 Correct 17 ms 31872 KB Output is correct
11 Correct 17 ms 31872 KB Output is correct
12 Correct 17 ms 31872 KB Output is correct
13 Correct 22 ms 31872 KB Output is correct
14 Correct 18 ms 31872 KB Output is correct
15 Correct 19 ms 31872 KB Output is correct
16 Correct 19 ms 31872 KB Output is correct
17 Correct 64 ms 32248 KB Output is correct
18 Correct 59 ms 32256 KB Output is correct
19 Correct 60 ms 32248 KB Output is correct
20 Correct 57 ms 32256 KB Output is correct
21 Correct 58 ms 32256 KB Output is correct
22 Correct 59 ms 32128 KB Output is correct
23 Correct 61 ms 32248 KB Output is correct
24 Runtime error 57 ms 64888 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 58 ms 64888 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 58 ms 64888 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -