0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-23 20:28:48 +00:00

CF19B Checkout Assistant

R73187794
This commit is contained in:
Baoshuo Ren 2022-04-04 21:34:32 +08:00
parent fa1c5990d3
commit 85b2bbae8e
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

39
Luogu/CF19B/CF19B.cpp Normal file
View File

@ -0,0 +1,39 @@
#include <cstring>
#include <iostream>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 2005;
int n, t[N], c[N];
long long f[N << 1], ans;
int main() {
std::ios::sync_with_stdio(false);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> t[i] >> c[i];
t[i] = std::min(n, t[i] + 1);
}
ans = 0x3f3f3f3f3f3f3f3f;
memset(f, 0x3f, sizeof(f));
f[0] = 0;
for (int i = 1; i <= n; i++) {
for (int j = n << 1; j >= t[i]; j--) {
f[j] = std::min(f[j], f[j - t[i]] + c[i]);
}
}
for (int i = 0; i <= n; i++) {
ans = std::min(ans, f[n + i]);
}
cout << ans << endl;
return 0;
}