結果

問題 No.409 ダイエット
ユーザー sugim48sugim48
提出日時 2016-08-05 23:01:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,372 bytes
コンパイル時間 1,057 ms
コンパイル使用メモリ 104,540 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-04-24 16:06:52
合計ジャッジ時間 6,371 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
10,752 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 1 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 1 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 9 ms
5,376 KB
testcase_36 AC 10 ms
5,376 KB
testcase_37 AC 10 ms
5,376 KB
testcase_38 AC 10 ms
5,376 KB
testcase_39 AC 10 ms
5,376 KB
testcase_40 AC 11 ms
5,376 KB
testcase_41 AC 12 ms
5,376 KB
testcase_42 AC 12 ms
5,376 KB
testcase_43 AC 10 ms
5,376 KB
testcase_44 AC 9 ms
5,376 KB
testcase_45 AC 10 ms
5,376 KB
testcase_46 AC 11 ms
5,376 KB
testcase_47 AC 10 ms
5,376 KB
testcase_48 AC 9 ms
5,376 KB
testcase_49 AC 12 ms
5,376 KB
testcase_50 AC 10 ms
5,376 KB
testcase_51 AC 11 ms
5,376 KB
testcase_52 AC 12 ms
5,376 KB
testcase_53 AC 12 ms
5,376 KB
testcase_54 AC 9 ms
5,376 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 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:58:21: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
   58 |         cout << W + ans << endl;
      |                     ^~~
main.cpp:44:12: note: 'ans' was declared here
   44 |         ll ans;
      |            ^~~

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<int, ll> i_ll;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	int N; ll A, B, W;
	cin >> N >> A >> B >> W;
	vector<ll> D(N);
	for (ll& x: D) scanf("%lld", &x);
	N++; D.push_back(0);
	int M = 1;
	vector<i_ll> p; p.push_back(i_ll(0, 0));
	ll ans;
	for (int i = 0; i < N; i++) {
		ll mi = LLONG_MAX;
		for (i_ll z: p) {
			int j = z.first; ll x = z.second;
			ll k = i - j;
			ll _x = x + k*(k+1)/2 * B - k * A + D[i];
			mi = min(mi, _x);
		}
		i_ll _p(i + 1, mi);
		for (; M >= 2 && (double)(p[M - 1].second - p[M - 2].second) / (p[M - 1].first - p[M - 2].first) < (double)(_p.second - p[M - 1].second) / (_p.first - p[M - 1].first); M--, p.pop_back());
		p.push_back(_p);
		ans = mi;
	}
	cout << W + ans << endl;
}
0