Submission #1075932

# Submission time Handle Problem Language Result Execution time Memory
1075932 2024-08-26T09:50:47 Z MinaRagy06 Two Dishes (JOI19_dishes) C++17
10 / 100
582 ms 1048576 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define SZ(x) (int) x.size()

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	int n, m;
	cin >> n >> m;
	array<ll, 3> a[n + 1], b[m + 1];
	ll prfa[n + 1]{}, prfb[m + 1]{};
	for (int i = 1; i <= n; i++) {
		cin >> a[i][0] >> a[i][1] >> a[i][2];
		prfa[i] = prfa[i - 1] + a[i][0];
	}
	for (int i = 1; i <= m; i++) {
		cin >> b[i][0] >> b[i][1] >> b[i][2];
		prfb[i] = prfb[i - 1] + b[i][0];
	}
	ll dp[n + 1][m + 1]{};
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= m; j++) {
			if (i == 0 && j == 0) continue;
//			cout << i << ' ' << j << endl;
			dp[i][j] = -1e18;
			if (i) {
				dp[i][j] = max(dp[i][j], dp[i - 1][j] + (prfa[i] + prfb[j] <= a[i][1]) * a[i][2]);
			}
			if (j) {
				dp[i][j] = max(dp[i][j], dp[i][j - 1] + (prfa[i] + prfb[j] <= b[j][1]) * b[j][2]);
			}
		}
	}
	cout << dp[n][m] << '\n';
	return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 558 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 456 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 452 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 456 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 452 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 28 ms 31836 KB Output is correct
18 Correct 36 ms 31836 KB Output is correct
19 Correct 33 ms 31832 KB Output is correct
20 Correct 28 ms 29532 KB Output is correct
21 Correct 30 ms 30580 KB Output is correct
22 Correct 32 ms 31832 KB Output is correct
23 Correct 29 ms 31836 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 456 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 452 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 28 ms 31836 KB Output is correct
18 Correct 36 ms 31836 KB Output is correct
19 Correct 33 ms 31832 KB Output is correct
20 Correct 28 ms 29532 KB Output is correct
21 Correct 30 ms 30580 KB Output is correct
22 Correct 32 ms 31832 KB Output is correct
23 Correct 29 ms 31836 KB Output is correct
24 Runtime error 582 ms 1048576 KB Execution killed with signal 9
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 456 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 452 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 28 ms 31836 KB Output is correct
18 Correct 36 ms 31836 KB Output is correct
19 Correct 33 ms 31832 KB Output is correct
20 Correct 28 ms 29532 KB Output is correct
21 Correct 30 ms 30580 KB Output is correct
22 Correct 32 ms 31832 KB Output is correct
23 Correct 29 ms 31836 KB Output is correct
24 Runtime error 582 ms 1048576 KB Execution killed with signal 9
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 456 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 452 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 28 ms 31836 KB Output is correct
18 Correct 36 ms 31836 KB Output is correct
19 Correct 33 ms 31832 KB Output is correct
20 Correct 28 ms 29532 KB Output is correct
21 Correct 30 ms 30580 KB Output is correct
22 Correct 32 ms 31832 KB Output is correct
23 Correct 29 ms 31836 KB Output is correct
24 Runtime error 582 ms 1048576 KB Execution killed with signal 9
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 558 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 558 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -