結果

問題 No.817 Coin donation
ユーザー どららどらら
提出日時 2019-04-19 21:59:07
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 761 bytes
コンパイル時間 1,632 ms
コンパイル使用メモリ 171,864 KB
実行使用メモリ 9,444 KB
最終ジャッジ日時 2023-10-24 02:15:25
合計ジャッジ時間 3,012 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int main(){
  int N, K;
  cin >> N >> K;
  vector<vector<int>> v;
  rep(i,N){
    int A, B;
    cin >> A >> B;
    v.push_back({A,B});
  }

  int lb = 0, ub = 1000000005;
  while(ub-lb>1){
    int m = ((ll)lb + ub)/2;

    int cnt = 0;
    rep(i,N){
      if(v[i][1] <= m) cnt += v[i][1] - v[i][0] + 1;
      else if(v[i][0] <= m && m < v[i][1]) cnt += m - v[i][0] + 1;
    }
    if(cnt<=K) lb = m;
    else ub = m;
  }

  cout << ub << endl;
  
  return 0;
}
0