結果

問題 No.1715 Dinner 2
ユーザー square1001square1001
提出日時 2021-10-22 23:31:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 780 bytes
コンパイル時間 533 ms
コンパイル使用メモリ 68,700 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 15:41:06
合計ジャッジ時間 1,813 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 23 ms
4,348 KB
testcase_12 AC 20 ms
4,348 KB
testcase_13 AC 16 ms
4,348 KB
testcase_14 AC 17 ms
4,348 KB
testcase_15 AC 19 ms
4,348 KB
testcase_16 AC 18 ms
4,348 KB
testcase_17 AC 12 ms
4,348 KB
testcase_18 AC 1 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 1 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 4 ms
4,348 KB
testcase_26 AC 3 ms
4,348 KB
testcase_27 AC 3 ms
4,348 KB
testcase_28 AC 3 ms
4,348 KB
testcase_29 AC 3 ms
4,348 KB
testcase_30 AC 3 ms
4,348 KB
testcase_31 AC 3 ms
4,348 KB
testcase_32 AC 28 ms
4,348 KB
testcase_33 AC 28 ms
4,348 KB
testcase_34 AC 27 ms
4,348 KB
testcase_35 AC 30 ms
4,348 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <vector>
#include <iostream>
using namespace std;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int N, D;
	cin >> N >> D;
	vector<int> P(N), Q(N);
	for (int i = 0; i < N; ++i) {
		cin >> P[i] >> Q[i];
	}
	int l = -1, r = (1 << 29);
	while (r - l > 1) {
		int m = (l + r) >> 1;
		int genki = 0, prechoice = -1;
		bool flag = true;
		for (int i = 0; i < D; ++i) {
			int optchoice = -1, optscore = -(1 << 30);
			for (int j = 0; j < N; ++j) {
				if (j != prechoice && genki + P[j] <= m && optscore < Q[j] - P[j]) {
					optchoice = j;
					optscore = Q[j] - P[j];
				}
			}
			if (optchoice == -1) {
				flag = false;
				break;
			}
			genki -= optscore;
			prechoice = optchoice;
		}
		if (flag) r = m;
		else l = m;
	}
	cout << -r << endl;
	return 0;
}
0