Pagini recente » Cod sursa (job #411649) | Cod sursa (job #2090354) | Cod sursa (job #2497770) | Cod sursa (job #1351412) | Cod sursa (job #782125)
Cod sursa(job #782125)
#include<cstdio>
int d[10001];
int main()
{
int n=0,g=0,s=10000000,i=0,j=0,inf=10000000,e=0,p=0;
freopen("energii.in","r",stdin);
freopen("energii.out","w",stdout);
scanf("%d%d",&n,&g);
for (i=1; i<=10001; ++i)
d[i]=inf;
for(i=0; i<n; ++i)
{
scanf("%d%d",&e,&p);
for(j=g-e; j>-1; --j)
if(d[j+e]>d[j]+p)
{
d[j+e]=d[j]+p;
if(d[j+e]<s)
s=d[j+e];
}
}
if (s!=10000000)
printf("%d",s);
else
printf("-1");
return 0;
}