0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-30 20:56:29 +00:00
OI-codes/Luogu/CF19B/CF19B.cpp

40 lines
694 B
C++
Raw Normal View History

2022-04-04 13:34:32 +00:00
#include <iostream>
2022-06-01 01:45:41 +00:00
#include <cstring>
2022-04-04 13:34:32 +00:00
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;
}