結果

問題 No.31 悪のミックスジュース
ユーザー fumofumofunifumofumofuni
提出日時 2020-09-18 20:42:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,547 bytes
コンパイル時間 1,589 ms
コンパイル使用メモリ 168,712 KB
実行使用メモリ 7,532 KB
最終ジャッジ日時 2023-09-04 09:11:12
合計ジャッジ時間 8,178 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a <= b) {
        a = b;
        return true;
    }
    return false;
}


int main(){
    ll n,v;cin >> n >>v;
    vl c(n);rep(i,n)cin >> c[i];
    ll sum=accumulate(all(c),0LL);
    if(v<=n){
        cout << sum << endl;return 0;
    }
    v-=n;
    vl cnt(n);
    while(v--){
        pl now={c[0],0};
        rep(i,n-1){
            if(cnt[i]<cnt[i+1])break;
            if(cnt[i]!=cnt[i+1])chmin(now,{c[i+1],-(i+1)});
        }
        cnt[-now.se]++;
    }
    rep(i,n)sum+=cnt[i]*c[i];
    //rep(i,n)cout << cnt[i] <<" ";cout << endl;
    cout << sum <<endl;
}   
0