dctc1494 @ 2024-05-04 17:56:40
样例都对,就是测试的时候WA了......
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <array>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iterator>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
const int N = 2e3 + 5;
const int M = 4e3 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int NEG_INF = -0x3f3f3f3f;
LL n, v = 0, ans = INF, t[N], c[N], dp[M];
int main(void) {
memset(dp, INF, sizeof(dp));
dp[0] = 0;
scanf("%lld", &n);
for (LL i = 1; i <= n; ++i) {
scanf("%lld%lld", &t[i], &c[i]);
++t[i];
v = max(v, t[i]);
}
v += n;
for (LL i = 1; i <= n; ++i) {
for (LL j = v; j >= t[i]; --j) {
dp[j] = min(dp[j], dp[j - t[i]] + c[i]);
}
}
for (LL i = n; i <= v; ++i) {
ans = min(ans, dp[i]);
}
printf("%lld\n", ans);
return 0;
}
by dctc800d @ 2024-05-05 20:04:12
@dctc1494 ans初值=0x3f3f3f3f3f3f3f3f
题解不是说注意了吗
多注意点啊