結果

問題 No.409 ダイエット
ユーザー parukiparuki
提出日時 2016-08-08 15:05:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 979 ms / 2,000 ms
コード長 1,066 bytes
コンパイル時間 1,684 ms
コンパイル使用メモリ 167,888 KB
実行使用メモリ 5,476 KB
最終ジャッジ日時 2023-09-08 17:01:56
合計ジャッジ時間 28,797 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,384 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,384 KB
testcase_13 AC 2 ms
4,384 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,384 KB
testcase_16 AC 2 ms
4,384 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1 ms
4,384 KB
testcase_23 AC 1 ms
4,384 KB
testcase_24 AC 1 ms
4,384 KB
testcase_25 AC 2 ms
4,384 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 1 ms
4,384 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 2 ms
4,384 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 1 ms
4,384 KB
testcase_34 AC 1 ms
4,380 KB
testcase_35 AC 10 ms
4,380 KB
testcase_36 AC 10 ms
4,384 KB
testcase_37 AC 10 ms
4,384 KB
testcase_38 AC 10 ms
4,380 KB
testcase_39 AC 10 ms
4,380 KB
testcase_40 AC 11 ms
4,380 KB
testcase_41 AC 11 ms
4,384 KB
testcase_42 AC 10 ms
4,380 KB
testcase_43 AC 10 ms
4,380 KB
testcase_44 AC 9 ms
4,380 KB
testcase_45 AC 10 ms
4,384 KB
testcase_46 AC 11 ms
4,384 KB
testcase_47 AC 10 ms
4,380 KB
testcase_48 AC 10 ms
4,380 KB
testcase_49 AC 11 ms
4,384 KB
testcase_50 AC 10 ms
4,384 KB
testcase_51 AC 10 ms
4,380 KB
testcase_52 AC 10 ms
4,380 KB
testcase_53 AC 10 ms
4,384 KB
testcase_54 AC 9 ms
4,380 KB
testcase_55 AC 469 ms
4,380 KB
testcase_56 AC 2 ms
4,384 KB
testcase_57 AC 979 ms
5,476 KB
testcase_58 AC 411 ms
4,384 KB
testcase_59 AC 595 ms
4,384 KB
testcase_60 AC 375 ms
4,380 KB
testcase_61 AC 871 ms
5,264 KB
testcase_62 AC 915 ms
5,220 KB
testcase_63 AC 850 ms
5,228 KB
testcase_64 AC 445 ms
4,384 KB
testcase_65 AC 876 ms
5,272 KB
testcase_66 AC 956 ms
5,220 KB
testcase_67 AC 735 ms
4,664 KB
testcase_68 AC 593 ms
4,608 KB
testcase_69 AC 837 ms
4,876 KB
testcase_70 AC 799 ms
4,884 KB
testcase_71 AC 448 ms
4,380 KB
testcase_72 AC 972 ms
5,144 KB
testcase_73 AC 901 ms
5,144 KB
testcase_74 AC 561 ms
4,420 KB
testcase_75 AC 902 ms
5,280 KB
testcase_76 AC 646 ms
4,624 KB
testcase_77 AC 430 ms
4,380 KB
testcase_78 AC 498 ms
4,380 KB
testcase_79 AC 396 ms
4,380 KB
testcase_80 AC 922 ms
5,100 KB
testcase_81 AC 890 ms
5,100 KB
testcase_82 AC 659 ms
4,624 KB
testcase_83 AC 709 ms
4,688 KB
testcase_84 AC 579 ms
4,400 KB
testcase_85 AC 63 ms
4,380 KB
testcase_86 AC 560 ms
4,608 KB
testcase_87 AC 795 ms
4,884 KB
testcase_88 AC 320 ms
4,384 KB
testcase_89 AC 671 ms
4,632 KB
testcase_90 AC 304 ms
4,380 KB
testcase_91 AC 712 ms
4,736 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int N;
ll A, B, W, INF = LLONG_MAX;

int main(){
    cin >> N >> A >> B >> W;
    
    if(B == 0){
        cout << W - N*A << endl;
        return 0;
    }
    
    vll D(N), cur(1100, INF), nex(1100, INF);
    rep(i, N)scanf("%lld", &D[i]);
    cur[0] = W;
    
    rep(i, N){
        fill(all(nex), INF);
        rep(j, 1100)if(cur[j] != INF){
            if(j != 1100 - 1)
                smin(nex[j+1], cur[j] - A + B*(j+1));
            smin(nex[0], cur[j] + D[i]);
        }
        swap(cur, nex);
    }
    cout << *min_element(all(cur)) << endl;
}
0