#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define BET(a,b,c) ((a)<=(b)&&(b)<(c)) #define FOR(i,n) for(int i=0,i##_end=(int(n));i VI; typedef vector VVI; int main() { int N, V; cin>>N>>V; VI C(N); FOR(i,N) cin>>C[i]; vector S(N); S[0] = C[0]; for(int i=1;i 0){ int maxUnitIndex = 0; FOR(i,N) if(S[i] * (maxUnitIndex + 1) > S[maxUnitIndex] * (i+1)){ maxUnitIndex = i; } long long upper = N * N * N; if(upper < V){ long long need = (V - upper) / (maxUnitIndex + 1); ans += need * S[maxUnitIndex]; V -= need * (maxUnitIndex+1); } vector dp(V + 1, 1LL<<60); dp[0] = 0; FOR(i,N) { FOR(j,V+1) if(j - (i+1) >= 0) { dp[j] = min(dp[j], dp[j-(i+1)] + S[i]); } } ans += dp[V]; } cout<