题目链接
立即学习“前端免费学习笔记(深入)”;
立即学习“前端免费学习笔记(深入)”;
立即学习“前端免费学习笔记(深入)”;
const int MAXN = 110;const int M = 210000;int tastes[MAXN], calories[MAXN];int v[MAXN];int dp[2][M];int main(){// freopen("in.txt", "r", stdin); int n, m; while (~RII(n, m)) { REP(i, n) RI(tastes[i]); REP(i, n) RI(calories[i]); REP(i, n) v[i] = tastes[i] - calories[i] * m; CLR(dp, -INF); dp[0][0] = dp[1][0] = 0; REP(i, n) { int cnt = v[i] < 0, val = abs(v[i]); FED(j, M - val - 1, 0) dp[cnt][j + val] = max(dp[cnt][j + val], dp[cnt][j] + tastes[i]); } int ans = 0; REP(i, M) ans = max(ans, dp[0][i] + dp[1][i]); if (ans <= 0) puts("-1"); else WI(ans); } return 0;}立即学习“前端免费学习笔记(深入)”;
HTML怎么学习?HTML怎么入门?HTML在哪学?HTML怎么学才快?不用担心,这里为大家提供了HTML速学教程(入门课程),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号