結果
問題 |
No.409 ダイエット
|
ユーザー |
|
提出日時 | 2016-08-08 15:04:20 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 983 bytes |
コンパイル時間 | 2,061 ms |
コンパイル使用メモリ | 169,868 KB |
実行使用メモリ | 5,760 KB |
最終ジャッジ日時 | 2024-11-07 07:18:19 |
合計ジャッジ時間 | 29,670 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 91 WA * 1 |
ソースコード
#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; 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; }