結果

問題 No.409 ダイエット
ユーザー sugim48sugim48
提出日時 2016-08-05 23:31:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,569 bytes
コンパイル時間 1,203 ms
コンパイル使用メモリ 105,496 KB
実行使用メモリ 13,864 KB
最終ジャッジ日時 2024-04-24 19:18:36
合計ジャッジ時間 5,273 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 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 WA -
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 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 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 WA -
testcase_23 AC 2 ms
5,376 KB
testcase_24 WA -
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 WA -
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 2 ms
5,376 KB
testcase_39 AC 2 ms
5,376 KB
testcase_40 AC 2 ms
5,376 KB
testcase_41 AC 2 ms
5,376 KB
testcase_42 AC 3 ms
5,376 KB
testcase_43 AC 2 ms
5,376 KB
testcase_44 AC 2 ms
5,376 KB
testcase_45 AC 2 ms
5,376 KB
testcase_46 AC 2 ms
5,376 KB
testcase_47 AC 2 ms
5,376 KB
testcase_48 AC 2 ms
5,376 KB
testcase_49 AC 2 ms
5,376 KB
testcase_50 AC 2 ms
5,376 KB
testcase_51 WA -
testcase_52 AC 2 ms
5,376 KB
testcase_53 AC 2 ms
5,376 KB
testcase_54 AC 3 ms
5,376 KB
testcase_55 WA -
testcase_56 AC 35 ms
7,680 KB
testcase_57 WA -
testcase_58 AC 24 ms
7,436 KB
testcase_59 AC 31 ms
8,240 KB
testcase_60 AC 22 ms
7,328 KB
testcase_61 WA -
testcase_62 AC 49 ms
13,712 KB
testcase_63 WA -
testcase_64 AC 24 ms
7,640 KB
testcase_65 AC 45 ms
9,040 KB
testcase_66 AC 51 ms
12,924 KB
testcase_67 AC 38 ms
11,352 KB
testcase_68 AC 30 ms
8,344 KB
testcase_69 AC 44 ms
11,600 KB
testcase_70 WA -
testcase_71 AC 27 ms
7,488 KB
testcase_72 AC 58 ms
13,568 KB
testcase_73 AC 51 ms
11,592 KB
testcase_74 WA -
testcase_75 AC 53 ms
11,596 KB
testcase_76 AC 39 ms
10,932 KB
testcase_77 AC 25 ms
6,300 KB
testcase_78 AC 30 ms
10,672 KB
testcase_79 AC 26 ms
7,372 KB
testcase_80 WA -
testcase_81 AC 50 ms
11,576 KB
testcase_82 AC 38 ms
11,052 KB
testcase_83 AC 40 ms
11,300 KB
testcase_84 AC 33 ms
7,928 KB
testcase_85 AC 5 ms
5,376 KB
testcase_86 AC 32 ms
8,012 KB
testcase_87 AC 45 ms
11,504 KB
testcase_88 AC 19 ms
5,924 KB
testcase_89 AC 36 ms
6,400 KB
testcase_90 AC 18 ms
5,376 KB
testcase_91 AC 40 ms
6,656 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:63:21: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
   63 |         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 (ll i = 0; i < N; i++) {
		ll mi = p[0].second - B * i * p[0].first;
		ll lb = 0, ub = M - 1;
		while (ub - lb > 1) {
			ll mid = (lb + ub) / 2;
			ll x1 = p[mid].second - B * i * p[mid].first;
			ll x2 = p[mid + 1].second - B * i * p[mid + 1].first;
			if (x1 > x2) lb = mid;
			else ub = mid;
			mi = min(mi, min(x1, x2));
		}
		mi += i*(i+1)/2 * B - i * A + D[i];
		ans = mi;
		i_ll _p(i + 1, mi + i*(i+1)/2 * B + (i+1) * A);
		for (; M >= 2 && (p[M - 1].second - p[M - 2].second) * (_p.first - p[M - 1].first) >= (_p.second - p[M - 1].second) * (p[M - 1].first - p[M - 2].first); M--, p.pop_back());
		M++; p.push_back(_p);
		
	}
	cout << W + ans << endl;
}
0