結果

問題 No.817 Coin donation
ユーザー O2MTO2MT
提出日時 2020-08-28 15:42:33
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 421 ms / 2,000 ms
コード長 369 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 10,964 KB
実行使用メモリ 27,920 KB
最終ジャッジ日時 2023-08-08 19:44:08
合計ジャッジ時間 3,526 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,764 KB
testcase_01 AC 15 ms
7,780 KB
testcase_02 AC 15 ms
7,820 KB
testcase_03 AC 16 ms
7,768 KB
testcase_04 AC 16 ms
7,784 KB
testcase_05 AC 27 ms
8,592 KB
testcase_06 AC 67 ms
10,836 KB
testcase_07 AC 81 ms
11,304 KB
testcase_08 AC 287 ms
21,544 KB
testcase_09 AC 90 ms
11,796 KB
testcase_10 AC 416 ms
27,760 KB
testcase_11 AC 421 ms
27,920 KB
testcase_12 AC 418 ms
27,788 KB
testcase_13 AC 15 ms
7,932 KB
testcase_14 AC 15 ms
7,800 KB
testcase_15 AC 15 ms
7,852 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]

def func(x,AB):
  s = 0
  for a,b in AB:
    if x < a:
      continue
    if x > b:
      s += b-a+1
    elif a <= x <= b:
      s += x-a+1
  return s

r = 10**9+1
l = 0
while r-l > 1:
  mid = (r+l)//2
  s = func(mid,AB)
  if s >= K:
    r  = mid
  elif s < K:
    l = mid
print(r)
0