結果

問題 No.31 悪のミックスジュース
ユーザー momoyuu
提出日時 2024-07-28 01:07:33
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 705 bytes
コンパイル時間 1,354 ms
コンパイル使用メモリ 95,464 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-28 01:07:37
合計ジャッジ時間 2,741 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 7 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
using ll = long long;


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    ll n,v;
    cin>>n>>v;
    vector<ll> c(n);
    for(int i = 0;i<n;i++) cin>>c[i];
    ll sum = 0;
    for(int i = 0;i<n;i++) sum += c[i];
    v -= n;
    if(v<=0){
        cout<<sum<<endl;
        return 0;
    }

    vector<ll> a(n+1,0);
    for(int i = 0;i<n;i++) a[i+1] += a[i] + c[i];
    ll ans = 1e18;
    for(int i = 0;i<n;i++){
        ll le = i + 1;
        ll can = v / le;
        ll nv = v - can * le;
        ll now = sum + a[i+1] * can;
        now += a[nv];
        ans = min(ans,now);
    }
    cout<<ans<<endl;

}
0