#include <bits/stdc++.h>
using namespace std;
int n, m, t;
int Max = 0;
struct good{
int p;
int v;
};
bool cmp (good a, good b)
{
if (a.p <= b.p)
return true;
else
return false;
}
good a [30];
void sel (int x, int y, int z)
{
if (z >= 0 && x <= m + 1){
Max = max (Max, y);
sel (x + 1, y + a [x].v, z - a [x].p);
sel (x + 1, y, z);
}
return;
}
int main ()
{
cin >> n >> m;
for (int i = 1; i <= m; i ++){
cin >> a [i].p;
cin >> t;
a [i].v = t * a [i].p;
}
sort (a + 1, a + m + 1, cmp);
/*for (int i = 1; i <= m; i ++){
cout << a [i].p << ' ' << a [i].v << endl;
}*/
sel (1, 0, n);
cout << Max;
return 0;
}
1115 开心的金明
最新推荐文章于 2024-05-29 16:54:04 发布