题目大意

混合背包。每棵树都有美学值 $C_i$,共有三种:

  • 一种只能看一遍。
  • 一种最多看 $A_i$ 遍。
  • 一种可以看无数遍。

分析

对于混合背包,我们可以对物品拆分,得到多个物品。

ll dp[1086], tt[100086], cc[100086];

int main() {
	int tsh = rr(), tsm = rr(), teh = rr(), tem = rr();
	int tsum = (teh - tsh) * 60 + tem - tsm;
	int n = rr();

	int tp = 1;
	for (ll i = 1; i <= n; i++) {
		int t = rr(), c = rr(), p = rr();
		if (p == 1) {
			tt[tp] = t, cc[tp] = c;
			tp++;
		} else {
			p = p != 0 ? p : 99999;
			int b = 1;
			while (b < p) {
				tt[tp] = t * b, cc[tp] = c * b;
				p -= b, b *= 2;
				tp++;
			}
			tt[tp] = t * p, cc[tp] = c * p;
			tp++;
		}
	}
	for (ll i = 1; i <= tp - 1; i++) {
		for (ll j = tsum; j >= tt[i]; j--) {
			dp[j] = max(dp[j], dp[j - tt[i]] + cc[i]);
		}
	}
	ll ans = 0;
	for (ll ic = 0; ic <= tsum; ic++) {
		ans = max(dp[ic], ans);
	}
	printf("%lld\n", ans);
	return 0;
}