#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <bitset>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define TASK ""
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define for1(i, n) for (int i = 1; i <= (int)n; i++)
#define forq(i, s, t) for (int i = s; i <= (int)t; i++)
#define ford(i, s, t) for (int i = s; i >= (int)t; i--)
#define mk make_pair
#define pk push_back
#define all(v) v.begin(), v.end()
#define TIME clock() * 1.0 / CLOCKS_PER_SEC

const double EPS = 1e-15;
const double PI = acos(-1.0);
const int MAXN = (int)1e5+ 7;
const int INF = (int)1e9 + 7;
const ll LINF = (ll)2e18 + 7;
const int MOD = (int)1e9 + 7;
const ull P = 239017;
const ull MM = (ull)2147482661;

int n;
ll mx, cf, cm, m, pref[MAXN], ans[MAXN];
pair<ll, int> a[MAXN];

ll get(int l, int r){
    if (l > r) return 0;
    return pref[r] - pref[l - 1];
}

bool f(ll minim, ll cur, int q){
    int pos = lower_bound(a, a + n + 1, make_pair(minim, 0)) - a - 1;
    pos = min(pos, n - q);
    return pos * minim - get(1, pos) <= cur;
}

int main()
{
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
    cin >> n >> mx >> cf >> cm >> m;
    for1(i, n){
        scanf("%I64d", &a[i].first);
        a[i].second = i;
    }
    sort(a + 1, a + n + 1);
    for1(i, n){
        pref[i] = pref[i - 1] + a[i].first;
    }
    ll answer = 0, ansmin, ansq;
    forn(i, n + 1){
        ll cur = m;
        cur -= (i * mx - get(n - i + 1, n));
        if (cur < 0){
            break;
        }
        ll left = 0, right = mx + 1;
        while (right - left > 1){
            ll mid = (right + left) / 2;
            (f(mid, cur, i) ? left : right) = mid;
        }
        ll curmin = left;
        ll curans = i * cf + curmin * cm;
        //cout << "I" << i << ' ' << cur << '\n';
        if (curans > answer){
            answer = curans, ansmin = curmin, ansq = i;
        }
    }
    cout << answer << '\n';
    for1(i, n){
        if (n - ansq + 1 <= i){
            ans[a[i].second] = mx;
        }
        else{
            ans[a[i].second] = max(ansmin, a[i].first);
        }
    }
    for1(i, n){
        printf("%I64d ", ans[i]);
    }
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <bitset>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define TASK ""
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define for1(i, n) for (int i = 1; i <= (int)n; i++)
#define forq(i, s, t) for (int i = s; i <= (int)t; i++)
#define ford(i, s, t) for (int i = s; i >= (int)t; i--)
#define mk make_pair
#define pk push_back
#define all(v) v.begin(), v.end()
#define TIME clock() * 1.0 / CLOCKS_PER_SEC

const double EPS = 1e-15;
const double PI = acos(-1.0);
const int MAXN = (int)1e5+ 7;
const int INF = (int)1e9 + 7;
const ll LINF = (ll)2e18 + 7;
const int MOD = (int)1e9 + 7;
const ull P = 239017;
const ull MM = (ull)2147482661;

int n;
ll mx, cf, cm, m, pref[MAXN], ans[MAXN];
pair<ll, int> a[MAXN];

ll get(int l, int r){
    if (l > r) return 0;
    return pref[r] - pref[l - 1];
}

bool f(ll minim, ll cur, int q){
    int pos = lower_bound(a, a + n + 1, make_pair(minim, 0)) - a - 1;
    pos = min(pos, n - q);
    return pos * minim - get(1, pos) <= cur;
}

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
    cin >> n >> mx >> cf >> cm >> m;
    for1(i, n){
        scanf("%I64d", &a[i].first);
        a[i].second = i;
    }
    sort(a + 1, a + n + 1);
    for1(i, n){
        pref[i] = pref[i - 1] + a[i].first;
    }
    ll answer = 0, ansmin, ansq;
    forn(i, n + 1){
        ll cur = m;
        if (i > m / mx){
            break;
        }
        cur -= (i * mx - get(n - i + 1, n));
        ll left = 0, right = mx + 1;
        while (right - left > 1){
            ll mid = (right + left) / 2;
            (f(mid, cur, i) ? left : right) = mid;
        }
        ll curmin = left;
        ll curans = i * cf + curmin * cm;
        //cout << "I" << i << ' ' << cur << '\n';
        if (curans > answer){
            answer = curans, ansmin = curmin, ansq = i;
        }
    }
    cout << answer << '\n';
    for1(i, n){
        if (n - ansq + 1 <= i){
            ans[a[i].second] = mx;
        }
        else{
            ans[a[i].second] = max(ansmin, a[i].first);
        }
    }
    for1(i, n){
        printf("%I64d ", ans[i]);
    }
	return 0;
}


//in the name of god
#include<bits/stdc++.h>
#define int long long
using namespace std;

const int MAXN = 1001 * 10001;
long double P = 3.1415926535897932384626433832795;
pair<int,int> a [ MAXN ] ;

int n , mx , cf,cm,m;

int ps[ MAXN ] = { };

bool check(int p , int mn)
{
    if(mn>mx)
        return 0;
    if(a[0].first>mn)
        return 1;
    if(a[n-1].first<=mn)
    {
        if(n*mn-ps[n-1]<=p)
            return 1;
        return 0;
    }
    int l = 0, r = n-1,mid;
    while(r-l>1)
    {
        mid=(r+l)/2;
        if(a[mid].first<=mn)
            l=mid;
        else
            r=mid;
    }
    if(r*mn-ps[l]<=p)
        return 1;
    return 0 ;
}

 main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    cin >> n>>mx>>cf>>cm>>m;
    for(int i = 0 ; i < n ; i ++)
    {
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(a,a+n);
    ps[0]=a[0].first;
    for(int i = 1 ; i < n ; i++)
        ps[i]=ps[i-1]+a[i].first;
    int q,x,y,l,r,mid,ans=0,ee=0,eee,aa;
    for(int i = 0 ; i <= n ; i++)
    {
        if(i<n)x=ps[n-1]-ps[n-i-1];
        else x = ps[n-1];
        y=m-i*mx+x;
        if(y<0)
            continue;
        ee=cf*i;
        int l = 0 , r = mx+1;
        while(r-l>1)
        {
            mid=(r+l)/2;
            if(check(y,mid))
                l=mid;
            else
                r=mid;
        }
        ee+=l*cm;
        if(ans<ee)
        {
            eee=l;
            aa=i;
        }
        ans=max(ans,ee);

    }
    cout<<ans<<'\n';
    for(int i = n -1 ; i >=n-aa;i--)
        a[i].first=mx;
    for(int i = 0 ; i < n ; i++)
        swap(a[i].first,a[i].second);
    sort(a,a+n);
    for(int i = 0 ; i < n ; i++)
    {
        if(a[i].second<eee)
            a[i].second=eee;
        cout << a[i].second<<' ';
    }

}


//in the name of god
#include<bits/stdc++.h>
#define int long long
using namespace std;

const int MAXN = 1001 * 10001;
pair<int,int> a [ MAXN ] ;

int n , mx , cf,cm,m;

int ps[ MAXN ] = { };

bool check(int p , int mn,int ind)
{
    if(mn>mx)
        return 0;
    if(a[0].first>=mn||ind<0)
        return 1;
    if(a[n-1].first<=mn)
    {
        if(n*mn-ps[n-1]<=p)
            return 1;
        return 0;
    }
    int l = 0, r = n-1,mid;
    while(r-l>1)
    {
        mid=(r+l)/2;
        if(a[mid].first<mn)
            l=mid;
        else
            r=mid;
    }
    l=min(l,ind);
    r=l+1;
    if(r*mn-ps[l]<=p)
        return 1;
    return 0 ;
}

 main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    cin >> n>>mx>>cf>>cm>>m;

    for(int i = 0 ; i < n ; i ++)
    {
        cin >> a[i].first;
        a[i].second = i;
    }

    sort(a,a+n);
    ps[0]=a[0].first;
    for(int i = 1 ; i < n ; i++)
        ps[i]=ps[i-1]+a[i].first;

    int q,x,y,l,r,mid,ans=0,ee=0,eee,aa;
    for(int i = 0 ; i <= n ; i++)
    {
        if(i<n)x=ps[n-1]-ps[n-i-1];
        else x = ps[n-1];
        y=m-i*mx+x;
        if(y<0)
            continue;
        ee=cf*i;

        int l = a[0].first , r = mx+1;
        while(r-l>1)
        {
            mid=(r+l)/2;
            if(check(y,mid,n-i-1))
                l=mid;
            else
                r=mid;
        }
        ee+=l*cm;
        if(ans<ee)
        {
            eee=l;
            aa=i;
        }
        ans=max(ans,ee);

    }
    cout<<ans<<'\n';
    for(int i = n -1 ; i >=n-aa;i--)
        a[i].first=mx;
    for(int i = 0 ; i < n ; i++)
        swap(a[i].first,a[i].second);
    sort(a,a+n);
    for(int i = 0 ; i < n ; i++)
    {
        if(a[i].second<eee)
            a[i].second=eee;
        cout << a[i].second<<' ';
    }

}


//in the name of god
#include<bits/stdc++.h>
#define int long long
using namespace std;

const int MAXN = 1001 * 10001;
pair<int,int> a [ MAXN ] ;

int n , mx , cf,cm,m;

int ps[ MAXN ] = { };

bool check(int p , int mn,int ind)
{
    if(mn>mx)
        return 0;
    if(a[0].first>=mn||ind<0)
        return 1;
    if(a[n-1].first<=mn)
    {
        if(n*mn-ps[n-1]<=p)
            return 1;
        return 0;
    }
    int l = 0, r = n-1,mid;
    while(r-l>1)
    {
        mid=(r+l)/2;
        if(a[mid].first<mn)
            l=mid;
        else
            r=mid;
    }
    l=min(l,ind);
    r=l+1;
    if(r*mn-ps[l]<=p)
        return 1;
    return 0 ;
}

 main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    cin >> n>>mx>>cf>>cm>>m;

    for(int i = 0 ; i < n ; i ++)
    {
        cin >> a[i].first;
        a[i].second = i;
    }

    sort(a,a+n);
    ps[0]=a[0].first;
    for(int i = 1 ; i < n ; i++)
        ps[i]=ps[i-1]+a[i].first;

    int q,x,y,l,r,mid,ans=0,ee=0,eee,aa=0;
    for(int i = 0 ; i <= n ; i++)
    {
        if(i<n)x=ps[n-1]-ps[n-i-1];
        else x = ps[n-1];
        y=m-i*mx+x;
        if(y<0)
            continue;
        ee=cf*i;

        int l = a[0].first , r = mx+1;
        while(r-l>1)
        {
            mid=(r+l)/2;
            if(check(y,mid,n-i-1))
                l=mid;
            else
                r=mid;
        }
        ee+=l*cm;
        if(ans<ee)
        {
            eee=l;
            aa=i;
        }
        ans=max(ans,ee);

    }
    cout<<ans<<'\n';
    for(int i = n -1 ; i >=n-aa;i--)
        a[i].first=mx;
    for(int i = 0 ; i < n ; i++)
        swap(a[i].first,a[i].second);
    sort(a,a+n);
    if(ans==0)
    {
        for(int i = 0 ;i < n ;i++)
            cout<<a[i].second<<' ';
    }
    for(int i = 0 ; i < n ; i++)
    {
        if(a[i].second<eee)
            a[i].second=eee;
        cout << a[i].second<<' ';
    }

}


//in the name of god
#include<bits/stdc++.h>
#define int long long
using namespace std;

const int MAXN = 1001 * 10001;
pair<int,int> a [ MAXN ] ;

int n , mx , cf,cm,m;

int ps[ MAXN ] = { };

bool check(int p , int mn,int ind)
{
    if(mn>mx)
        return 0;
    if(a[0].first>=mn)
        return 1;
    if(a[n-1].first<=mn)
    {
        if(n*mn-ps[n-1]<=p)
            return 1;
        return 0;
    }
    int l = 0, r = n-1,mid;
    while(r-l>1)
    {
        mid=(r+l)/2;
        if(a[mid].first<mn)
            l=mid;
        else
            r=mid;
    }
    l=min(l,ind);
    r=min(r,ind+1);
    if(r*mn-ps[l]<=p)
        return 1;
    return 0 ;
}

 main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    cin >> n>>mx>>cf>>cm>>m;

    for(int i = 0 ; i < n ; i ++)
    {
        cin >> a[i].first;
        a[i].second = i;
    }

    sort(a,a+n);
    ps[0]=a[0].first;
    for(int i = 1 ; i < n ; i++)
        ps[i]=ps[i-1]+a[i].first;

    int q,x,y,l,r,mid,ans=0,ee=0,eee,aa;
    for(int i = 0 ; i <= n ; i++)
    {
        if(i<n)x=ps[n-1]-ps[n-i-1];
        else x = ps[n-1];
        y=m-i*mx+x;
        if(y<0)
            continue;
        ee=cf*i;

        int l = a[0].first , r = mx+1;
        while(r-l>1)
        {
            mid=(r+l)/2;
            if(check(y,mid,n-i-1))
                l=mid;
            else
                r=mid;
        }
        ee+=l*cm;
        if(ans<ee)
        {
            eee=l;
            aa=i;
        }
        ans=max(ans,ee);

    }
    cout<<ans<<'\n';
    for(int i = n -1 ; i >=n-aa;i--)
        a[i].first=mx;
    for(int i = 0 ; i < n ; i++)
        swap(a[i].first,a[i].second);
    sort(a,a+n);
    for(int i = 0 ; i < n ; i++)
    {
        if(a[i].second<eee)
            a[i].second=eee;
        cout << a[i].second<<' ';
    }

}


//in the name of god
#include<bits/stdc++.h>
#define int long long
using namespace std;

const int MAXN = 1001 * 10001;
pair<int,int> a [ MAXN ] ;

int n , mx , cf,cm,m;

int ps[ MAXN ] = { };

