結果

問題 No.31 悪のミックスジュース
コンテスト
ユーザー pessimist
提出日時 2026-01-19 04:36:13
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
結果
WA  
実行時間 -
コード長 1,065 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 5,386 ms
コンパイル使用メモリ 355,984 KB
実行使用メモリ 7,852 KB
最終ジャッジ日時 2026-01-19 04:36:20
合計ジャッジ時間 5,974 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 2 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll=long long;
void solve(){
    ll N,V; cin>>N>>V;
    vector<ll> C(N);
    for(auto&x:C)cin>>x;
    ll ANS=accumulate(begin(C),end(C),0LL);
    if(V<=N){
        cout<<ANS;
        return;
    }
    V-=N;
    vector<ll> pref(N+1);
    partial_sum(begin(C),end(C),begin(pref)+1);
    const int U=10010;
    vector<ll> dp(U,1e10);
    dp[0]=0;
    for(int i=1;i<=N;++i){
        for(int j=i;j<U;++j){
            ll cst=dp[j-i]+pref[i];
            if(dp[j]>cst)dp[j]=cst;
        }
    }

    vector<double> min_rate(N+1);
    min_rate[0]=1e18;
    for(int i=1;i<=N;++i)min_rate[i]=(C[i-1]*1.)/i;
    const int n=min_element(begin(min_rate),end(min_rate))-begin(min_rate);
    ll k=max(0ll,1+(V-U)/n);
    ANS+=k*pref[n];
    if(V>0)ANS+=dp[V-k*n];
    cout<<ANS;
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int T=1; // cin>>T;
    while(T--)solve();
    cout<<endl;
    return 0;
}
0