結果
| 問題 |
No.817 Coin donation
|
| コンテスト | |
| ユーザー |
a
|
| 提出日時 | 2019-04-19 21:44:56 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 85 ms / 2,000 ms |
| コード長 | 500 bytes |
| コンパイル時間 | 1,708 ms |
| コンパイル使用メモリ | 169,712 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-22 18:10:00 |
| 合計ジャッジ時間 | 2,598 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 14 |
ソースコード
#include "bits/stdc++.h"
using namespace std;
void solve()
{
int n, k;
cin >> n >> k;
vector<long> as(n), bs(n);
for (int i = 0; i < n; i++)
{
cin >> as[i] >> bs[i];
}
int ng = 0, ok = 1e9;
while(ng+1<ok)
{
int x = (ok + ng) / 2;
long res = 0;
for (int i = 0; i < n; i++)
{
if (as[i] > x) continue;
res += min(bs[i] - as[i], x - as[i]) + 1;
}
(res >= k ? ok : ng) = x;
}
cout << ok << endl;
}
int main()
{
solve();
//cout << "yui(*-v・)yui" << endl;
return 0;
}
a