Cod sursa(job #1923314)
| Utilizator | Data | 10 martie 2017 22:24:13 | |
|---|---|---|---|
| Problema | Energii | Scor | 95 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.52 kb |
#include <cstdio>
#include <algorithm>
using namespace std;
const int INF=1e9;
int d[10010];
int main()
{
freopen("energii.in","r",stdin);
freopen("energii.out","w",stdout);
int g,w,e,c;
scanf("%d%d",&g,&w);
for(int i=1;i<=2*w;i++) d[i]=INF;
for(int i=1;i<=g;i++)
{
scanf("%d%d",&e,&c);
for(int i=2*w;i>=e;i--)
d[i]=min(d[i],d[i-e]+c);
}
int sol=INF;
for(int i=w;i<=2*w;i++) sol=min(sol,d[i]);
printf("%d",sol);
return 0;
}
