結果

問題 No.817 Coin donation
ユーザー O2MTO2MT
提出日時 2020-08-28 15:42:33
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 517 ms / 2,000 ms
コード長 369 bytes
コンパイル時間 160 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 30,464 KB
最終ジャッジ日時 2024-04-26 12:10:43
合計ジャッジ時間 3,741 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,752 KB
testcase_01 AC 28 ms
10,752 KB
testcase_02 AC 28 ms
10,752 KB
testcase_03 AC 28 ms
10,752 KB
testcase_04 AC 28 ms
10,880 KB
testcase_05 AC 42 ms
11,264 KB
testcase_06 AC 93 ms
13,312 KB
testcase_07 AC 110 ms
13,952 KB
testcase_08 AC 358 ms
24,320 KB
testcase_09 AC 126 ms
14,720 KB
testcase_10 AC 517 ms
30,464 KB
testcase_11 AC 510 ms
30,464 KB
testcase_12 AC 500 ms
30,464 KB
testcase_13 AC 28 ms
10,880 KB
testcase_14 AC 28 ms
10,752 KB
testcase_15 AC 28 ms
10,880 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