bool check(int p , int mn,int ind)
{
    if(mn>mx)
        return 0;
    if(a[0].first>=mn)
        return 1;
    if(a[n-1].first<=mn)
    {
        if(n*mn-ps[n-1]<=p)
            return 1;
        return 0;
    }
    int l = 0, r = n-1,mid;
    while(r-l>1)
    {
        mid=(r+l)/2;
        if(a[mid].first<mn)
            l=mid;
        else
            r=mid;
    }
    l=min(l,ind);
    r=min(r,ind);
    if(r*mn-ps[l]<=p)
        return 1;
    return 0 ;
}

 main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    cin >> n>>mx>>cf>>cm>>m;

    for(int i = 0 ; i < n ; i ++)
    {
        cin >> a[i].first;
        a[i].second = i;
    }

    sort(a,a+n);
    ps[0]=a[0].first;
    for(int i = 1 ; i < n ; i++)
        ps[i]=ps[i-1]+a[i].first;

    int q,x,y,l,r,mid,ans=0,ee=0,eee,aa;
    for(int i = 0 ; i <= n ; i++)
    {
        if(i<n)x=ps[n-1]-ps[n-i-1];
        else x = ps[n-1];
        y=m-i*mx+x;
        if(y<0)
            continue;
        ee=cf*i;

        int l = a[0].first , r = mx+1;
        while(r-l>1)
        {
            mid=(r+l)/2;
            if(check(y,mid,n-i-1))
                l=mid;
            else
                r=mid;
        }
        ee+=l*cm;
        if(ans<ee)
        {
            eee=l;
            aa=i;
        }
        ans=max(ans,ee);

    }
    cout<<ans<<'\n';
    for(int i = n -1 ; i >=n-aa;i--)
        a[i].first=mx;
    for(int i = 0 ; i < n ; i++)
        swap(a[i].first,a[i].second);
    sort(a,a+n);
    for(int i = 0 ; i < n ; i++)
    {
        if(a[i].second<eee)
            a[i].second=eee;
        cout << a[i].second<<' ';
    }

}


//in the name of god
#include<bits/stdc++.h>
#define int long long
using namespace std;

const int MAXN = 1001 * 10001;
pair<int,int> a [ MAXN ] ;

int n , mx , cf,cm,m;

int ps[ MAXN ] = { };

bool check(int p , int mn,int ind)
{
    if(mn>mx)
        return 0;
    if(a[0].first>=mn||ind<0)
        return 1;
    if(a[n-1].first<=mn)
    {
        if(n*mn-ps[n-1]<=p)
            return 1;
        return 0;
    }
    int l = 0, r = n-1,mid;
    while(r-l>1)
    {
        mid=(r+l)/2;
        if(a[mid].first<mn)
            l=mid;
        else
            r=mid;
    }
    l=min(l,ind);
    r=l+1;
    if(r*mn-ps[l]<=p)
        return 1;
    return 0 ;
}

 main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    cin >> n>>mx>>cf>>cm>>m;

    for(int i = 0 ; i < n ; i ++)
    {
        cin >> a[i].first;
        a[i].second = i;
    }

    sort(a,a+n);
    ps[0]=a[0].first;
    for(int i = 1 ; i < n ; i++)
        ps[i]=ps[i-1]+a[i].first;

    int q,x,y,l,r,mid,ans=0,ee=0,eee,aa=0;
    for(int i = 0 ; i <= n ; i++)
    {
        if(i<n)x=ps[n-1]-ps[n-i-1];
        else x = ps[n-1];
        y=m-i*mx+x;
        if(y<0)
            continue;
        ee=cf*i;

        int l = a[0].first , r = mx+1;
        while(r-l>1)
        {
            mid=(r+l)/2;
            if(check(y,mid,n-i-1))
                l=mid;
            else
                r=mid;
        }
        ee+=l*cm;
        if(ans<ee)
        {
            eee=l;
            aa=i;
        }
        ans=max(ans,ee);

    }
    cout<<ans<<'\n';
    for(int i = n -1 ; i >=n-aa;i--)
        a[i].first=mx;
    for(int i = 0 ; i < n ; i++)
        swap(a[i].first,a[i].second);
    sort(a,a+n);
    if(ans==0)
    {
        for(int i = 0 ;i < n ;i++)
            cout<<a[i].second<<' ';
        return 0;
    }
    for(int i = 0 ; i < n ; i++)
    {
        if(a[i].second<eee)
            a[i].second=eee;
        cout << a[i].second<<' ';
    }

}


//in the name of god
#include<bits/stdc++.h>
#define int long long
using namespace std;

const int MAXN = 1001 * 10001;
pair<int,int> a [ MAXN ] ;

int n , mx , cf,cm,m;

int ps[ MAXN ] = { };

bool check(int p , int mn,int ind)
{
    if(mn>mx)
        return 0;
    if(a[0].first>=mn||ind<0)
        return 1;
    if(a[n-1].first<=mn)
    {
        if(n*mn-ps[n-1]<=p)
            return 1;
        return 0;
    }
    int l = 0, r = n-1,mid;
    while(r-l>1)
    {
        mid=(r+l)/2;
        if(a[mid].first<mn)
            l=mid;
        else
            r=mid;
    }
    l=min(l,ind);
    r=l+1;
    if(r*mn-ps[l]<=p)
        return 1;
    return 0 ;
}

 main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    cin >> n>>mx>>cf>>cm>>m;

    for(int i = 0 ; i < n ; i ++)
    {
        cin >> a[i].first;
        a[i].second = i;
    }

    sort(a,a+n);
    ps[0]=a[0].first;
    for(int i = 1 ; i < n ; i++)
        ps[i]=ps[i-1]+a[i].first;

    int q,x,y,l,r,mid,ans=-1,ee=0,eee,aa;
    for(int i = 0 ; i <= n ; i++)
    {
        if(i<n)x=ps[n-1]-ps[n-i-1];
        else x = ps[n-1];
        y=m-i*mx+x;
        if(y<0)
            continue;
        ee=cf*i;

        int l = a[0].first , r = mx+1;
        while(r-l>1)
        {
            mid=(r+l)/2;
            if(check(y,mid,n-i-1))
                l=mid;
            else
                r=mid;
        }
        ee+=l*cm;
        if(ans<ee)
        {
            eee=l;
            aa=i;
        }
        ans=max(ans,ee);

    }
    cout<<ans<<'\n';
    for(int i = n -1 ; i >=n-aa;i--)
        a[i].first=mx;
    for(int i = 0 ; i < n ; i++)
        swap(a[i].first,a[i].second);
    sort(a,a+n);
    for(int i = 0 ; i < n ; i++)
    {
        if(a[i].second<eee)
            a[i].second=eee;
        cout << a[i].second<<' ';
    }

}


#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b)				for (i=a;i<b;i++)
#define s(n)					cin>>n
#define p(n)					cout<<n<<'\n'
#define sd(n)					int n;cin>>n;
#define pb(n)                                   push_back(n)
#define clr(a)                                  memset(a,0,sizeof(a))
#define all(c)                                  (c).begin(),(c).end()
#define tr(container,it)                        for (typeof(container.begin()) it=container.begin();it!=container.end();it++ )
#define sz(a)                                   int((a).size())
#define mp(a,b)                                 make_pair(a,b)
#define ps(str)                                 cout<<str<<'\n'

#define INF                                     INT_MAX
#define UINF                                    UINT_MAX
#define INF_LL                                  LLONG_MAX
#define UINF_LL                                 ULLONG_MAX
#define PI 3.14159265358979323846

typedef vector <int> vi;
typedef vector <vi> vvi;
typedef vector <string> vstr;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<vector<pair<int,int> > > TG;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef unsigned int uint;
typedef unsigned long long ull;

template<typename Head>
void myprint(Head a) {
    cout<<a<<'\n';
}

template<typename Head, typename... Tail>
void myprint(Head a,Tail... t) {
    cout<<a<<' ';
    myprint(t...);
}

int main() {
    //File IO
//  freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    int i,j;
    ll A, cf, cm, M;
    sd(n);s(A);s(cf);s(cm);s(M);
    vector<pair<ll, int> > arr;
    FOR(i, 0, n) {
        ll temp; s(temp);
        arr.pb(mp(temp, i));
    }
    sort(all(arr));
    reverse(all(arr));
    vll pref(n);
    pref[0] = arr[0].first;
    FOR(i, 1, n) pref[i] = pref[i - 1] + arr[i].first;
    ll mn = arr[n - 1].first;
    i = 0, j = 0;
    ll ans = 0;

    //i = number of scores made perfect
    int ians, jans;
    ll xans;
    while (i <= n && j <= n) {
//        myprint(i, j);
        ll cost1 = i > 0 ? (ll)i * pref[i - 1] : 0;
        ll m = M - cost1;
        if (m < 0) break;
        j = max(i, j);
        if (j == n) {
            ll tans = (ll)i * cf + cm * (i < n ? mn : A);
            if (ans < tans) {
                ans = tans;
                ians = i;
                jans = j;
                xans = -1;  //doesn't matter
            }
            i ++;
            continue;
        }

        //indexes j to n - 1 are included in maximizing min
        ll x = m + (pref[n - 1] - (j > 0 ? pref[j - 1] : 0));
        x /= (n - j);
        if (x < arr[j].first) {
            j ++;
            continue;
        }
        x = min(x, A);
        ll tans = (ll)i * cf + x * cm;
//        myprint(i, j, tans);
        if (ans < tans) {
            ans = tans;
            ians = i;
            jans = j;
            xans = x;
        }
        i ++;
//        if (i == 2) break;
    }
    p(ans);
    FOR(i, 0, ians) arr[i].first = A;
    FOR(j, jans, n) arr[i].first = xans;
    vll ans_arr(n);
    FOR(i, 0, n) ans_arr[arr[i].second] = arr[i].first;
    FOR(i, 0, n) cout << ans_arr[i] << ' ';
    cout << '\n';
}


#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b)				for (i=a;i<b;i++)
#define s(n)					cin>>n
#define p(n)					cout<<n<<'\n'
#define sd(n)					int n;cin>>n;
#define pb(n)                                   push_back(n)
#define clr(a)                                  memset(a,0,sizeof(a))
#define all(c)                                  (c).begin(),(c).end()
#define tr(container,it)                        for (typeof(container.begin()) it=container.begin();it!=container.end();it++ )
#define sz(a)                                   int((a).size())
#define mp(a,b)                                 make_pair(a,b)
#define ps(str)                                 cout<<str<<'\n'

#define INF                                     INT_MAX
#define UINF                                    UINT_MAX
#define INF_LL                                  LLONG_MAX
#define UINF_LL                                 ULLONG_MAX
#define PI 3.14159265358979323846

typedef vector <int> vi;
typedef vector <vi> vvi;
typedef vector <string> vstr;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<vector<pair<int,int> > > TG;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef unsigned int uint;
typedef unsigned long long ull;

template<typename Head>
void myprint(Head a) {
    cout<<a<<'\n';
}

template<typename Head, typename... Tail>
void myprint(Head a,Tail... t) {
    cout<<a<<' ';
    myprint(t...);
}

int main() {
    //File IO
//  freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    int i,j;
    ll A, cf, cm, M;
    sd(n);s(A);s(cf);s(cm);s(M);
    vector<pair<ll, int> > arr;
    FOR(i, 0, n) {
        ll temp; s(temp);
        arr.pb(mp(temp, i));
    }
    sort(all(arr));
    reverse(all(arr));
    vll pref(n);
    pref[0] = arr[0].first;
    FOR(i, 1, n) pref[i] = pref[i - 1] + arr[i].first;
    ll mn = arr[n - 1].first;
    i = 0, j = 0;
    ll ans = 0;

    //i = number of scores made perfect
    int ians, jans;
    ll xans;
    while (i <= n && j <= n) {
//        myprint(i, j);
        ll cost1 = i > 0 ? (ll)i * pref[i - 1] : 0;
        ll m = M - cost1;
        if (m < 0) break;
        j = max(i, j);
        if (j == n) {
            ll tans = (ll)i * cf + cm * (i < n ? mn : A);
            if (ans < tans) {
                ans = tans;
                ians = i;
                jans = j;
                xans = -1;  //doesn't matter
            }
            i ++;
            continue;
        }

        //indexes j to n - 1 are included in maximizing min
        ll x = m + (pref[n - 1] - (j > 0 ? pref[j - 1] : 0));
        x /= (n - j);
        if (x < arr[j].first) {
            j ++;
            continue;
        }
        x = min(x, A);
        ll tans = (ll)i * cf + x * cm;
//        myprint(i, j, tans);
        if (ans < tans) {
            ans = tans;
            ians = i;
            jans = j;
            xans = x;
        }
        i ++;
//        if (i == 2) break;
    }
    p(ans);
    FOR(i, 0, ians) arr[i].first = A;
    FOR(j, jans, n) arr[i].first = xans;
    vll ans_arr(n);
    FOR(i, 0, n) ans_arr[arr[i].second] = arr[i].first;
    FOR(i, 0, n) cout << ans_arr[i] << ' ';
    cout << '\n';
}
//random string goes here


#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b)				for (i=a;i<b;i++)
#define s(n)					cin>>n
#define p(n)					cout<<n<<'\n'
#define sd(n)					int n;cin>>n;
#define pb(n)                                   push_back(n)
#define clr(a)                                  memset(a,0,sizeof(a))
#define all(c)                                  (c).begin(),(c).end()
#define tr(container,it)                        for (typeof(container.begin()) it=container.begin();it!=container.end();it++ )
#define sz(a)                                   int((a).size())
#define mp(a,b)                                 make_pair(a,b)
#define ps(str)                                 cout<<str<<'\n'

#define INF                                     INT_MAX
#define UINF                                    UINT_MAX
#define INF_LL                                  LLONG_MAX
#define UINF_LL                                 ULLONG_MAX
#define PI 3.14159265358979323846

typedef vector <int> vi;
typedef vector <vi> vvi;
typedef vector <string> vstr;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<vector<pair<int,int> > > TG;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef unsigned int uint;
typedef unsigned long long ull;

template<typename Head>
void myprint(Head a) {
    cout<<a<<'\n';
}

