榨取kkksc03 luogu1855 dp 裸二维费用背包

时间:2021-12-20 08:25:55

  首先对于这个题目背景,,个人认为很(you)好(qu),,,

  核心就是一个裸的二维费用背包,刚刚学习的同学参见dd大牛的背包九讲

 #include <cstdio>
#include <cstring>
#include <algorithm> int n, m, t;
int dp[][];
int mi, ti; int main () {
scanf("%d %d %d", &n, &m, &t);
for (int i = ; i <= n; i++) {
scanf("%d %d", &mi, &ti);
for (int j = m; j >= mi; j--)
for (int k = t; k >= ti; k--) {
dp[j][k] = std :: max(dp[j][k], dp[j-mi][k-ti] + );
}
}
printf("%d", dp[m][t]);
return ;
}