結果

問題 No.817 Coin donation
ユーザー to10to10to10toto10to10to10to
提出日時 2019-04-20 00:08:52
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 709 bytes
コンパイル時間 1,470 ms
コンパイル使用メモリ 166,816 KB
実行使用メモリ 4,392 KB
最終ジャッジ日時 2023-10-24 16:27:42
合計ジャッジ時間 2,898 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 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))

int N,K;
int A[100010],B[100010];
bool isOK(int x){//x円以下のコインがk枚以上存在するか
  int 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];
  }

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