#include #include #include using namespace std; using ll = long long; int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int t; cin>>t; vector dp(t+1,0); int n; cin>>n; vector c(n),v(n); for(int i = 0;i>c[i]; for(int i = 0;i>v[i]; for(int i = 0;i0){ for(int j = t;j>=0;j--){ if(j-c[i]<0) continue; dp[j] = max(dp[j],dp[j-c[i]]+v[i]); } v[i] /= 2; } } int mx = 0; for(int i = 0;i<=t;i++) mx = max(mx,dp[i]); cout<