結果
| 問題 |
No.817 Coin donation
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-10-10 19:00:14 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 44 ms / 2,000 ms |
| コード長 | 619 bytes |
| コンパイル時間 | 2,220 ms |
| コンパイル使用メモリ | 196,224 KB |
| 最終ジャッジ日時 | 2025-02-08 01:15:15 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 14 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
int main(){
cin.tie(0);
ios::sync_with_stdio(0);
ll N,K; cin >> N >> K;
vector<ll> A(N), B(N);
rep(i,N) cin >> A[i] >> B[i];
cout << [&]() {
ll ng = 0, ok = 1e18;
while(ok - ng > 1) {
ll mid = (ok + ng) / 2;
([&](ll x) {
ll cnt = 0;
rep(i,N) cnt += max(0LL , min(x, B[i]) - A[i] + 1);
return cnt >= K;
}(mid) ? ok : ng) = mid;
}
return ok;
}() << endl;
}