Pagini recente » Cod sursa (job #795960) | Cod sursa (job #3126807) | Cod sursa (job #2774348) | Cod sursa (job #1651826) | Cod sursa (job #2614129)
/*
`-/oo+/- ``
.oyhhhhhhyo.`od
+hhhhyyoooos. h/
+hhyso++oosy- /s
.yoooossyyo:``-y`
..----.` ``.-/+:.`
`````..-::/.
`..```.-::///`
`-.....--::::/:
`.......--::////:
`...`....---:::://:
`......``..--:::::///:`
`---.......--:::::////+/`
----------::::::/::///++:
----:---:::::///////////:`
.----::::::////////////:-`
`----::::::::::/::::::::-
`.-----:::::::::::::::-
...----:::::::::/:-`
`.---::/+osss+:`
``.:://///-.
*/
// aparent costurile pot fi si 0
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cmath>
using namespace std;
const int INF = 2e9;
const int N = 1e3;
const int W = 5e3;
int dp[5 + W];
int main() {
freopen("energii.in", "r", stdin);
freopen("energii.out", "w", stdout);
int n, w;
scanf("%d%d", &n, &w);
for(int i = 1; i <= w; i++) dp[i] = INF;
for(int i = 1; i <= n; i++) {
int p, g;
scanf("%d%d", &g, &p);
for(int j = w; j >= 0; j--) {
dp[min(w, j + g)] = min(dp[min(w, j + g)], dp[j] + p);
}
}
if(dp[w] != INF) printf("%d\n", dp[w]);
else printf("-1\n");
return 0;
}