結果

問題 No.817 Coin donation
ユーザー eQeeQe
提出日時 2020-02-23 16:19:06
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 93 ms / 2,000 ms
コード長 714 bytes
コンパイル時間 1,128 ms
コンパイル使用メモリ 157,992 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-18 09:29:18
合計ジャッジ時間 2,592 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 4 ms
6,940 KB
testcase_06 AC 14 ms
6,944 KB
testcase_07 AC 18 ms
6,940 KB
testcase_08 AC 64 ms
6,944 KB
testcase_09 AC 20 ms
6,940 KB
testcase_10 AC 90 ms
6,944 KB
testcase_11 AC 90 ms
6,940 KB
testcase_12 AC 93 ms
6,940 KB
testcase_13 AC 1 ms
6,944 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


ll N, K;
ll a[MAX], b[MAX];

ll C(ll x) {
  ll cnt=0;
  for(ll i=0; i<N; i++) {
    if(a[i]<=x) {
      cnt+=min(x-a[i], b[i]-a[i]);
    }
  }
  return cnt>=K;
}

int main(void) {
  cin >> N >> K;
  ll i;
  
  for(i=0; i<N; i++) {
    cin >> a[i] >> b[i];
    b[i]++;
  }
  
  ll l=0, r=INF;
  while(l+1<r) {
    ll mid=(l+r)/2;
    if(C(mid)) r=mid;
    else l=mid;
  }
  
  pt(l);
}





0