Submission #375775

# Submission time Handle Problem Language Result Execution time Memory
375775 2021-03-10T01:41:09 Z Kevin_Zhang_TW Two Dishes (JOI19_dishes) C++17
0 / 100
1 ms 492 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb emplace_back
#define AI(i) begin(i), end(i)
template<class T> bool chmin(T &a, T b) { return b < a && (a = b, true); }
template<class T> bool chmax(T &a, T b) { return a < b && (a = b, true); }
#ifdef KEV
#define DE(args...) kout("[ " + string(#args) + " ] = ", args)
void kout() { cerr << endl; }
template<class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ', kout(b...); }
template<class T> void debug(T l, T r) { while (l != r) cerr << *l << " \n"[next(l) == r], ++l; }
#else
#define DE(...) 0
#define debug(...) 0
#endif 
const int MAX_N = 2010;

const ll inf = 1ll << 60;

int n[2], a[2][MAX_N], tl[2][MAX_N], w[2][MAX_N];

ll dur[2][MAX_N];

ll dp[MAX_N][MAX_N];

int32_t main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n[0] >> n[1];

	if (max(n[0], n[1]) > 2000) return -1;

	for (int k = 0;k < 2;++k)
		for (int i = 1;i <= n[k];++i)
			cin >> a[k][i] >> tl[k][i] >> w[k][i];

	for (int k = 0;k < 2;++k) {
		for (int i = 1;i <= n[k];++i)
			dur[k][i] = dur[k][i-1] + a[k][i];
	}

	for (int i = 0;i <= n[0];++i)
		for (int j = 0;j <= n[1];++j)
			dp[i][j] = -inf;
	dp[0][0] = 0;

	for (int i = 0;i <= n[0];++i)
		for (int j = 0;j <= n[1];++j) {
			ll ct = dur[0][i] + dur[1][j];
			chmax(dp[i+1][j], dp[i][j] +
					(ct + a[0][i+1] <= tl[0][i+1] ? w[0][i+1] : 0));
			chmax(dp[i][j+1], dp[i][j] +
					(ct + a[1][j+1] <= tl[1][j+1] ? w[1][j+1] : 0));
		}

	cout << dp[n[0]][n[1]] << '\n';

}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 492 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 492 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 492 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -