#include #include #include #include #include #include #include #include #include #include using namespace std; long long gcd(long long a, long long b){ if(b==0) return a; return gcd(b, a%b); } long long lcm(long long a, long long b){ if(a& a, pair& b){ long long lcm_ = lcm(a.second, b.second); return a.first * (lcm_/a.second) > b.first * (lcm_/b.second); } int main(){ int n; long long v; cin >> n >> v; vector c(n); for(int i=0; i> c[i]; } vector d(n+1, 0); for(int i=0; i dp(n*n, 1LL<<58); dp[0] = 0; for(int i=0; i best = {d[1],1}; for(int i=2; i<=n; i++){ pair next = {d[i], i}; if(comp(best, next)){ best = next; } } long long lb = -1; long long ub = v/best.second +1; while(ub-lb>1){ long long mid = (ub+lb)/2; long long rem = v - best.second * mid; if(rem >= dp.size()){ lb = mid; }else{ ub = mid; } } ans += best.first * ub; v -= best.second * ub; ans += dp[v]; cout << ans << endl; return 0; }