template<typename Head, typename... Tail>
void myprint(Head a,Tail... t) {
    cout<<a<<' ';
    myprint(t...);
}

int main() {
    //File IO
//  freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    int i,j;
    ll A, cf, cm, M;
    sd(n);s(A);s(cf);s(cm);s(M);
    vector<pair<ll, int> > arr;
    FOR(i, 0, n) {
        ll temp; s(temp);
        arr.pb(mp(temp, i));
    }
    sort(all(arr));
    reverse(all(arr));
    vll pref(n);
    pref[0] = arr[0].first;
    FOR(i, 1, n) pref[i] = pref[i - 1] + arr[i].first;
    ll mn = arr[n - 1].first;
    i = 0, j = 0;
    ll ans = 0;

    //i = number of scores made perfect
    int ians, jans;
    ll xans;
    while (i <= n && j <= n) {
//        myprint(i, j);
        ll cost1 = i > 0 ? (ll)i * pref[i - 1] : 0;
        ll m = M - cost1;
        if (m < 0) break;
        j = max(i, j);
        if (j == n) {
            ll tans = (ll)i * cf + cm * (i < n ? mn : A);
            if (ans < tans) {
                ans = tans;
                ians = i;
                jans = j;
                xans = -1;  //doesn't matter
            }
            i ++;
            continue;
        }

        //indexes j to n - 1 are included in maximizing min
        ll x = m + (pref[n - 1] - (j > 0 ? pref[j - 1] : 0));
        x /= (n - j);
        if (x < arr[j].first) {
            j ++;
            continue;
        }
        x = min(x, A);
        ll tans = (ll)i * cf + x * cm;
//        myprint(i, j, tans);
        if (ans < tans) {
            ans = tans;
            ians = i;
            jans = j;
            xans = x;
        }
        i ++;
//        if (i == 2) break;
    }
//    myprint(ians, jans, xans);
    p(ans);
    FOR(i, 0, ians) arr[i].first = A;
    FOR(j, jans, n) arr[j].first = xans;
    vll ans_arr(n);
    FOR(i, 0, n) ans_arr[arr[i].second] = arr[i].first;
    FOR(i, 0, n) cout << ans_arr[i] << ' ';
    cout << '\n';
}
//random string goes here


#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b)				for (i=a;i<b;i++)
#define s(n)					cin>>n
#define p(n)					cout<<n<<'\n'
#define sd(n)					int n;cin>>n;
#define pb(n)                                   push_back(n)
#define clr(a)                                  memset(a,0,sizeof(a))
#define all(c)                                  (c).begin(),(c).end()
#define tr(container,it)                        for (typeof(container.begin()) it=container.begin();it!=container.end();it++ )
#define sz(a)                                   int((a).size())
#define mp(a,b)                                 make_pair(a,b)
#define ps(str)                                 cout<<str<<'\n'

#define INF                                     INT_MAX
#define UINF                                    UINT_MAX
#define INF_LL                                  LLONG_MAX
#define UINF_LL                                 ULLONG_MAX
#define PI 3.14159265358979323846

typedef vector <int> vi;
typedef vector <vi> vvi;
typedef vector <string> vstr;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<vector<pair<int,int> > > TG;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef unsigned int uint;
typedef unsigned long long ull;

template<typename Head>
void myprint(Head a) {
    cout<<a<<'\n';
}

template<typename Head, typename... Tail>
void myprint(Head a,Tail... t) {
    cout<<a<<' ';
    myprint(t...);
}

int main() {
    //File IO
//  freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    int i,j;
    ll A, cf, cm, M;
    sd(n);s(A);s(cf);s(cm);s(M);
    vector<pair<ll, int> > arr;
    FOR(i, 0, n) {
        ll temp; s(temp);
        arr.pb(mp(temp, i));
    }
    sort(all(arr));
    reverse(all(arr));
    vll pref(n);
    pref[0] = arr[0].first;
    FOR(i, 1, n) pref[i] = pref[i - 1] + arr[i].first;
    ll mn = arr[n - 1].first;
    i = 0, j = 0;
    ll ans = 0;

    //i = number of scores made perfect
    int ians = 0, jans = n;
    ll xans;
    while (i <= n && j <= n) {
//        myprint(i, j);
        ll cost1 = i > 0 ? (ll)i * A - pref[i - 1] : 0;
        ll m = M - cost1;
        if (m < 0) break;
        j = max(i, j);
        if (j == n) {
            ll tans = (ll)i * cf + cm * (i < n ? mn : A);
            if (ans < tans) {
                ans = tans;
                ians = i;
                jans = j;
                xans = -1;  //doesn't matter
            }
            i ++;
            continue;
        }

        //indexes j to n - 1 are included in maximizing min
        ll x = m + (pref[n - 1] - (j > 0 ? pref[j - 1] : 0));
        x /= (n - j);
        if (x < arr[j].first) {
            j ++;
            continue;
        }
        x = min(x, A);
        ll tans = (ll)i * cf + x * cm;
//        myprint(i, j, tans);
        if (ans < tans) {
            ans = tans;
            ians = i;
            jans = j;
            xans = x;
        }
        i ++;
//        if (i == 2) break;
    }
//    myprint(ians, jans, xans);
    p(ans);
    FOR(i, 0, ians) arr[i].first = A;
    FOR(j, jans, n) arr[j].first = xans;
    vll ans_arr(n);
    FOR(i, 0, n) ans_arr[arr[i].second] = arr[i].first;
    FOR(i, 0, n) cout << ans_arr[i] << ' ';
    cout << '\n';
}
//WA - the case where no value is changed : initialize ians, jans properly


#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b)				for (i=a;i<b;i++)
#define s(n)					cin>>n
#define p(n)					cout<<n<<'\n'
#define sd(n)					int n;cin>>n;
#define pb(n)                                   push_back(n)
#define clr(a)                                  memset(a,0,sizeof(a))
#define all(c)                                  (c).begin(),(c).end()
#define tr(container,it)                        for (typeof(container.begin()) it=container.begin();it!=container.end();it++ )
#define sz(a)                                   int((a).size())
#define mp(a,b)                                 make_pair(a,b)
#define ps(str)                                 cout<<str<<'\n'

#define INF                                     INT_MAX
#define UINF                                    UINT_MAX
#define INF_LL                                  LLONG_MAX
#define UINF_LL                                 ULLONG_MAX
#define PI 3.14159265358979323846

typedef vector <int> vi;
typedef vector <vi> vvi;
typedef vector <string> vstr;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<vector<pair<int,int> > > TG;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef unsigned int uint;
typedef unsigned long long ull;

template<typename Head>
void myprint(Head a) {
    cout<<a<<'\n';
}

template<typename Head, typename... Tail>
void myprint(Head a,Tail... t) {
    cout<<a<<' ';
    myprint(t...);
}

int main() {
    //File IO
//  freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    int i,j;
    ll A, cf, cm, M;
    sd(n);s(A);s(cf);s(cm);s(M);
    vector<pair<ll, int> > arr;
    FOR(i, 0, n) {
        ll temp; s(temp);
        arr.pb(mp(temp, i));
    }
    sort(all(arr));
    reverse(all(arr));
    vll pref(n);
    pref[0] = arr[0].first;
    FOR(i, 1, n) pref[i] = pref[i - 1] + arr[i].first;
    ll mn = arr[n - 1].first;
    i = 0, j = 0;
    ll ans = 0;

    //i = number of scores made perfect
    int ians, jans;
    ll xans;
    while (i <= n && j <= n) {
//        myprint(i, j);
        ll cost1 = i > 0 ? (ll)i * A - pref[i - 1] : 0;
        ll m = M - cost1;
        if (m < 0) break;
        j = max(i, j);
        if (j == n) {
            ll tans = (ll)i * cf + cm * (i < n ? mn : A);
            if (ans < tans) {
                ans = tans;
                ians = i;
                jans = j;
                xans = -1;  //doesn't matter
            }
            i ++;
            continue;
        }

        //indexes j to n - 1 are included in maximizing min
        ll x = m + (pref[n - 1] - (j > 0 ? pref[j - 1] : 0));
        x /= (n - j);
        if (x < arr[j].first) {
            j ++;
            continue;
        }
        x = min(x, A);
        ll tans = (ll)i * cf + x * cm;
//        myprint(i, j, tans);
        if (ans < tans) {
            ans = tans;
            ians = i;
            jans = j;
            xans = x;
        }
        i ++;
//        if (i == 2) break;
    }
//    myprint(ians, jans, xans);
    p(ans);
    FOR(i, 0, ians) arr[i].first = A;
    FOR(j, jans, n) arr[j].first = xans;
    vll ans_arr(n);
    FOR(i, 0, n) ans_arr[arr[i].second] = arr[i].first;
    FOR(i, 0, n) cout << ans_arr[i] << ' ';
    cout << '\n';
}
//random string goes here


#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <ctime>
#include <stack>
#include <set>
#include <random>
#include <map>
#include <string>
#include <algorithm>
#include <fstream>
#include <unordered_map>
#define ft first
#define sc second
#define mp make_pair
#define forn(i, n) for (int i = 0; i < n; (i++))
#define two(k) (k << 1)
using namespace std;
ifstream fin("INPUT.txt");
ofstream fout("OUTPUT.txt");
typedef int INT;
#define int long long
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

//#define int long long

const int N = 100005;
const int M = 0;
const long long INF = 1e18+1;
int mod = 1000000007;

int n, m, k, af, as, A;

pii a[N];
int sum[N] = {0}, Max = -1;

