dfs超时版本
#include <iostream>
using namespace std;
int w[101], v[101];
int ans = 0;
int t, m;
void dfs(int pos, int tleft, int val){
if(tleft < 0) return;
if (pos == m + 1) {
ans = max(ans, val);
return;
}
dfs(pos + 1, tleft, val);
dfs(pos + 1, tleft - w[pos], val + v[pos]);
}
int main(){
cin >> t >> m;
for (int i = 1; i <= m; i ++ ){
cin >> w[i] >> v[i];
}
dfs(1, t, 0);
cout << ans << endl;
return 0;
}