Pagini recente » Cod sursa (job #2845025) | Cod sursa (job #1501805) | Cod sursa (job #2317201) | Cod sursa (job #1809026) | Cod sursa (job #2602914)
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << x << "\n"
using namespace std;
typedef long long ll;
typedef pair <int, int > pii;
const int N = 25;
int dp[5005];
int main() {
ifstream cin("energii.in");
ofstream cout("energii.out");
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n,g;
cin >> n >> g;
for(int i = 0;i <= g;i++)
dp[i] = 1e9;
dp[0] = 0;
for(int i = 1;i <= n;i++){
int x,y;
cin >> x >> y;
for(int j = g;j >= 0;j--){
dp[j] = min(dp[j], dp[max(j - x,0)] + y);
}
}
if(dp[g] == 1e9)
cout << -1;
else
cout << dp[g];
return 0;
}