10pts,大佬求助!
  • 板块P1833 樱花
  • 楼主_Supernova
  • 当前回复0
  • 已保存回复0
  • 发布时间2023/10/30 15:49
  • 上次更新2023/11/2 10:41:52
查看原帖
10pts,大佬求助!
878013
_Supernova楼主2023/10/30 15:49
#include <bits/stdc++.h>
using namespace std;
int h1, m1, h2, m2, n, tt;
int t[100002], c[100002], p[100002], ti, ci, pi, cnt;
int ans, dp[500002];
int main(void) {
	scanf("%d:%d %d:%d %d",&h1, &m1, &h2, &m2, &n);
	tt = 60 * (h2 - h1) + (m2 - m1);
	for (int i = 1; i <= n; ++i) {
		scanf("%d %d %d", &ti, &ci, &pi);
		int now = 1;
		while (now < pi) {
			t[++cnt] = now * ti;
			c[cnt] = now * ci;
			pi -= now;
			now *= 2;
		}
		if (pi) {
			t[++cnt] = ti * pi;
			c[cnt] = ci * pi;
		}
	}
	for (int i = 1; i <= cnt; ++i) {
		for (int j = tt; j >= t[i]; --j) {
			dp[j] = max(dp[j], dp[j - t[i]] + c[i]);
		}
	}
	printf("%d", dp[tt]);
	return 0;
}
2023/10/30 15:49
加载中...