結果

問題 No.817 Coin donation
ユーザー tko919tko919
提出日時 2019-04-22 20:34:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,026 bytes
コンパイル時間 751 ms
コンパイル使用メモリ 93,504 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-20 04:44:44
合計ジャッジ時間 2,007 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define case(i) cout<<"Case #"<<i<<": "
using namespace std;
typedef long long int ll;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 4e18;



int main() {
	int n, k; cin >> n >> k;
	vector<pair<int, int>> a(n);
	rep(i, 0, n) cin >> a[i].first >> a[i].second;
	int l = 0, r = 1e9;
	while (abs(l - r) > 1) {
		int mid = (l + r) / 2;
		int cnt = 0;
		rep(i, 0, n) {
			if (a[i].first > mid) continue;
			if (a[i].first <= mid && a[i].second >= mid) {
				cnt += mid - a[i].first + 1;
			}
			else {
				cnt += a[i].second - a[i].first + 1;
			}
		}
		if (cnt >= k) r = mid;
		else l = mid;
	}
	cout << l+1 << endl;
	return 0;
}
0