結果

問題 No.409 ダイエット
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2017-03-23 11:10:49
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,457 bytes
コンパイル時間 1,861 ms
コンパイル使用メモリ 165,204 KB
実行使用メモリ 8,768 KB
最終ジャッジ日時 2023-09-19 08:45:19
合計ジャッジ時間 9,903 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,600 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 1 ms
4,380 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
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 #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)





template<typename V> struct ConvexHull {
	deque<pair<V, V>> Q;
	int cmptype = 0; // 0-min 1-max
	V calc(pair<V, V> p, V x) {
		return p.first*x + p.second;
	}
	int dodo(pair<V, V> A, pair<V, V> B, pair<V, V> C) { // max or min
		return cmptype ^ ((B.second - C.second)*(B.first - A.first) <= (A.second - B.second)*(C.first - B.first));
	}
	void add(V a, V b) { // add ax+b
		Q.push_front({ a,b });
		while (Q.size() >= 3 && !dodo(Q[0], Q[1], Q[2]))
			Q[1] = Q[0], Q.pop_front();
	}
	V get(V x) {
		int L = -1, R = Q.size() - 1;
		while (R - L>1) {
			int M = (L + R) / 2;
			((cmptype ^ ((calc(Q[M], x) >= calc(Q[M + 1], x)))) ? L : R) = M;
		}
		return calc(Q[R], x);
	}
};
//-----------------------------------------------------------------------------------
typedef long long ll;
#define INF 1LL<<60
int N, A, B, W;
int D[301010];
//-----------------------------------------------------------------------------------
ll dp[301010];
int main() {
	cin >> N >> A >> B >> W;
	rep(i, 0, N) scanf("%d", &D[i]);

	dp[0] = W;
	rep(i, 1, N + 1) {
		dp[i] = INF;
		rep(j, 0, i) {
			ll w = dp[j];
			int n = i - j - 1;
			w -= A * n;
			w += n * (n + 1) / 2 * B;
			w += D[i - 1];
			dp[i] = min(dp[i], w);
		}
	}

	ll ans = INF;
	rep(i, 0, N + 1) {
		ll w = dp[i];
		int n = N - i;
		w -= A * n;
		w += n * (n + 1) / 2 * B;
		ans = min(ans, w);
	}

	cout << ans << endl;
}
0