#include using namespace std; int dp[10005]; int c[15]; int v[15]; int main(void) { cin.tie(0); ios::sync_with_stdio(false); int t,n; cin >> t; cin >> n; for(int i=0;i> c[i]; } for(int i=0;i> v[i]; } memset(dp,-1,sizeof(dp)); dp[0] = 0; for(int i=0;i> vec; while(val > 0) { cost += c[i]; sum += val; val/=2; vec.push_back(make_pair(cost,sum)); } for(int j=t;j>=0;j--) { if(dp[j]==-1) continue; for(int k=0;k