結果

問題 No.817 Coin donation
ユーザー ldsybldsyb
提出日時 2019-04-19 23:52:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 542 bytes
コンパイル時間 1,516 ms
コンパイル使用メモリ 169,084 KB
実行使用メモリ 4,828 KB
最終ジャッジ日時 2023-10-24 14:12:23
合計ジャッジ時間 2,943 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 3 ms
4,348 KB
testcase_06 AC 14 ms
4,348 KB
testcase_07 AC 17 ms
4,348 KB
testcase_08 AC 63 ms
4,348 KB
testcase_09 AC 20 ms
4,348 KB
testcase_10 AC 92 ms
4,828 KB
testcase_11 AC 92 ms
4,828 KB
testcase_12 AC 92 ms
4,828 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main()
{
	int64_t n, k;
	cin >> n >> k;
	vector<pair<int64_t, int64_t>> ps(n);
	for (auto &p : ps)
	{
		cin >> p.first >> p.second;
	}
	auto f = [](vector<pair<int64_t, int64_t>> &ps, int64_t x) {
		int64_t r = 0;
		for (auto &p : ps)
		{
			if (p.first <= x)
			{
				r += min(x, p.second) - p.first + 1;
			}
		}
		return r;
	};
	int64_t l = 0, r = (1LL << 60);
	while (1 < r - l)
	{
		int64_t mid = (l + r) / 2;
		((f(ps, mid) <= k) ? l : r) = mid;
	}
	cout << l + 1 << endl;
	return 0;
}
0