結果

問題 No.31 悪のミックスジュース
ユーザー Ricky_ponRicky_pon
提出日時 2020-05-19 20:13:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,527 bytes
コンパイル時間 1,971 ms
コンパイル使用メモリ 196,320 KB
実行使用メモリ 11,696 KB
最終ジャッジ日時 2024-04-09 22:23:54
合計ジャッジ時間 6,036 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 1000010;

int main(){
    int n; lint V;
    scanf("%d%lld", &n, &V);
    lint C[n], sum = 0;
    rep(i, n){
        scanf("%lld", &C[i]);
        sum += C[i];
    }
    V -= n;
    if(V <= 0){
        printf("%lld\n", sum);
        return 0;
    }

    partial_sum(C, C+n, C);
    lint dp[MAX];
    fill(dp, dp+MAX, INF);
    dp[0] = 0;
    rep(i, n)rrep(j, MAX){
        if(j-(i+1) >= 0) chmin(dp[j], dp[j-(i+1)] + C[i]);
    }

    int m = 0;
    For(i, 1, n){
        if(C[m]*(i+1) > C[i]*(m+1)) m = i;
    }
    lint ans = INF;
    rep(i, V+1){
        chmin(ans, sum + dp[i] + C[m]*div_ceil(V-i, (lint)m+1));
    }
    printf("%lld\n", ans);
}
0