-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathParty_Lemonade.cpp
113 lines (100 loc) · 2.42 KB
/
Party_Lemonade.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//https://codeforces.com/problemset/problem/913/C
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <class T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define repA(i, a, n) for (ll i = a; i <= (n); ++i)
#define repD(i, a, n) for (ll i = a; i >= (n); --i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define bpc(a) __builtin_popcount(a)
#define ff first
#define ss second
#define mk0(a) memset(a, 0, sizeof(a))
#define mk_1(a) memset(a, -1, sizeof(a))
#define ar array
#define pb push_back
#define faster \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(0);
#define pi pair<ll, ll>
#define map1 unordered_map
inline ll nc()
{
static char buf[100000], *p1 = buf, *p2 = buf;
return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++;
}
inline ll read()
{
ll ret = 0;
bool f = 0;
char ch = nc();
while (ch > '9' || ch < '0')
f ^= ch == '-', ch = nc();
while (ch <= '9' && ch >= '0')
ret = ret * 10 + ch - '0', ch = nc();
return f ? -ret : ret;
}
ll power(ll base, ll ind, ll mod)
{
ll res = 1;
while (ind)
{
if (ind & 1)
res = (res * base) % mod;
base = (base * base) % mod;
ind >>= 1;
}
return res;
}
ll inv(ll den, ll mod) { return power(den, mod - 2, mod); }
const ll MAX = 3e5 + 5;
const ll MASK = (1<<30)+1;
const ll MAX1 = 1e2 + 5;
const ll INF = 1e18;
const ll MOD = 998244353;
ll n,l;
ll c[32];
ll mn=INF;
void input()
{
// mk_1(dp);
cin>>n>>l;
rep(i,n)
cin>>c[i];
}
void solve()
{
rep1(i,n-1)
{
if(c[i]>c[i-1]*2)
c[i]=c[i-1]*2;
}
ll tot=0;
repD(i,n-1,0)
{
tot+=(l/(1<<i))*c[i];
l%=(1<<i);
mn=min(mn,tot+(l>0)*c[i]);
}
cout<<mn;
}
int main()
{
faster;
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
input();
solve();
}