結果

問題 No.409 ダイエット
ユーザー btkbtk
提出日時 2016-04-17 21:13:53
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,244 bytes
コンパイル時間 1,217 ms
コンパイル使用メモリ 162,768 KB
実行使用メモリ 16,644 KB
最終ジャッジ日時 2024-04-15 02:17:44
合計ジャッジ時間 7,313 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
13,760 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 AC 1 ms
6,944 KB
testcase_12 AC 1 ms
6,944 KB
testcase_13 AC 1 ms
6,940 KB
testcase_14 AC 1 ms
6,944 KB
testcase_15 AC 1 ms
6,944 KB
testcase_16 AC 1 ms
6,940 KB
testcase_17 AC 1 ms
6,940 KB
testcase_18 AC 1 ms
6,940 KB
testcase_19 AC 1 ms
6,940 KB
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 1 ms
6,944 KB
testcase_22 AC 1 ms
6,944 KB
testcase_23 AC 1 ms
6,944 KB
testcase_24 AC 1 ms
6,940 KB
testcase_25 AC 2 ms
6,944 KB
testcase_26 AC 2 ms
6,944 KB
testcase_27 AC 1 ms
6,944 KB
testcase_28 AC 1 ms
6,940 KB
testcase_29 AC 1 ms
6,944 KB
testcase_30 AC 1 ms
6,940 KB
testcase_31 AC 1 ms
6,944 KB
testcase_32 AC 1 ms
6,940 KB
testcase_33 AC 1 ms
6,944 KB
testcase_34 AC 2 ms
6,940 KB
testcase_35 AC 17 ms
6,944 KB
testcase_36 AC 22 ms
6,944 KB
testcase_37 AC 20 ms
6,940 KB
testcase_38 AC 19 ms
6,940 KB
testcase_39 AC 19 ms
6,940 KB
testcase_40 AC 22 ms
6,944 KB
testcase_41 AC 25 ms
6,944 KB
testcase_42 AC 23 ms
6,940 KB
testcase_43 AC 20 ms
6,940 KB
testcase_44 AC 18 ms
6,944 KB
testcase_45 AC 21 ms
6,944 KB
testcase_46 AC 22 ms
6,944 KB
testcase_47 AC 21 ms
6,940 KB
testcase_48 AC 20 ms
6,940 KB
testcase_49 AC 22 ms
6,944 KB
testcase_50 AC 21 ms
6,944 KB
testcase_51 AC 21 ms
6,940 KB
testcase_52 AC 23 ms
6,940 KB
testcase_53 AC 23 ms
6,944 KB
testcase_54 AC 18 ms
6,940 KB
testcase_55 TLE -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
testcase_67 -- -
testcase_68 -- -
testcase_69 -- -
testcase_70 -- -
testcase_71 -- -
testcase_72 -- -
testcase_73 -- -
testcase_74 -- -
testcase_75 -- -
testcase_76 -- -
testcase_77 -- -
testcase_78 -- -
testcase_79 -- -
testcase_80 -- -
testcase_81 -- -
testcase_82 -- -
testcase_83 -- -
testcase_84 -- -
testcase_85 -- -
testcase_86 -- -
testcase_87 -- -
testcase_88 -- -
testcase_89 -- -
testcase_90 -- -
testcase_91 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

/*想定TLE解法その1*/

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef __int128 INT;


/*cin高速化*/
struct INIT{INIT(){ios::sync_with_stdio(false);cin.tie(0);}}init;

ostream& operator<<(ostream &os,INT x){
    LL y;
    y=x;
    assert(y==x);
    os << y;
    return os;
}
istream& operator>>(istream &is,INT& x){
    LL y;
    is >> y;
    x = y;
    return is;
}

const INT INF = 1e24;
int main() {
    INT N,A,B,W;
    /*input N,A,B,W*/
    {
        cin >> N >> A >> B >> W;
        assert(1 <= N && N <= 300000);
        assert(0 <= A && A <= 1000000);
        assert(0 <= B && B <= 1000000);
        assert(0 <= W && W <= 1000000);
    }
    vector<INT> D(N);
    {
        for(auto& it : D){
            cin >> it;
            assert(0 <= it && it <= 1000000);
        }
    }
    /*DP*/
    vector<INT> dp(N+1,INF),nxt(N+1);
    dp[0] = W;
    for(int i = 0; i < N; i++){
        nxt[0] = dp[N] + D[i];
        for(int j = 0; j < N; j++){
            nxt[0] = min(nxt[0],dp[j] + D[i]);
            nxt[j+1] = dp[j] - A + (j + 1) * B;
        }
        swap(dp,nxt);
    }

    /*output*/
    INT res = INF;
    for(auto& it : dp)
        res = min(res,it);
    cout << res << endl;
    return 0;
}
0