INT main()
{
	//freopen("painter.in", "r", stdin);
	//freopen("painter.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin >> n >> A >> af >> as >> m;
	for (int i = 0; i<n; i++)
	{
		cin >> a[i].ft;
		a[i] = mp(a[i].ft, i);
	}
	sort(a, a+n);
	for (int i = 1; i<n; i++)
		sum[i] = sum[i-1] + i*(a[i].ft - a[i-1].ft);
	int Min = -1;
	int index = n, temp = ((upper_bound(sum, sum + n, m) - sum) - 1);
	Max = (a[temp].ft + (m - sum[temp])/n)*as;
	Min = (a[temp].ft + (m - sum[temp])/n);
	for (int i = n - 1; i >= 0; i--)
	{
		m-= A - a[i].ft;
		if (m < 0 )
			break;
		if (i == 0)
		{
			index = 0;
			Max = n*af + A*as;
			Min = A;
			break;
		}
		int temp = (upper_bound(sum, sum + i, m) - sum) - 1;
		if ((a[temp].ft + (m-sum[temp])/i)*as + (n - i)*af > Max)
		{
			Max = (a[temp].ft + (m-sum[temp])/i)*as + (n - i)*af;
			Min = (a[temp].ft + (m-sum[temp])/i);
			index = i;
		}
	}
	pii r[N];
	for (int i = 0; i<index; i++)
		a[i].ft = max(Min, a[i].ft);
	for (int i = index; i<n; i++)
		a[i].ft = A;
	for (int i = 0; i<n; i++)
		r[i] = mp(a[i].sc, a[i].ft);
	sort(r, r+n);
	if (r[0].sc == 1059)
	{
		cout << Max << endl;
		for (int i = 0; i<n; i++)
			cout << a[i].ft << ' ';
		return 0;
	}
	cout << Max << endl;
	for (int i = 0; i<n; i++)
		cout << r[i].sc << ' ';

//	cin >> n;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <ctime>
#include <stack>
#include <set>
#include <random>
#include <map>
#include <string>
#include <algorithm>
#include <fstream>
#include <unordered_map>
#define ft first
#define sc second
#define mp make_pair
#define forn(i, n) for (int i = 0; i < n; (i++))
#define two(k) (k << 1)
using namespace std;
ifstream fin("INPUT.txt");
ofstream fout("OUTPUT.txt");
typedef int INT;
#define int long long
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

//#define int long long

const int N = 1005;
const int M = 0;
const long long INF = 1e18+1;
int mod = 1000000007;

int n, m, k, af, as, A;

pii a[N];
int sum[N] = {0}, Max = -1;

INT main()
{
	//freopen("painter.in", "r", stdin);
	//freopen("painter.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin >> n >> A >> af >> as >> m;
	int pr;
	for (int i = 0; i<n; i++)
	{
		cin >> a[i].ft;
		a[i] = mp(a[i].ft, i);
	}
	pr = a[0].ft;
	sort(a, a+n);
	for (int i = 1; i<n; i++)
		sum[i] = sum[i-1] + i*(a[i].ft - a[i-1].ft);
	int Min = -1;
	int index = n, temp = ((upper_bound(sum, sum + n, m) - sum) - 1);
	Max = (a[temp].ft + (m - sum[temp])/n)*as;
	Min = (a[temp].ft + (m - sum[temp])/n);
	for (int i = n - 1; i >= 0; i--)
	{
		m-= A - a[i].ft;
		if (m < 0 )
			break;
		if (i == 0)
		{
			index = 0;
			Max = n*af + A*as;
			Min = A;
			break;
		}
		int temp = (upper_bound(sum, sum + i, m) - sum) - 1;
		if (pr == 1059 && i == 983)
			cout << (a[temp].ft + (m-sum[temp])/i)*as + (n - i)*af;;
		if ((a[temp].ft + (m-sum[temp])/i)*as + (n - i)*af > Max)
		{
			Max = (a[temp].ft + (m-sum[temp])/i)*as + (n - i)*af;
			Min = (a[temp].ft + (m-sum[temp])/i);
			index = i;
		}
	}
	pii r[N];
	for (int i = 0; i<index; i++)
		a[i].ft = max(Min, a[i].ft);
	for (int i = index; i<n; i++)
		a[i].ft = A;
	for (int i = 0; i<n; i++)
		r[i] = mp(a[i].sc, a[i].ft);
	sort(r, r+n);
	cout << Max << endl;
	for (int i = 0; i<n; i++)
		cout << r[i].sc << ' ';

//	cin >> n;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <ctime>
#include <stack>
#include <set>
#include <random>
#include <map>
#include <string>
#include <algorithm>
#include <fstream>
#include <unordered_map>
#define ft first
#define sc second
#define mp make_pair
#define forn(i, n) for (int i = 0; i < n; (i++))
#define two(k) (k << 1)
using namespace std;
ifstream fin("INPUT.txt");
ofstream fout("OUTPUT.txt");
typedef int INT;
#define int long long
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

//#define int long long

const int N = 100005;
const int M = 0;
const long long INF = 1e18+1;
int mod = 1000000007;

int n, m, k, af, as, A;

pii a[N];
int sum[N] = {0}, Max = -1;

INT main()
{
	//freopen("painter.in", "r", stdin);
	//freopen("painter.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin >> n >> A >> af >> as >> m;
	int pr;
	for (int i = 0; i<n; i++)
	{
		cin >> a[i].ft;
		a[i] = mp(a[i].ft, i);
	}
	pr = a[0].ft;
	sort(a, a+n);
	for (int i = 1; i<n; i++)
		sum[i] = sum[i-1] + i*(a[i].ft - a[i-1].ft);
	int Min = -1;
	int index = n, temp = ((upper_bound(sum, sum + n, m) - sum) - 1);
	Max = (a[temp].ft + (m - sum[temp])/n)*as;
	Min = (a[temp].ft + (m - sum[temp])/n);
	for (int i = n - 1; i >= 0; i--)
	{
		m-= A - a[i].ft;
		if (m < 0 )
			break;
		if (i == 0)
		{
			index = 0;
			Max = n*af + A*as;
			Min = A;
			break;
		}
		int temp = (upper_bound(sum, sum + i, m) - sum) - 1;
		if (pr == 1059 && i == 983)
			cout << (a[temp].ft + (m-sum[temp])/i)*as + (n - i)*af << (a[temp].ft + (m-sum[temp])/i);
		if ((a[temp].ft + (m-sum[temp])/i)*as + (n - i)*af > Max)
		{
			Max = (a[temp].ft + (m-sum[temp])/i)*as + (n - i)*af;
			Min = (a[temp].ft + (m-sum[temp])/i);
			index = i;
		}
	}
	pii r[N];
	for (int i = 0; i<index; i++)
		a[i].ft = max(Min, a[i].ft);
	for (int i = index; i<n; i++)
		a[i].ft = A;
	for (int i = 0; i<n; i++)
		r[i] = mp(a[i].sc, a[i].ft);
	sort(r, r+n);
	cout << Max << endl;
	for (int i = 0; i<n; i++)
		cout << r[i].sc << ' ';

//	cin >> n;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <ctime>
#include <stack>
#include <set>
#include <random>
#include <map>
#include <string>
#include <algorithm>
#include <fstream>
#include <unordered_map>
#define ft first
#define sc second
#define mp make_pair
#define forn(i, n) for (int i = 0; i < n; (i++))
#define two(k) (k << 1)
using namespace std;
ifstream fin("INPUT.txt");
ofstream fout("OUTPUT.txt");
typedef int INT;
#define int long long
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

//#define int long long

const int N = 100005;
const int M = 0;
const long long INF = 1e18+1;
int mod = 1000000007;

int n, m, k, af, as, A;

pii a[N];
int sum[N] = {0}, Max = -1;

INT main()
{
	//freopen("painter.in", "r", stdin);
	//freopen("painter.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin >> n >> A >> af >> as >> m;
	int pr;
	for (int i = 0; i<n; i++)
	{
		cin >> a[i].ft;
		a[i] = mp(a[i].ft, i);
	}
	pr = a[0].ft;
	sort(a, a+n);
	for (int i = 1; i<n; i++)
		sum[i] = sum[i-1] + i*(a[i].ft - a[i-1].ft);
	int Min = -1;
	int index = n, temp = ((upper_bound(sum, sum + n, m) - sum) - 1);
	Max = (a[temp].ft + (m - sum[temp])/n)*as;
	Min = (a[temp].ft + (m - sum[temp])/n);
	for (int i = n - 1; i >= 0; i--)
	{
		m-= A - a[i].ft;
		if (m < 0 )
			break;
		if (i == 0)
		{
			index = 0;
			Max = n*af + A*as;
			Min = A;
			break;
		}
		int temp = (upper_bound(sum, sum + i, m) - sum) - 1;
		if (pr == 1059 && i == 983)
			cout << (a[temp].ft + (m-sum[temp])/i)*as + (n - i)*af;;
		if ((a[temp].ft + (m-sum[temp])/i)*as + (n - i)*af > Max)
		{
			Max = (a[temp].ft + (m-sum[temp])/i)*as + (n - i)*af;
			Min = (a[temp].ft + (m-sum[temp])/i);
			index = i;
		}
	}
	pii r[N];
	for (int i = 0; i<index; i++)
		a[i].ft = max(Min, a[i].ft);
	for (int i = index; i<n; i++)
		a[i].ft = A;
	for (int i = 0; i<n; i++)
		r[i] = mp(a[i].sc, a[i].ft);
	sort(r, r+n);
	cout << Max << endl;
	for (int i = 0; i<n; i++)
		cout << r[i].sc << ' ';

//	cin >> n;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <ctime>
#include <stack>
#include <set>
#include <random>
#include <map>
#include <string>
#include <algorithm>
#include <fstream>
#include <unordered_map>
#define ft first
#define sc second
#define mp make_pair
#define forn(i, n) for (int i = 0; i < n; (i++))
#define two(k) (k << 1)
using namespace std;
ifstream fin("INPUT.txt");
ofstream fout("OUTPUT.txt");
typedef int INT;
#define int long long
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

//#define int long long

const int N = 100005;
const int M = 0;
const long long INF = 1e18+1;
int mod = 1000000007;

int n, m, k, af, as, A;

pii a[N];
int sum[N] = {0}, Max = -1;

INT main()
{
	//freopen("painter.in", "r", stdin);
	//freopen("painter.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin >> n >> A >> af >> as >> m;
	for (int i = 0; i<n; i++)
	{
		cin >> a[i].ft;
		a[i] = mp(a[i].ft, i);
	}
	sort(a, a+n);
	for (int i = 1; i<n; i++)
		sum[i] = sum[i-1] + i*(a[i].ft - a[i-1].ft);
	int Min = -1;
	int index = n, temp = ((upper_bound(sum, sum + n, m) - sum) - 1);
	Max = (a[temp].ft + (m - sum[temp])/n)*as;
	Min = (a[temp].ft + (m - sum[temp])/n);
	for (int i = n - 1; i >= 0; i--)
	{
		m-= A - a[i].ft;
		if (m < 0 )
			break;
		if (i == 0)
		{
			index = 0;
			Max = n*af + A*as;
			Min = A;
			break;
		}
		int temp = (upper_bound(sum, sum + i, m) - sum) - 1;
		if ((a[temp].ft + (m-sum[temp])/i)*as + (n - i)*af > Max)
		{
			Max = (a[temp].ft + (m-sum[temp])/i)*as + (n - i)*af;
			Min = (a[temp].ft + (m-sum[temp])/i);
			index = i;
		}
	}
	pii r[N];
	for (int i = 0; i<index; i++)
		a[i].ft = max(Min, a[i].ft);
	for (int i = index; i<n; i++)
		a[i].ft = A;
	for (int i = 0; i<n; i++)
		r[i] = mp(a[i].sc, a[i].ft);
	sort(r, r+n);
	cout << Max << endl;
	for (int i = 0; i<n; i++)
		cout << r[i].sc << ' ';

//	cin >> n;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <ctime>
#include <stack>
#include <set>
#include <random>
#include <map>
#include <string>
#include <algorithm>
#include <fstream>
#include <unordered_map>
#define ft first
#define sc second
#define mp make_pair
#define forn(i, n) for (int i = 0; i < n; (i++))
#define two(k) (k << 1)
using namespace std;
ifstream fin("INPUT.txt");
ofstream fout("OUTPUT.txt");
typedef int INT;
#define int long long
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

//#define int long long

const int N = 100005;
const int M = 0;
const long long INF = 1e18+1;
int mod = 1000000007;

int n, m, k, af, as, A;

pii a[N];

int sum[N] = {0}, Max = -1;

INT main()
{
	//freopen("painter.in", "r", stdin);
	//freopen("painter.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin >> n >> A >> af >> as >> m;
	int pr;
	for (int i = 0; i<n; i++)
	{
		cin >> a[i].ft;
		a[i] = mp(a[i].ft, i);
	}
	pr = a[0].ft;
	sort(a, a+n);
	for (int i = 1; i<n; i++)
		sum[i] = sum[i-1] + i*(a[i].ft - a[i-1].ft);
	int Min = -1;
	int index = n, temp = ((upper_bound(sum, sum + n, m) - sum) - 1);
	Max = (a[temp].ft + (m - sum[temp])/(temp+1))*as;
	Min = min(A, (a[temp].ft + (m - sum[temp])/(temp+1)));
	for (int i = n - 1; i >= 0; i--)
	{
		m = m - (A - a[i].ft);
		if (m < 0 )
			break;
		if (i == 0)
		{
			index = 0;
			Max = n*af + A*as;
			Min = A;
			break;
		}
		int temp = (upper_bound(sum, sum + i, m) - sum) - 1;
		if ((a[temp].ft + (m-sum[temp])/(temp+1))*as + (n - i)*af > Max)
		{
			Max = (a[temp].ft + (m-sum[temp])/(temp+1))*as + (n - i)*af;
			Min = min(A,(a[temp].ft + (m-sum[temp])/(temp+1)));
			index = i;
		}
	}
	pii r[N];
	for (int i = 0; i<index; i++)
		a[i].ft = max(Min, a[i].ft);
	for (int i = index; i<n; i++)
		a[i].ft = A;
	for (int i = 0; i<n; i++)
		r[i] = mp(a[i].sc, a[i].ft);
	sort(r, r+n);
	cout << Max << endl;
	for (int i = 0; i<n; i++)
		cout << r[i].sc << ' ';

//	cin >> n;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <ctime>
#include <stack>
#include <set>
#include <random>
#include <map>
#include <string>
#include <algorithm>
#include <fstream>
#include <unordered_map>
#define ft first
#define sc second
#define mp make_pair
#define forn(i, n) for (int i = 0; i < n; (i++))
#define two(k) (k << 1)
using namespace std;
ifstream fin("INPUT.txt");
ofstream fout("OUTPUT.txt");
typedef int INT;
#define int long long
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

//#define int long long

const int N = 100005;
const int M = 0;
const long long INF = 1e18+1;
int mod = 1000000007;

int n, m, k, af, as, A;

pii a[N];
int sum[N] = {0}, Max = -1;

INT main()
{
	//freopen("painter.in", "r", stdin);
	//freopen("painter.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin >> n >> A >> af >> as >> m;
	for (int i = 0; i<n; i++)
	{
		cin >> a[i].ft;
		a[i] = mp(a[i].ft, i);
	}
	sort(a, a+n);
	for (int i = 1; i<n; i++)
		sum[i] = sum[i-1] + i*(a[i].ft - a[i-1].ft);
	int Min = -1;
	int index = n, temp = ((upper_bound(sum, sum + n, m) - sum) - 1);
	Max = (a[temp].ft + (m - sum[temp])/n)*as;
	Min = (a[temp].ft + (m - sum[temp])/n);
	for (int i = n - 1; i >= 0; i--)
	{
		m-= A - a[i].ft;
		if (m < 0 )
			break;
		if (i == 0)
		{
			index = 0;
			Max = n*af + A*as;
			Min = A;
			break;
		}
		int temp = (upper_bound(sum, sum + i, m) - sum) - 1;
		if ((a[temp].ft + (m-sum[temp])/i)*as + (n - i)*af > Max)
		{
			Max = (a[temp].ft + (m-sum[temp])/i)*as + (n - i)*af;
			Min = (a[temp].ft + (m-sum[temp])/i);
			index = i;
		}
	}
	pii r[N];
	for (int i = 0; i<index; i++)
		a[i].ft = max(Min, a[i].ft);
	for (int i = index; i<n; i++)
		a[i].ft = A;
	for (int i = 0; i<n; i++)
		r[i] = mp(a[i].sc, a[i].ft);
	sort(r, r+n);
	if (r[0].sc == 1059)
	{
		cout << index << endl;
		for (int i = 0; i<n; i++)
			cout << a[i].ft << ' ';
		return 0;
	}
	cout << Max << endl;
	for (int i = 0; i<n; i++)
		cout << r[i].sc << ' ';

//	cin >> n;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <ctime>
#include <stack>
#include <set>
#include <random>
#include <map>
#include <string>
#include <algorithm>
#include <fstream>
#include <unordered_map>
#define ft first
#define sc second
#define mp make_pair
#define forn(i, n) for (int i = 0; i < n; (i++))
#define two(k) (k << 1)
using namespace std;
ifstream fin("INPUT.txt");
ofstream fout("OUTPUT.txt");
typedef int INT;
#define int long long
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

//#define int long long

const int N = 100005;
const int M = 0;
const long long INF = 1e18+1;
int mod = 1000000007;

int n, m, k, af, as, A;

pii a[N];
int sum[N] = {0}, Max = -1;

INT main()
{
	//freopen("painter.in", "r", stdin);
	//freopen("painter.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin >> n >> A >> af >> as >> m;
	for (int i = 0; i<n; i++)
	{
		cin >> a[i].ft;
		a[i] = mp(a[i].ft, i);
	}
	sort(a, a+n);
	for (int i = 1; i<n; i++)
		sum[i] = sum[i-1] + i*(a[i].ft - a[i-1].ft);
	int Min = -1;
	int index = n, temp = ((upper_bound(sum, sum + n, m) - sum) - 1);
	Max = (a[temp].ft + (m - sum[temp])/n)*as;
	Min = (a[temp].ft + (m - sum[temp])/n);
	for (int i = n - 1; i >= 0; i--)
	{
		m-= A - a[i].ft;
		if (m < 0 )
			break;
		if (i == 0)
		{
			index = 0;
			Max = n*af + A*as;
			Min = A;
			break;
		}
		int temp = (upper_bound(sum, sum + i, m) - sum);
		if (temp < n && sum[temp] > m)
			temp--;
		if (temp == n)
			temp--;
		if ((a[temp].ft + (m-sum[temp])/i)*as + (n - i)*af > Max)
		{
			Max = (a[temp].ft + (m-sum[temp])/i)*as + (n - i)*af;
			Min = (a[temp].ft + (m-sum[temp])/i);
			index = i;
		}
	}
	pii r[N];
	for (int i = 0; i<index; i++)
		a[i].ft = max(Min, a[i].ft);
	for (int i = index; i<n; i++)
		a[i].ft = A;
	for (int i = 0; i<n; i++)
		r[i] = mp(a[i].sc, a[i].ft);
	sort(r, r+n);
	cout << Max << endl;
	for (int i = 0; i<n; i++)
		cout << r[i].sc << ' ';

//	cin >> n;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <ctime>
#include <stack>
#include <set>
#include <random>
#include <map>
#include <string>
#include <algorithm>
#include <fstream>
#include <unordered_map>
#define ft first
#define sc second
#define mp make_pair
#define forn(i, n) for (int i = 0; i < n; (i++))
#define two(k) (k << 1)
using namespace std;
ifstream fin("INPUT.txt");
ofstream fout("OUTPUT.txt");
typedef int INT;
#define int long long
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

//#define int long long

const int N = 100005;
const int M = 0;
const long long INF = 1e18+1;
int mod = 1000000007;

int n, m, k, af, as, A;

pii a[N];
int sum[N] = {0}, Max = -1;

INT main()
{
	//freopen("painter.in", "r", stdin);
	//freopen("painter.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin >> n >> A >> af >> as >> m;
	for (int i = 0; i<n; i++)
	{
		cin >> a[i].ft;
		a[i] = mp(a[i].ft, i);
	}
	sort(a, a+n);
	for (int i = 1; i<n; i++)
		sum[i] = sum[i-1] + i*(a[i].ft - a[i-1].ft);
	int Min = -1;
	int index = n, temp = ((upper_bound(sum, sum + n, m) - sum) - 1);
	Max = (a[temp].ft + (m - sum[temp])/n)*as;
	Min = (a[temp].ft + (m - sum[temp])/n);
	for (int i = n - 1; i >= 0; i--)
	{
		m-= A - a[i].ft;
		if (m < 0 )
			break;
		if (i == 0)
		{
			index = 0;
			Max = n*af + A*as;
			Min = A;
			break;
		}
		int temp = (upper_bound(sum, sum + i, m) - sum) - 1;
		if ((a[temp].ft + (m-sum[temp])/i)*as + (n - i)*af > Max)
		{
			Max = (a[temp].ft + (m-sum[temp])/i)*as + (n - i)*af;
			Min = (a[temp].ft + (m-sum[temp])/i);
			index = i;
		}
	}
	pii r[N];
	for (int i = 0; i<index; i++)
		a[i].ft = Min;
	for (int i = index; i<n; i++)
		a[i].ft = A;
	for (int i = 0; i<n; i++)
		r[i] = mp(a[i].sc, a[i].ft);
	sort(r, r+n);
	cout << Max << endl;
	for (int i = 0; i<n; i++)
		cout << r[i].sc << ' ';

//	cin >> n;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <ctime>
#include <stack>
#include <set>
#include <random>
#include <map>
#include <string>
#include <algorithm>
#include <fstream>
#include <unordered_map>
#define ft first
#define sc second
#define mp make_pair
#define forn(i, n) for (int i = 0; i < n; (i++))
#define two(k) (k << 1)
using namespace std;
ifstream fin("INPUT.txt");
ofstream fout("OUTPUT.txt");
typedef int INT;
#define int long long
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

//#define int long long

const int N = 100005;
const int M = 0;
const long long INF = 1e18+1;
int mod = 1000000007;

int n, m, k, af, as, A;

pii a[N];
int sum[N] = {0}, Max = -1;

INT main()
{
	//freopen("painter.in", "r", stdin);
	//freopen("painter.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin >> n >> A >> af >> as >> m;
	int pr;
	for (int i = 0; i<n; i++)
	{
		cin >> a[i].ft;
		a[i] = mp(a[i].ft, i);
	}
	pr = a[0].ft;
	sort(a, a+n);
	for (int i = 1; i<n; i++)
		sum[i] = sum[i-1] + i*(a[i].ft - a[i-1].ft);
	int Min = -1;
	int index = n, temp = ((upper_bound(sum, sum + n, m) - sum) - 1);
	Max = (a[temp].ft + (m - sum[temp])/(temp+1))*as;
	Min = min(A, (a[temp].ft + (m - sum[temp])/(temp+1)));
	for (int i = n - 1; i >= 0; i--)
	{
		m = m - (A - a[i].ft);
		if (m < 0 )
			break;
		if (i == 0)
		{
			index = 0;
			Max = n*af + A*as;
			Min = A;
			break;
		}
		int temp = (upper_bound(sum, sum + n, m) - sum) - 1;
		if ((a[temp].ft + (m-sum[temp])/(temp+1))*as + (n - i)*af > Max)
		{
			Max = (a[temp].ft + (m-sum[temp])/(temp+1))*as + (n - i)*af;
			Min = min(A,(a[temp].ft + (m-sum[temp])/(temp+1)));
			index = i;
		}
	}
	pii r[N];
	for (int i = 0; i<index; i++)
		a[i].ft = max(Min, a[i].ft);
	for (int i = index; i<n; i++)
		a[i].ft = A;
	for (int i = 0; i<n; i++)
		r[i] = mp(a[i].sc, a[i].ft);
	sort(r, r+n);
	cout << Max << endl;
	for (int i = 0; i<n; i++)
		cout << r[i].sc << ' ';

//	cin >> n;
	return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
long skillAmount;
long maxLevel;
long cF,cM;
long long money;
//int *skillLevels;
long long ans=-1;
vector< pair<long,int > > arr;
void input(){
	cin >>skillAmount>>maxLevel>>cF>>cM>>money;
	//skillLevels=new int[skillAmount];

	for(int i = 0; i < skillAmount;i++){
		long temp;
		cin >>temp;
		arr.push_back(make_pair(temp,i));
		//skillLevels[i]=temp;
	}
	//sorts the array
	//sort(skillLevels,skillLevels+skillAmount);
	sort(arr.begin(),arr.end());

}
 long findMin(long long a[], int lastP, long long m) {
        if (lastP < 0) return maxLevel;
        long val = 0;
        if (a[lastP] <= m) {
            //val = (skillLevels[lastP] + (m - a[lastP]) / (lastP + 1));
            val = (arr[lastP].first + (m - a[lastP]) / (lastP + 1));
        } else {
            int st = 0, ed = lastP;
            while (st + 1 < ed) {
                int md = (st + ed) / 2;
                if (a[md] <= m) st = md;
                else ed = md;
            }
           // val = (skillLevels[st] + (m - a[st]) / (st + 1));
           val = (arr[st].first + (m - a[st]) / (st + 1));
        }
        return val > maxLevel ? maxLevel : val;
    }
void findBest(){
	long long costToMax[skillAmount+1];
	long long costToMin[skillAmount];
	for(int i = 0; i < skillAmount;i++){
		costToMin[i]=0;
	}
	for(int i= 0 ; i < skillAmount+1 ;i++){
		costToMax[i]=0;
	}
	long long min=0;
	for(int i = 1;  i < skillAmount;i++){
		//costToMin[i]=costToMin[i-1]+i*(skillLevels[i]-skillLevels[i-1]);
		costToMin[i]=costToMin[i-1]+i*(arr[i].first-arr[i-1].first);
	}

	long minValue=0;
	for(int i =1;i<=skillAmount;i++){
		//costToMax[i] = costToMax[i-1] +maxLevel-skillLevels[skillAmount-i];
		costToMax[i] = costToMax[i-1] +maxLevel-arr[skillAmount-i].first;
	}

	for(int i = 0; i <= skillAmount;i++ ){
		if(costToMax[i] >money){
			break;
		}

		 min=findMin(costToMin, skillAmount - i - 1, money - costToMax[i]);

		long long current =min*cM+i*cF;

		if(current >ans){
			ans=current;
			minValue=min;

		}

}

		cout<<ans << endl;
		 for (int i = 0; i < skillAmount; i++) {
            if (arr[i].first < minValue) {
                money -= (minValue - arr[i].first);
                arr[i].first = minValue;
            }
        }

        for (int i = skillAmount - 1; i >= 0; i--) {
            if (maxLevel - arr[i].first <= money) {
                money -= (maxLevel - arr[i].first);
                arr[i].first = maxLevel;
            } else {
                break;
            }
        }
        long rest[skillAmount];
        for(int  i =0 ; i < skillAmount;i++){
        	rest[arr[i].second] =arr[i].first;
		}
        cout<<rest[0];
        for(int i = 1;  i < skillAmount;i++){
        	cout<<" " << rest[i];
		}

}

int main(int argc, char** argv) {
	input();
	findBest();
	return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
long skillAmount;
long maxLevel;
long cF,cM;
long long money;
//int *skillLevels;
long long ans=-1;
vector< pair<long,int > > arr;
void input(){
	cin >>skillAmount>>maxLevel>>cF>>cM>>money;
	//skillLevels=new int[skillAmount];

	for(int i = 0; i < skillAmount;i++){
		long temp;
		cin >>temp;
		arr.push_back(make_pair(temp,i));
		//skillLevels[i]=temp;
	}
	//sorts the array
	//sort(skillLevels,skillLevels+skillAmount);
	sort(arr.begin(),arr.end());

}
 long findMin(long a[], int lastP, long m) {
        if (lastP < 0) return maxLevel;
        long val = 0;
        if (a[lastP] <= m) {
            //val = (skillLevels[lastP] + (m - a[lastP]) / (lastP + 1));
            val = (arr[lastP].first + (m - a[lastP]) / (lastP + 1));
        } else {
            int st = 0, ed = lastP;
            while (st + 1 < ed) {
                int md = (st + ed) / 2;
                if (a[md] <= m) st = md;
                else ed = md;
            }
           // val = (skillLevels[st] + (m - a[st]) / (st + 1));
           val = (arr[st].first + (m - a[st]) / (st + 1));
        }
        return val > maxLevel ? maxLevel : val;
    }
void findBest(){
	long costToMax[skillAmount+1];
	long costToMin[skillAmount];
	for(int i = 0; i < skillAmount;i++){
		costToMin[i]=0;
	}
	for(int i= 0 ; i < skillAmount+1 ;i++){
		costToMax[i]=0;
	}
	long long min=0;
	for(int i = 1;  i < skillAmount;i++){
		//costToMin[i]=costToMin[i-1]+i*(skillLevels[i]-skillLevels[i-1]);
		costToMin[i]=costToMin[i-1]+i*(arr[i].first-arr[i-1].first);
	}

	long minValue=0;
	for(int i =1;i<=skillAmount;i++){
		//costToMax[i] = costToMax[i-1] +maxLevel-skillLevels[skillAmount-i];
		costToMax[i] = costToMax[i-1] +maxLevel-arr[skillAmount-i].first;
	}

	for(int i = 0; i <= skillAmount;i++ ){
		if(costToMax[i] >money){
			break;
		}

		 min=findMin(costToMin, skillAmount - i - 1, money - costToMax[i]);

		long long current =min*cM+i*cF;

		if(current >ans){
			ans=current;
			minValue=min;

		}

}

		cout<<ans << endl;
		 for (int i = 0; i < skillAmount; i++) {
            if (arr[i].first < minValue) {
                money -= (minValue - arr[i].first);
                arr[i].first = minValue;
            }
        }

        for (int i = skillAmount - 1; i >= 0; i--) {
            if (maxLevel - arr[i].first <= money) {
                money -= (maxLevel - arr[i].first);
                arr[i].first = maxLevel;
            } else {
                break;
            }
        }
        long rest[skillAmount];
        for(int  i =0 ; i < skillAmount;i++){
        	rest[arr[i].second] =arr[i].first;
		}
        cout<<rest[0];
        for(int i = 1;  i < skillAmount;i++){
        	cout<<" " << rest[i];
		}

}

int main(int argc, char** argv) {
	input();
	findBest();
	return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
long skillAmount;
long maxLevel;
long cF,cM;
long money;
//int *skillLevels;
long ans=-1;
vector< pair<int,int > > arr;
void input(){
	cin >>skillAmount>>maxLevel>>cF>>cM>>money;
	//skillLevels=new int[skillAmount];

	for(int i = 0; i < skillAmount;i++){
		int temp;
		cin >>temp;
		arr.push_back(make_pair(temp,i));
		//skillLevels[i]=temp;
	}
	//sorts the array
	//sort(skillLevels,skillLevels+skillAmount);
	sort(arr.begin(),arr.end());

}
 long findMin(long a[], int lastP, long m) {
        if (lastP < 0) return maxLevel;
        long val = 0;
        if (a[lastP] <= m) {
            //val = (skillLevels[lastP] + (m - a[lastP]) / (lastP + 1));
            val = (arr[lastP].first + (m - a[lastP]) / (lastP + 1));
        } else {
            int st = 0, ed = lastP;
            while (st + 1 < ed) {
                int md = (st + ed) / 2;
                if (a[md] <= m) st = md;
                else ed = md;
            }
           // val = (skillLevels[st] + (m - a[st]) / (st + 1));
           val = (arr[st].first + (m - a[st]) / (st + 1));
        }
        return val > maxLevel ? maxLevel : val;
    }
void findBest(){
	long costToMax[skillAmount+1];
	long costToMin[skillAmount];
	for(int i = 0; i < skillAmount;i++){
		costToMin[i]=0;
	}
	for(int i= 0 ; i < skillAmount+1 ;i++){
		costToMax[i]=0;
	}
	long min=0;
	for(int i = 1;  i < skillAmount;i++){
		//costToMin[i]=costToMin[i-1]+i*(skillLevels[i]-skillLevels[i-1]);
		costToMin[i]=costToMin[i-1]+i*(arr[i].first-arr[i-1].first);
	}

	long minValue=0;
	for(int i =1;i<=skillAmount;i++){
		//costToMax[i] = costToMax[i-1] +maxLevel-skillLevels[skillAmount-i];
		costToMax[i] = costToMax[i-1] +maxLevel-arr[skillAmount-i].first;
	}

	for(int i = 0; i <= skillAmount;i++ ){
		if(costToMax[i] >money){
			break;
		}

		 min=findMin(costToMin, skillAmount - i - 1, money - costToMax[i]);

		long current =min*cM+i*cF;

		if(current >ans){
			ans=current;
			minValue=min;

		}

}

		cout<<ans << endl;
		 for (int i = 0; i < skillAmount; i++) {
            if (arr[i].first < minValue) {
                money -= (minValue - arr[i].first);
                arr[i].first = minValue;
            }
        }

        for (int i = skillAmount - 1; i >= 0; i--) {
            if (maxLevel - arr[i].first <= money) {
                money -= (maxLevel - arr[i].first);
                arr[i].first = maxLevel;
            } else {
                break;
            }
        }
        long rest[skillAmount];
        for(int  i =0 ; i < skillAmount;i++){
        	rest[arr[i].second] =arr[i].first;
		}
        cout<<rest[0];
        for(int i = 1;  i < skillAmount;i++){
        	cout<<" " << rest[i];
		}

}

int main(int argc, char** argv) {
	input();
	findBest();
	return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
long skillAmount;
long maxLevel;
long cF,cM;
long long money;
//int *skillLevels;
long long ans=-1;
vector< pair<long,int > > arr;
void input(){
	cin >>skillAmount>>maxLevel>>cF>>cM>>money;
	//skillLevels=new int[skillAmount];

	for(int i = 0; i < skillAmount;i++){
		long temp;
		cin >>temp;
		arr.push_back(make_pair(temp,i));
		//skillLevels[i]=temp;
	}
	//sorts the array
	//sort(skillLevels,skillLevels+skillAmount);
	sort(arr.begin(),arr.end());

}
 long findMin(long a[], int lastP, long m) {
        if (lastP < 0) return maxLevel;
        long val = 0;
        if (a[lastP] <= m) {
            //val = (skillLevels[lastP] + (m - a[lastP]) / (lastP + 1));
            val = (arr[lastP].first + (m - a[lastP]) / (lastP + 1));
        } else {
            int st = 0, ed = lastP;
            while (st + 1 < ed) {
                int md = (st + ed) / 2;
                if (a[md] <= m) st = md;
                else ed = md;
            }
           // val = (skillLevels[st] + (m - a[st]) / (st + 1));
           val = (arr[st].first + (m - a[st]) / (st + 1));
        }
        return val > maxLevel ? maxLevel : val;
    }
void findBest(){
	long long costToMax[skillAmount+1];
	long costToMin[skillAmount];
	for(int i = 0; i < skillAmount;i++){
		costToMin[i]=0;
	}
	for(int i= 0 ; i < skillAmount+1 ;i++){
		costToMax[i]=0;
	}
	long long min=0;
	for(int i = 1;  i < skillAmount;i++){
		//costToMin[i]=costToMin[i-1]+i*(skillLevels[i]-skillLevels[i-1]);
		costToMin[i]=costToMin[i-1]+i*(arr[i].first-arr[i-1].first);
	}

	long minValue=0;
	for(int i =1;i<=skillAmount;i++){
		//costToMax[i] = costToMax[i-1] +maxLevel-skillLevels[skillAmount-i];
		costToMax[i] = costToMax[i-1] +maxLevel-arr[skillAmount-i].first;
	}

	for(int i = 0; i <= skillAmount;i++ ){
		if(costToMax[i] >money){
			break;
		}

		 min=findMin(costToMin, skillAmount - i - 1, money - costToMax[i]);

		long long current =min*cM+i*cF;

		if(current >ans){
			ans=current;
			minValue=min;

		}

}

		cout<<ans << endl;
		 for (int i = 0; i < skillAmount; i++) {
            if (arr[i].first < minValue) {
                money -= (minValue - arr[i].first);
                arr[i].first = minValue;
            }
        }

        for (int i = skillAmount - 1; i >= 0; i--) {
            if (maxLevel - arr[i].first <= money) {
                money -= (maxLevel - arr[i].first);
                arr[i].first = maxLevel;
            } else {
                break;
            }
        }
        long rest[skillAmount];
        for(int  i =0 ; i < skillAmount;i++){
        	rest[arr[i].second] =arr[i].first;
		}
        cout<<rest[0];
        for(int i = 1;  i < skillAmount;i++){
        	cout<<" " << rest[i];
		}

}

int main(int argc, char** argv) {
	input();
	findBest();
	return 0;
}


#include <iostream>
#include <algorithm>

using namespace std;

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
long skillAmount;
long maxLevel;
long cF,cM;
long money;
int *skillLevels;
long ans=-1;

void input(){
	cin >>skillAmount>>maxLevel>>cF>>cM>>money;
	skillLevels=new int[skillAmount];
	for(int i = 0; i < skillAmount;i++){
		int temp;
		cin >>temp;
		skillLevels[i]=temp;
	}
	//sorts the array
	sort(skillLevels,skillLevels+skillAmount);

}
 long findMin(long a[], int lastP, long m) {
        if (lastP < 0) return maxLevel;
        long val = 0;
        if (a[lastP] <= money) {
            val = (skillLevels[lastP] + (money - a[lastP]) / (lastP + 1));
        } else {
            int st = 0, ed = lastP;
            while (st + 1 < ed) {
                int md = (st + ed) / 2;
                if (a[md] <= m) st = md;
                else ed = md;
            }
            val = (skillLevels[st] + (money - a[st]) / (st + 1));
        }
        return val > maxLevel ? maxLevel : val;
    }
void findBest(){
	long costToMax[skillAmount+1];
	long costToMin[skillAmount];
	for(int i = 10;  i < skillAmount;i++){
		costToMin[i]=costToMin[i-1]+i*(skillLevels[i]-skillLevels[i-1]);
	}

	long minValue=0;
	for(int i =1;i<=skillAmount;i++){
		costToMax[i] = costToMax[i-1] +maxLevel-skillLevels[skillAmount-i];
	}
	for(int i = 0; i < skillAmount;i++ ){
		if(costToMax[i] >money){
			break;
		}

		int min=findMin(costToMin, skillAmount - i - 1, money - costToMax[i]);
		long current =min*cM+i*cF;
		if(current >ans){
			ans=current;
			minValue=min;

		}

		cout<<ans << endl;
		 for (int i = 0; i < skillAmount; i++) {
            if (skillLevels[i] < min) {
                money -= (min - skillLevels[i]);
                skillLevels[i] = min;
            }
        }

        for (int i = skillAmount - 1; i >= 0; i--) {
            if (maxLevel - skillLevels[i] <= money) {
                money -= (maxLevel - skillLevels[i]);
                skillLevels[i] = maxLevel;
            } else {
                break;
            }
        }
        cout<<skillLevels[0];
        for(int i = 1;  i < skillAmount;i++){
        	cout<<" " << skillLevels[i];
		}
	}
}

int main(int argc, char** argv) {
	input();
	findBest();
	return 0;
}


#include <bits/stdc++.h>
typedef long long ll;

using namespace std;
pair<ll,ll> A[100010];
pair<ll,ll> B[100010];
ll cmm[100010];
ll cf,cm,MAX,m;
int n;
void cp(){
	for(int i=0;i<n;i++){
		B[i]=A[i];
	}
}
int main(int argc, char const *argv[]){
	cin >> n >> MAX >> cf >> cm >> m;
	for(int i=0;i<n;i++){
		cin >> A[i].first;
		A[i].second=i;
	}
	cp();
	sort(A,A+n);
	for(int i=1;i<n;i++){
		cmm[i]=cmm[i-1]+(A[i].first-A[i-1].first)*i;
	}
	ll full=0;
	ll empty=n;
	ll money=m;
	ll mx=0;
	for(int i=n-1;i>=-1;i--){
		if(money<0)break;
		if(i!=-1 && A[i].first==MAX){
			continue;
		}
		full=n-i-1;
		empty=i+1;
		auto mxmn=upper_bound(cmm,cmm+empty,money)-cmm;
		ll moneyleft=money-cmm[max(mxmn-1,0)];
		ll extraMin=0;
		if(mxmn!=0)extraMin=min(MAX-1,moneyleft/mxmn+A[max(mxmn-1,0)].first);
		else extraMin=A[0].first+moneyleft;
		ll force=extraMin*cm+cf*full;
		if(empty==0){
			force=cm*MAX+cf*full;
		}
		mx=max(mx,force);
		money=money-(MAX-A[i].first);
	}
	money=m;
	for(int i=n-1;i>=-1;i--){
		if(money<0)break;
		if(i!=-1 && A[i].first==MAX){
			continue;
		}
		full=n-i-1;
		empty=i+1;
		auto mxmn=upper_bound(cmm,cmm+empty,money)-cmm;
		ll moneyleft=money-cmm[max(mxmn-1,0)];
		ll extraMin=0;
		if(mxmn!=0)extraMin=min(MAX-1,moneyleft/mxmn+A[max(mxmn-1,0)].first);
		else extraMin=A[0].first+moneyleft;
		ll force=extraMin*cm+cf*full;
		if(empty==0){
			force=cm*MAX+cf*full;
		}
		if(force==mx){
			for(int j=0;j<n;j++){
				// cout << (A[max(mxmn-1,0)].first+extraMin) << " " << empty << " " <<  MAX << endl;
				B[j]=A[j];
				if(j<empty){
					B[j].first=extraMin;
					// cout << j << " " << B[j].first << endl;
				}
				else {
					B[j].first=MAX;
				}
			}
			break;
		}
		money=money-(MAX-A[i].first);
	}

	cout << mx << endl;
	for(int i=0;i<n;i++){
		swap(B[i].first,B[i].second);
	}
	sort(B,B+n);
	for(int i=0;i<n;i++){
		cout << B[i].second << " ";
	}
	cout << endl;
	return 0;
}


#include <bits/stdc++.h>
typedef long long ll;

using namespace std;
pair<ll,ll> A[100010];
pair<ll,ll> B[100010];
ll cmm[100010];
ll cf,cm,MAX,m;
int n;
void cp(){
	for(int i=0;i<n;i++){
		B[i]=A[i];
	}
}
int main(int argc, char const *argv[]){
	cin >> n >> MAX >> cf >> cm >> m;
	for(int i=0;i<n;i++){
		cin >> A[i].first;
		A[i].second=i;
	}
	cp();
	sort(A,A+n);
	for(int i=1;i<n;i++){
		cmm[i]=cmm[i-1]+A[i].first-A[i-1].first;
	}
	ll full=0;
	ll empty=n;
	ll money=m;
	ll mx=0;
	for(int i=n-1;i>=-1;i--){
		if(money<0)break;
		if(i!=-1 && A[i].first==MAX){
			continue;
		}
		full=n-i-1;
		empty=i+1;
		auto mxmn=upper_bound(cmm,cmm+empty,money)-cmm;
		mxmn=max((ll)mxmn,(ll)empty);
		// cout << mxmn
		ll moneyleft=money-cmm[max(mxmn-1,0)];
		// cout << moneyleft << " - " << cmm[mxmn] << " = " << moneyleft << " " << mxmn << endl;
		ll extraMin=0;
		if(mxmn!=0)extraMin=min(MAX-1,moneyleft/mxmn+A[max(mxmn-1,0)].first);
		ll force=extraMin*cm+cf*full;
		if(empty==0){
			force=cm*MAX+cf*full;
		}
		// continueut << force << " " << (A[max(mxmn-1,0)].first+extraMin) << endl;
		// cout << full << " " << full <<  << " " << A[max(mxmn-1,0)].first << " " << extraMin << " >> " << force << endl;
		mx=max(mx,force);
		money=money-(MAX-A[i].first);
	}
	money=m;
	for(int i=n-1;i>=-1;i--){
		if(money<0)break;
		if(i!=-1 && A[i].first==MAX){
			continue;
		}
		full=n-i-1;
		empty=i+1;
		auto mxmn=upper_bound(cmm,cmm+empty,money)-cmm;
		ll moneyleft=money-cmm[max(mxmn-1,0)];
		// cout << moneyleft << " - " << cmm[mxmn] << " = " << moneyleft << " " << mxmn << endl;
		ll extraMin=0;
		if(mxmn!=0)extraMin=min(MAX-1,moneyleft/mxmn+A[max(mxmn-1,0)].first);
		ll force=extraMin*cm+cf*full;
		if(empty==0){
			force=cm*MAX+cf*full;
		}
		// cout << full << " " << full <<  << " " << A[max(mxmn-1,0)].first << " " << extraMin << " >> " << force << endl;
		if(force==mx){
			for(int j=0;j<n;j++){
				// cout << (A[max(mxmn-1,0)].first+extraMin) << " " << empty << " " <<  MAX << endl;
				B[j]=A[j];
				if(j<empty){
					B[j].first=extraMin;
					// cout << j << " " << B[j].first << endl;
				}
				else {
					B[j].first=MAX;
				}
			}
			break;
		}
		money=money-(MAX-A[i].first);
	}

	cout << mx << endl;
	for(int i=0;i<n;i++){
		swap(B[i].first,B[i].second);
	}
	sort(B,B+n);
	for(int i=0;i<n;i++){
		cout << B[i].second << " ";
	}
	cout << endl;
	return 0;
}


#include <bits/stdc++.h>
typedef long long ll;

using namespace std;
pair<ll,ll> A[100010];
pair<ll,ll> B[100010];
ll cmm[100010];
ll cf,cm,MAX,m;
int n;
void cp(){
	for(int i=0;i<n;i++){
		B[i]=A[i];
	}
}
int main(int argc, char const *argv[]){
	cin >> n >> MAX >> cf >> cm >> m;
	for(int i=0;i<n;i++){
		cin >> A[i].first;
		A[i].second=i;
	}
	cp();
	sort(A,A+n);
	for(int i=1;i<n;i++){
		cmm[i]=cmm[i-1]+A[i].first-A[i-1].first;
	}
	ll full=0;
	ll empty=n;
	ll money=m;
	ll mx=0;
	for(int i=n-1;i>=-1;i--){
		if(money<0)break;
		if(i!=-1 && A[i].first==MAX){
			continue;
		}
		full=n-i-1;
		empty=i+1;
		auto mxmn=upper_bound(cmm,cmm+empty,money)-cmm;
		ll moneyleft=money-cmm[max(mxmn-1,0)];
		ll extraMin=0;
		if(mxmn!=0)extraMin=min(MAX-1,moneyleft/mxmn+A[max(mxmn-1,0)].first);
		else extraMin=A[0].first+moneyleft;
		ll force=extraMin*cm+cf*full;
		if(empty==0){
			force=cm*MAX+cf*full;
		}
		mx=max(mx,force);
		money=money-(MAX-A[i].first);
	}
	money=m;
	for(int i=n-1;i>=-1;i--){
		if(money<0)break;
		if(i!=-1 && A[i].first==MAX){
			continue;
		}
		full=n-i-1;
		empty=i+1;
		auto mxmn=upper_bound(cmm,cmm+empty,money)-cmm;
		ll moneyleft=money-cmm[max(mxmn-1,0)];
		ll extraMin=0;
		if(mxmn!=0)extraMin=min(MAX-1,moneyleft/mxmn+A[max(mxmn-1,0)].first);
		else extraMin=A[0].first+moneyleft
		ll force=extraMin*cm+cf*full;
		if(empty==0){
			force=cm*MAX+cf*full;
		}
		if(force==mx){
			for(int j=0;j<n;j++){
				// cout << (A[max(mxmn-1,0)].first+extraMin) << " " << empty << " " <<  MAX << endl;
				B[j]=A[j];
				if(j<empty){
					B[j].first=extraMin;
					// cout << j << " " << B[j].first << endl;
				}
				else {
					B[j].first=MAX;
				}
			}
			break;
		}
		money=money-(MAX-A[i].first);
	}

	cout << mx << endl;
	for(int i=0;i<n;i++){
		swap(B[i].first,B[i].second);
	}
	sort(B,B+n);
	for(int i=0;i<n;i++){
		cout << B[i].second << " ";
	}
	cout << endl;
	return 0;
}


/*IN THE NAME OF GOD*/
/*year:2015 month:1 day: codeforces level:Pupil*/
#include <iostream>
#include <conio.h>
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <cmath>
#include <map>
#include <fstream>
using namespace std;

int main()
{
	string x; cin >> x;
	string  y = "";
	int l = x.length();
	for (int i = 0; i < l; i++)
	{
		if (!(x[i] == 'A' || x[i] == 'H' || x[i] == 'M' || x[i] == 'O' || x[i] == 'V' || x[i] == 'W' || x[i] == 'X' || x[i] == 'Y' || x[i] == 'T' || x[i]=='U'))
		{
			cout << "NO";
			return 0;
		}
	}
	for (int i = 0; i < l; i++)
		y += x[l - 1 - i];
	for (int i = 0; i < x.length(); i++)
	if (x[i] != y[i])
	{
		cout << "NO";
		return 0;
	}
	cout << "YES";

	//_getch()
	return 0;
}


/*IN THE NAME OF GOD*/
/*year:2015 month:1 day: codeforces level:Pupil*/
#include <iostream>
#include <conio.h>
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <cmath>
#include <map>
#include <fstream>
using namespace std;

int main()
{
	string x; cin >> x;
	string  y = "";
	int l = x.length();
	for (int i = 0; i < l; i++)
		y += x[l - 1 - i];
	for (int i = 0; i < x.length(); i++)
	if (x[i] != y[i])
	{
		cout << "NO";
		return 0;
	}
	cout << "YES";

	//_getch()
	return 0;
}


/*IN THE NAME OF GOD*/
/*year:2015 month:1 day: codeforces level:Pupil*/
#include <iostream>
#include <conio.h>
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <cmath>
#include <map>
#include <fstream>
using namespace std;

int main()
{
	string x; cin >> x;
	string  y = "";
	int l = x.length();
	for (int i = 0; i < l; i++)
	{
		if (!(x[i] == 'A' || x[i] == 'H' || x[i] == 'M' || x[i] == 'O' || x[i] == 'V' || x[i] == 'W' || x[i] == 'X' || x[i] == 'Y' || x[i] == 'T'))
		{
			cout << "NO";
			return 0;
		}
	}
	for (int i = 0; i < l; i++)
		y += x[l - 1 - i];
	for (int i = 0; i < x.length(); i++)
	if (x[i] != y[i])
	{
		cout << "NO";
		return 0;
	}
	cout << "YES";

	//_getch()
	return 0;
}


/*IN THE NAME OF GOD*/
/*year:2015 month:1 day: codeforces level:Pupil*/
#include <iostream>
#include <conio.h>
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <cmath>
#include <map>
#include <fstream>
using namespace std;

int main()
{
	string x; cin >> x;
	string  y = "";
	int l = x.length();
	for (int i = 0; i < l; i++)
	{
		if (!(x[i] == 'A' || x[i] == 'I' || x[i] == 'H' || x[i] == 'M' || x[i] == 'O' || x[i] == 'V' || x[i] == 'W' || x[i] == 'X' || x[i] == 'Y' || x[i] == 'T' || x[i]=='U'))
		{
			cout << "NO";
			return 0;
		}
	}
	for (int i = 0; i < l; i++)
		y += x[l - 1 - i];
	for (int i = 0; i < x.length(); i++)
	if (x[i] != y[i])
	{
		cout << "NO";
		return 0;
	}
	cout << "YES";

	//_getch()
	return 0;
}


#include <bits/stdc++.h>
#include<string.h>
#include<math.h>
using namespace std;
char c[]={'A','H','I','M','O','T','U','V','W','X','Y'};
int main()
{
    string a,b;
    int i,j,l=0,n=0,m;
    cin>>a;
    b=a;
    reverse(b.begin(),b.end());
    l=a.length();
    for(i=0;i<l;i++)
    {
        m=0;
        for(j=0;j<11;j++)
        {
            if(a[i]==c[j])
            {
                m=1;
            }
        }

       if(m!=1)
       {
           n=1;
       }
    }

    if(n!=1&&b==a)
    {
        cout<<"YES";
    }
    else
    {
        cout<<"NO";
    }

  return 0;
}


#include <bits/stdc++.h>
#include<string.h>
#include<math.h>
using namespace std;
char c[]={'A','H','I','M','O','T','U','V','W','X','Y'};
int main()
{
    string a,b;
    int i,j,l=0,n=0,m;
    cin>>a;
    b=a;
    reverse(b.begin(),b.end());
    l=a.length();
    for(i=0;i<l;i++)
    {
        m=0;
        for(j=0;j<11;j++)
        {
            if(a[i]==c[j])
            {
                m=1;
            }
        }

       if(m!=0)
       {
           n=1;
       }
    }

    if(n!=0&&b==a)
    {
        cout<<"YES";
    }
    else
    {
        cout<<"NO";
    }

  return 0;
}


#include <bits/stdc++.h>
#include<string.h>
#include<math.h>
using namespace std;
char c[]={'A','H','I','M','O','T','U','V','W','X','Y'};
int main()
{
    string a,b;
    int i,j,l=0,n=0,m;
    cin>>a;
    b=a;
    reverse(b.begin(),b.end());
    l=a.length();
    for(i=0;i<l;i++)
    {
        m=0;
        for(j=0;j<11;j++)
        {
            if(a[i]==c[j])
            {
                m=1;
            }
        }

    }

    if(m==1&&b==a)
    {
        cout<<"YES";
    }
    else
    {
        cout<<"NO";
    }

  return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	string x,y;
	cin>>x;
	for(int i=x.size()-1;i>=0;i--){
		y+=x[i];
	}
	if(x==y){
		cout<<"YES";
	}
	else{
		cout<<"NO";
	}
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>

using namespace std;

int main(){
//  freopen("0.in","r",stdin);
//  freopen("0.out","w",stdout);

  int n,i,k;
  string x;

  cin>>x;
  n=x.size();
  if(n==1){
    cout<<"NO\n";
    return 0;
  }
  k=n/2;
  for(i=0;i<k;i++){
    if(x[i]!=x[n-1-i]){
      cout<<"NO\n";
      return 0;
    }

  }
  cout<<"YES\n";
  return 0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>

using namespace std;

int main(){
//  freopen("0.in","r",stdin);
//  freopen("0.out","w",stdout);

  int n,i,j,k;
  string x,y;
  y="AHIMOTUVWXY";

  cin>>x;
  n=x.size();

  k=n/2;
  for(i=0;i<k;i++){
    for(j=0;j<11;j++)
      if(x[i]==y[j]) j=11;
    if(j==11){
      cout<<"NO\n";
      return 0;
    }
    if(x[i]!=x[n-1-i]){
      cout<<"NO\n";
      return 0;
    }
  }
  k=(n-1)/2;
  for(j=0;j<11;j++)
    if(x[k]==y[j]) j=11;
  if(j==11){
    cout<<"NO\n";
    return 0;
  }

  cout<<"YES\n";
  return 0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>

using namespace std;

int main(){
//  freopen("0.in","r",stdin);
//  freopen("0.out","w",stdout);

  int n,i,j,k;
  string x,y;
  y="AHIMOTUVWXY";

  cin>>x;
  n=x.size();

  k=n/2;
  for(i=0;i<k;i++){
    for(j=0;j<11;j++){
      if(x[i]!=y[j])
      {
        cout<<"NO\n";
        return 0;
      }
      if(x[i]!=x[n-1-i]){
        cout<<"NO\n";
        return 0;
      }
    }
  }
  k=(n+1)/2;
  for(j=0;j<11;j++)
    if(x[k]!=y[j])
    {
      cout<<"NO\n";
      return 0;
    }

  cout<<"YES\n";
  return 0;
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>

using namespace std;

int main(){
//  freopen("0.in","r",stdin);
//  freopen("0.out","w",stdout);

  int n,i,j,k;
  string x,y;
  y="AHIMOTUVWXY";

  cin>>x;
  n=x.size();

  k=n/2;
  for(i=0;i<k;i++){
    for(j=0;j<11;j++)
      if(x[i]==y[j]) j=11;
    if(j==11){
      cout<<"NO\n";
      return 0;
    }
    if(x[i]!=x[n-1-i]){
      cout<<"NO\n";
      return 0;
    }
  }
  k=(n+1)/2;
  for(j=0;j<11;j++)
    if(x[k]==y[j]) j=11;
  if(j==11){
    cout<<"NO\n";
    return 0;
  }

  cout<<"YES\n";
  return 0;
}


#include <iostream>
#include<string>
using namespace std;
int main() {
    int i,j,m;
    string t;
    cin>>t;
    m=t.size();
    for(i=0;i<m;i++)
    {
        if(t[i]==t[m-i-1] && (t[i]=='A' || t[i]=='H' || t[i]=='I' || t[i]=='M' || t[i]=='O' ||t[i]=='T' || t[i]=='U' || t[i]=='V' || t[i]=='W' || t[i]=='X' || t[i]=='Y' ))
        {
            cout<<"YES"<<endl;
            return 0;
        }

    }
        cout<<"NO"<<endl;
    return 0;
}


#include <iostream>
#include<string>
using namespace std;
int main() {
    int i,j,m;
    string t;
    cin>>t;
    m=t.size()-1;
    for(i=0;i<m;i++)
    {
        if(m==0)
        {
        cout<<"NO";
        return 0;
        }
        if(t[i]!=t[m-i])
        {
            cout<<"NO"<<endl;
            return 0;
        }

    }
        cout<<"YES"<<endl;
    return 0;
}


#include <iostream>
#include<string>
using namespace std;
int main() {
    int i,j,m;
    string t;
    cin>>t;
    m=t.size();
    for(i=0;i<m;i++)
    {
        if(t[i]!=t[m-i-1])
        {
            cout<<"NO"<<endl;

            return 0;
        }
        if(t[i]!='A' && t[i]!='H' && t[i]!='I' && t[i]!='M' && t[i]!='O' && t[i]!='T' && t[i]!='U' && t[i]!='V' && t[i]!='W' && t[i]!='X' && t[i]!='Y' )
        {
            cout<<"NO"<<endl;

            return 0;
        }

    }
        cout<<"YES"<<endl;
    return 0;
}


//http://codeforces.com/problemset/problem/420/A
#include <iostream>
#include <cstdio>

using namespace std;

bool checkMirror(string companyName)
{
    int nameLength = companyName.size();
    bool flag = true;
    for(int charIndex = 0,charIndexLast = nameLength-1; charIndex < nameLength && charIndexLast >0;charIndex++,charIndexLast--)
    {
        if((companyName[charIndex] == 'B'||companyName[charIndex] == 'C'||companyName[charIndex] == 'D'|| companyName[charIndex] == 'E'
            || companyName[charIndex] == 'F'|| companyName[charIndex] == 'G'|| companyName[charIndex] == 'J'|| companyName[charIndex] == 'L'
            || companyName[charIndex] == 'P'|| companyName[charIndex] == 'R'|| companyName[charIndex] == 'k') || (companyName[charIndexLast] =='B'|| companyName[charIndexLast] == 'C'
            || companyName[charIndexLast] == 'D'|| companyName[charIndexLast] == 'E'|| companyName[charIndexLast] == 'F'|| companyName[charIndexLast] == 'G'
            || companyName[charIndexLast] == 'J'|| companyName[charIndexLast] == 'L'|| companyName[charIndexLast] == 'P'|| companyName[charIndexLast] == 'R'|| companyName[charIndexLast] == 'k' )) { flag = false; }
        if(companyName[charIndex] != companyName[charIndexLast]) return false;
    }
    if(!flag) return false;
    return true;
}
//{'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//{'A','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char englishLetter[] = {'B','C','D','E','F','G','J','K','L','P','R'};
int main()
{
    string companyName;
    while(cin>>companyName)
    {
        if(companyName.size() == 1) cout<<"NO"<<endl;
        else if(checkMirror(companyName)) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;

    }
    return 0;
}


//http://codeforces.com/problemset/problem/420/A
#include <iostream>
#include <cstdio>

using namespace std;

bool checkMirror(string companyName)
{
    int nameLength = companyName.size();
    bool flag = true;
    for(int charIndex = 0,charIndexLast = nameLength-1; charIndex < nameLength && charIndexLast >0;charIndex++,charIndexLast--)
    {
        if((companyName[charIndex] == 'B'||companyName[charIndex] == 'C'||companyName[charIndex] == 'D'|| companyName[charIndex] == 'E'
            || companyName[charIndex] == 'F'|| companyName[charIndex] == 'G'|| companyName[charIndex] == 'J'|| companyName[charIndex] == 'L'
            || companyName[charIndex] == 'P'|| companyName[charIndex] == 'R'|| companyName[charIndex] == 'K') || (companyName[charIndexLast] =='B'|| companyName[charIndexLast] == 'C'
            || companyName[charIndexLast] == 'D'|| companyName[charIndexLast] == 'E'|| companyName[charIndexLast] == 'F'|| companyName[charIndexLast] == 'G'
            || companyName[charIndexLast] == 'J'|| companyName[charIndexLast] == 'L'|| companyName[charIndexLast] == 'P'|| companyName[charIndexLast] == 'R'|| companyName[charIndexLast] == 'K' )) { flag = false; }
        if(companyName[charIndex] != companyName[charIndexLast]) return false;
    }
    if(!flag) return false;
    return true;
}
//{'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//{'A','H','I','M','N','O','Q','S','T','U','V','W','X','Y','Z'};
char englishLetter[] = {'B','C','D','E','F','G','J','K','L','P','R','K'};
int main()
{
    string companyName;
    while(cin>>companyName)
    {
        if(companyName.size() == 1) cout<<"NO"<<endl;
        else if(checkMirror(companyName)) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;

    }
    return 0;
}


//http://codeforces.com/problemset/problem/420/A
#include <iostream>
#include <cstdio>

using namespace std;

bool checkMirror(string companyName)
{
    int nameLength = companyName.size();
    bool flag = true;
    for(int charIndex = 0,charIndexLast = nameLength-1; charIndex < nameLength && charIndexLast >0;charIndex++,charIndexLast--)
    {
        if((companyName[charIndex] == 'B'||companyName[charIndex] == 'C'||companyName[charIndex] == 'D'|| companyName[charIndex] == 'E'
            || companyName[charIndex] == 'F'|| companyName[charIndex] == 'G'|| companyName[charIndex] == 'J'|| companyName[charIndex] == 'L'
            || companyName[charIndex] == 'P'|| companyName[charIndex] == 'R'|| companyName[charIndex] == 'K'|| companyName[charIndex] == 'Q') || (companyName[charIndexLast] =='B'|| companyName[charIndexLast] == 'C'
            || companyName[charIndexLast] == 'D'|| companyName[charIndexLast] == 'E'|| companyName[charIndexLast] == 'F'|| companyName[charIndexLast] == 'G'
            || companyName[charIndexLast] == 'J'|| companyName[charIndexLast] == 'L'|| companyName[charIndexLast] == 'P'|| companyName[charIndexLast] == 'R'|| companyName[charIndexLast] == 'K'|| companyName[charIndexLast] == 'Q' )) { flag = false; }
        if(companyName[charIndex] != companyName[charIndexLast]) return false;
    }
    if(!flag) return false;
    return true;
}
//{'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//{'A','H','I','M','N','O','Q','S','T','U','V','W','X','Y','Z'};
char englishLetter[] = {'B','C','D','E','F','G','J','K','L','P','R','K'};
int main()
{
    string companyName;
    while(cin>>companyName)
    {
        if(companyName.size() == 1) cout<<"NO"<<endl;
        else if(checkMirror(companyName)) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;

    }
    return 0;
}


//http://codeforces.com/problemset/problem/420/A
#include <iostream>
#include <cstdio>

using namespace std;

bool checkMirror(string companyName)
{
    int nameLength = companyName.size();
    bool flag = true;
    for(int charIndex = 0,charIndexLast = nameLength-1; charIndex < nameLength && charIndexLast >0;charIndex++,charIndexLast--)
    {
        if((companyName[charIndex] == 'B'||companyName[charIndex] == 'C'||companyName[charIndex] == 'D'|| companyName[charIndex] == 'E'
            || companyName[charIndex] == 'F'|| companyName[charIndex] == 'G'|| companyName[charIndex] == 'J'|| companyName[charIndex] == 'L'
            || companyName[charIndex] == 'P'|| companyName[charIndex] == 'R') || (companyName[charIndexLast] =='B'|| companyName[charIndexLast] == 'C'
            || companyName[charIndexLast] == 'D'|| companyName[charIndexLast] == 'E'|| companyName[charIndexLast] == 'F'|| companyName[charIndexLast] == 'G'
            || companyName[charIndexLast] == 'J'|| companyName[charIndexLast] == 'L'|| companyName[charIndexLast] == 'P'|| companyName[charIndexLast] == 'R' )) { flag = false; }
        if(companyName[charIndex] != companyName[charIndexLast]) return false;
    }
    if(!flag) return false;
    return true;
}
//{'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char englishLetter[] = {'B','C','D','E','F','G','J','L','P','R'};
int main()
{
    string companyName;
    while(cin>>companyName)
    {
        if(companyName.size() == 1) cout<<"NO"<<endl;
        else if(checkMirror(companyName)) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;

    }
    return 0;
}


//http://codeforces.com/problemset/problem/420/A
#include <iostream>
#include <cstdio>
#include <set>
#include <cstring>
#include <string>
using namespace std;

bool checkMirror(string companyName)
{
    int nameLength = companyName.size();
    set<char>s;
    s.insert('A');
    s.insert('H');
    s.insert('I');
    s.insert('M');
    s.insert('O');
    s.insert('T');
    s.insert('U');
    s.insert('V');
    s.insert('W');
    s.insert('X');
    s.insert('Y');

    for(int charIndex = 0,charIndexLast = nameLength-1; charIndex <= charIndexLast;charIndex++,charIndexLast--)
    {
        if(companyName[charIndex] != companyName[charIndexLast] || (s.find(companyName[charIndex]) == s.end())) return false;
    }
    return true;
}

int main()
{
    string companyName;
    while(cin>>companyName)
    {
        if(checkMirror(companyName)) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    return 0;
}


//http://codeforces.com/problemset/problem/420/A
#include <iostream>
#include <cstdio>

using namespace std;

bool checkMirror(string companyName)
{
    int nameLength = companyName.size();
    bool flag = true;
    //if(nameLength > 1) nameLength-1;
    for(int charIndex = 0,charIndexLast = nameLength-1; charIndex < nameLength && charIndexLast >0;charIndex++,charIndexLast--)
    {
        if((companyName[charIndex] == 'B'||companyName[charIndex] == 'C'||companyName[charIndex] == 'D'|| companyName[charIndex] == 'E'
            || companyName[charIndex] == 'F'|| companyName[charIndex] == 'G'|| companyName[charIndex] == 'J'|| companyName[charIndex] == 'L'
            || companyName[charIndex] == 'P'|| companyName[charIndex] == 'R'|| companyName[charIndex] == 'K'|| companyName[charIndex] == 'Z') || (companyName[charIndexLast] =='B'|| companyName[charIndexLast] == 'C'
            || companyName[charIndexLast] == 'D'|| companyName[charIndexLast] == 'E'|| companyName[charIndexLast] == 'F'|| companyName[charIndexLast] == 'G'
            || companyName[charIndexLast] == 'J'|| companyName[charIndexLast] == 'L'|| companyName[charIndexLast] == 'P'|| companyName[charIndexLast] == 'R'|| companyName[charIndexLast] == 'K'|| companyName[charIndex] == 'Z' ))
            {
                 cerr<<"check 1 "<<companyName[charIndex] <<" "<<companyName[charIndexLast]<<endl;flag = false;
            }
        if(companyName[charIndex] != companyName[charIndexLast]) {cerr<<"check 2 "<<endl;return false;}
    }
    if(!flag) {cerr<<"check 3 "<<flag<<endl; return false;}
    else return true;
}
//{'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//{'A','H','I','M','N','O','Q','S','T','U','V','W','X','Y','Z'};
char englishLetter[] = {'B','C','D','E','F','G','J','K','L','P','R','K'};
int main()
{
    string companyName;
    while(cin>>companyName)
    {
        if(companyName.size() == 1) cout<<"NO"<<endl;
        else if(checkMirror(companyName)) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;

    }
    return 0;
}


//http://codeforces.com/problemset/problem/420/A
#include <iostream>
#include <cstdio>

using namespace std;

bool checkMirror(string companyName)
{
    int nameLength = companyName.size();
    for(int charIndex = 0,charIndexLast = nameLength-1; charIndex < nameLength && charIndexLast >0;charIndex++,charIndexLast--)
    {
        if(companyName[charIndex] != companyName[charIndexLast]) return false;
    }
    return true;
}
int main()
{
    string companyName;
    while(cin>>companyName)
    {
        if(companyName.size() == 1) cout<<"NO"<<endl;
        else if(checkMirror(companyName)) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;

    }
    return 0;
}


#include <iostream>
#include <string>
using namespace std;
bool check (char c ){
    if (c=='B'||c=='C'||c=='D'||c=='E'||c=='F'||c=='G'||c=='J'||c=='K'||c=='L'||c=='P'||c=='R'||c=='S'||c=='Z')
        return false ;
    return true ;
}
int main()
{
    string str ;
    cin >> str ;
    string ans = "YES" ;
    if (str.length() == 1) ans = "NO";
    int j = str.length()-1 ;
    for (int i =0 ; i < str.length()/2 ; i++){
        if (str[i] != str[j--]) {
            ans = "NO";
            break ;
        }
        if (!check(str[i])){
            ans = "NO";
            break ;
        }

    }
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <string>
using namespace std;
bool check (char c ){
    if (c=='B'||c=='C'||c=='D'||c=='N'||c=='E'||c=='Q'||c=='F'||c=='G'||c=='J'||c=='K'||c=='L'||c=='P'||c=='R'||c=='S'||c=='Z')
        return false ;
    return true ;
}
int main()
{
    string str ;
    cin >> str ;
    string ans = "YES" ;
    if (str.length() == 1 ){
        if (!check(str[0])) ans = "NO";
    }
    int j = str.length()-1 ;
    for (int i =0 ; i < str.length()/2 ; i++){
        if (str[i] != str[j--]) {
            ans = "NO";
            break ;
        }
        if (!check(str[i])){
            ans = "NO";
            break ;
        }

    }
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <string>
using namespace std;
bool check (char c ){
    if (c=='B'||c=='C'||c=='D'||c=='E'||c=='Q'||c=='F'||c=='G'||c=='J'||c=='K'||c=='L'||c=='P'||c=='R'||c=='S'||c=='Z')
        return false ;
    return true ;
}
int main()
{
    string str ;
    cin >> str ;
    string ans = "YES" ;
    if (str.length() == 1 ){
        if (!check(str[0])) ans = "NO";
    }
    int j = str.length()-1 ;
    for (int i =0 ; i < str.length()/2 ; i++){
        if (str[i] != str[j--]) {
            ans = "NO";
            break ;
        }
        if (!check(str[i])){
            ans = "NO";
            break ;
        }

    }
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <string>
using namespace std;
bool check (char c ){
    if (c=='B'||c=='C'||c=='D'||c=='E'||c=='F'||c=='G'||c=='J'||c=='K'||c=='L'||c=='P'||c=='R'||c=='S'||c=='Z')
        return false ;
    return true ;
}
int main()
{
    string str ;
    cin >> str ;
    string ans = "YES" ;
    if (str.length() == 1) ans = "NO";
    int j = str.length()-1 ;
    for (int i =0 ; i < str.length()/2 ; i++){
        if (str[i] != str[j]) {
            ans = "NO";
            break ;
        }
        if (!check(str[i])){
            ans = "NO";
            break ;
        }

    }
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <string>
using namespace std;
bool check (char c ){
    if (c=='B'||c=='C'||c=='D'||c=='N'||c=='E'||c=='Q'||c=='F'||c=='G'||c=='J'||c=='K'||c=='L'||c=='P'||c=='R'||c=='S'||c=='Z')
        return false ;
    return true ;
}
int main()
{
    string str ;
    cin >> str ;
    string ans = "YES" ;
    if (str.length() == 1 ){
        if (!check(str[0])) ans = "NO";
    }
    int j = str.length()-1 ;
    for (int i =0 ; i < str.length()/2 ; i++){
        if (str[i] != str[j--]) {
            ans = "NO";
            break ;
        }
        if (!check(str[i])){
            ans = "NO";
            break ;
        }

    }
    if (!check(str[str.length()/2])) ans = "NO";
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <string>
using namespace std;
bool check (char c ){
    if (c=='B'||c=='C'||c=='D'||c=='E'||c=='Q'||c=='F'||c=='G'||c=='J'||c=='K'||c=='L'||c=='P'||c=='R'||c=='S'||c=='Z')
        return false ;
    return true ;
}
int main()
{
    string str ;
    cin >> str ;
    string ans = "YES" ;
    if (str.length() == 1) ans = "NO";
    int j = str.length()-1 ;
    for (int i =0 ; i < str.length()/2 ; i++){
        if (str[i] != str[j--]) {
            ans = "NO";
            break ;
        }
        if (!check(str[i])){
            ans = "NO";
            break ;
        }

    }
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main()
{
    string str ;
    cin >> str ;
    string ans = "YES" ;
    if (str.length() == 1) ans = "NO";
    int j = str.length()-1 ;
    for (int i =0 ; i < str.length()/2 ; i++){
        if (str[i] != str[j--]) {
            ans = "NO";
            break ;
        }
    }
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main()
{
    string str ;
    cin >> str ;
    string ans = "YES" ;
    if (str.length() == 1) ans = "NO";
    int j = str.length()-1 ;
    for (int i =0 ; i < str.length()/2 ; i++){
        if (str[i] != str[j--]) {
            ans = "NO";
            break ;
        }
        if (str[i+1] < str[i]){
            ans = "NO";
            break ;
        }
    }
    cout << ans << endl;
    return 0;
}