Pagini recente » Istoria paginii runda/minune3/clasament | Cod sursa (job #1587726) | Cod sursa (job #1139843) | Cod sursa (job #457006) | Cod sursa (job #2357285)
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream fin("energii.in");
ofstream fout("energii.out");
const int INF = (1 << 30);
int G,W;
int mat[5010];
int x,y;
vector <int> L,C;
void Read()
{
fin>>G>>W;
for(int i=1;i<=W;++i)
mat[i]=INF;
for(int i=1;i<=G;++i)
{
fin>>x>>y;
int l,c;
for(int k=0;k<L.size();++k)
{
l=L[k];
mat[l+x]=min(mat[l+x],mat[l]+y);
}
mat[x]=min(mat[x],y);
L.push_back(x);
}
fout<<mat[W];
}
int main()
{
Read();
return 0;
}