#include <bits/stdc++.h>
#define endl '\n'
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
using namespace std;
template<class T, class T2> inline int chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline int chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const int MAXN = 32;
const int MAXK = 5032;
const int64_t inf = (int64_t)1e18;
int n, k;
pair<int64_t, int> a[MAXN];
void read()
{
cin >> n >> k;
k -= n;
for(int i = 0; i < n; i++)
{
cin >> a[i].first;
a[i].second = i;
}
}
int64_t dp[MAXN][MAXN][MAXK];
int answer[MAXN];
int64_t rec(int i, int add, int lft, int S = 0)
{
if(i == n)
return lft == 0 ? 0 : inf;
int64_t &memo = dp[i][add][lft];
if(memo != -1)
return memo;
memo = inf;
chkmin(memo, rec(i + 1, add + 1, lft, S + a[i].first));
for(int v = 1; v * (n - i) <= lft; v++)
chkmin(memo, S * (n - i) + rec(i + 1, 1, lft - v * (n - i), a[i].first));
return memo;
}
void solve()
{
sort(a, a + n);
memset(dp, -1, sizeof(dp));
while(k > 1200)
{
k -= n;
for(int i = 0; i < n; i++)
answer[i]++;
}
for(int i = 0; i < n; i++)
answer[i]++;
cout << rec(0, 0, k) << endl;
int add = 0, lft = k, S = 0;
for(int i = 0; i < n; i++)
{
if(rec(i, add, lft, S) == rec(i + 1, add + 1, lft, S + a[i].first))
{
S += a[i].first;
add++;
}
else for(int v = 1; v * (n - i) <= lft; v++)
if(rec(i, add, lft, S) == S * (n - i) + rec(i + 1, 1, lft - v * (n - i), a[i].first))
{
S = a[i].first;
lft -= v * (n - i);
add = 1;
for(int p = i; p < n; p++)
answer[a[p].second] += v;
break;
}
}
for(int i = 0; i < n; i++)
cout << answer[i] << " ";
cout << endl;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
read();
solve();
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgZW5kbCAnXG4nCgovLyNwcmFn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