結果
問題 | No.817 Coin donation |
ユーザー |
![]() |
提出日時 | 2019-04-20 07:21:02 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 87 ms / 2,000 ms |
コード長 | 558 bytes |
コンパイル時間 | 430 ms |
コンパイル使用メモリ | 56,284 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-25 03:35:54 |
合計ジャッジ時間 | 1,964 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 14 |
ソースコード
#include <iostream> using namespace std; typedef long long ll; int main(){ int n;ll k; cin>>n>>k; ll a[100001], b[100001]; for(int i=0; i<n; i++){ cin>>a[i]>>b[i]; } ll x1=0, x2=1e9+7; while(x1!=x2){ ll x=(x1+x2)/2; ll c=0; for(int i=0; i<n; i++){ if(x<a[i]) continue; if(x>=b[i]){ c+=(b[i]-a[i]+1); }else{ c+=(x-a[i]+1); } } if(c<k) x1=x+1; else x2=x; } cout<<x1<<endl; return 0; }