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:
parent
fa1c5990d3
commit
85b2bbae8e
39
Luogu/CF19B/CF19B.cpp
Normal file
39
Luogu/CF19B/CF19B.cpp
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user