結果
| 問題 | No.409 ダイエット |
| コンテスト | |
| ユーザー |
btk
|
| 提出日時 | 2016-04-17 21:25:01 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,217 bytes |
| 記録 | |
| コンパイル時間 | 1,654 ms |
| コンパイル使用メモリ | 162,148 KB |
| 実行使用メモリ | 12,928 KB |
| 最終ジャッジ日時 | 2024-10-04 10:31:10 |
| 合計ジャッジ時間 | 6,327 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 55 TLE * 1 -- * 36 |
ソースコード
#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);
dp[0] = W;
for(int i = 0; i < N; i++){
for(int j = 0; j <= i; j++){
dp[i + 1] = min(dp[i + 1],dp[j] + D[i] - A * (i - j) + B * (i - j) * (i - j + 1) / 2);
}
}
/*output*/
INT res = INF;
for(int i = 0; i <= N; i++)
res = min(res,dp[i] - A * (N -i) + B * (N - i) * (N - i + 1) / 2);
cout << res << endl;
return 0;
}
btk