結果
| 問題 | No.817 Coin donation |
| コンテスト | |
| ユーザー |
azbrugby
|
| 提出日時 | 2019-05-04 15:35:51 |
| 言語 | C++11 (gcc 15.3.0 + boost 1.92.0) |
| 結果 |
AC
不安定
|
| 実行時間 | 57 ms / 2,000 ms |
| + 196µs | |
| コード長 | 730 bytes |
| 記録 | |
| コンパイル時間 | 517 ms |
| コンパイル使用メモリ | 90,312 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-10-14 10:14:10 |
| 合計ジャッジ時間 | 2,057 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 16 |
ソースコード
#include <iostream>
#include <algorithm>
#include <cstring>
#include <sstream>
#include <map>
#include <queue>
#include <vector>
#include <climits>
#define scanf scanf_s
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pos;
const ll MOD = 1000000007,N=100010;
ll n, k;
pos ab[N];
bool ok(ll v1) {
ll kv = 0;
for (int i = 1; i <= n; i++) {
ll vv1 = ab[i].first, vv2 = ab[i].second;
kv += max((ll)0, min(v1, vv2) - vv1 + 1);
}
return kv >= k;
}
int main() {
cin >> n >> k;
for (int i = 1; i <= n; i++)cin >> ab[i].first >> ab[i].second;
ll mnv = 0, mxv = 1000000010;
while (mxv - mnv > 1) {
ll md = (mxv + mnv) / 2;
if (ok(md))mxv = md;
else mnv = md;
}
cout << mxv << endl;
return 0;
}
azbrugby