結果

問題 No.817 Coin donation
ユーザー to10to10to10toto10to10to10to
提出日時 2019-04-20 00:10:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 703 bytes
コンパイル時間 1,456 ms
コンパイル使用メモリ 167,108 KB
実行使用メモリ 5,200 KB
最終ジャッジ日時 2023-10-24 16:35:03
合計ジャッジ時間 2,722 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 WA -
testcase_04 WA -
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 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define reps(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   reps(i,0,n)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define PI (acos(-1))

ll N,K;
ll A[100010],B[100010];
bool isOK(ll x){//x円以下のコインがk枚以上存在するか
  ll cnt=0;
  rep(i,N){
    cnt += (min(B[i],x)-A[i])+1;
    if(cnt >= K)return true;
  }
  return false;
}

int main(){
  cin >> N >> K;
  rep(i,N){
    cin >> A[i] >> B[i];
  }

  ll ok = 1e9+7, ng = 0;
  while(abs(ok-ng)>1){
    ll mid = (ok+ng)/2;
    if(isOK(mid)){
      ok = mid;
    }else{
      ng = mid;
    }
  }
  cout << ok << endl;
}
0