結果

問題 No.817 Coin donation
ユーザー 双六双六
提出日時 2019-04-19 22:32:33
言語 Python3
(3.10.1 + numpy 1.22.3 + scipy 1.8.0)
結果
AC  
実行時間 1,283 ms / 2,000 ms
コード長 470 bytes
コンパイル時間 715 ms
使用メモリ 44,116 KB
最終ジャッジ日時 2022-11-22 13:29:03
合計ジャッジ時間 6,959 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 18 ms
7,928 KB
testcase_01 AC 18 ms
8,120 KB
testcase_02 AC 20 ms
8,020 KB
testcase_03 AC 20 ms
8,160 KB
testcase_04 AC 18 ms
7,936 KB
testcase_05 AC 36 ms
9,060 KB
testcase_06 AC 114 ms
12,668 KB
testcase_07 AC 134 ms
13,612 KB
testcase_08 AC 812 ms
30,876 KB
testcase_09 AC 160 ms
14,476 KB
testcase_10 AC 1,279 ms
43,976 KB
testcase_11 AC 1,252 ms
43,988 KB
testcase_12 AC 1,283 ms
44,116 KB
testcase_13 AC 19 ms
8,060 KB
testcase_14 AC 18 ms
8,056 KB
testcase_15 AC 19 ms
7,956 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

from heapq import heappop, heappush

def getlist():
	return list(map(int, input().split()))

N, K = getlist()
D = defaultdict(int)
for i in range(N):
	A, B = getlist()
	D[A] += 1
	D[B + 1] -= 1

L = []
for i in D:
	L.append([i, D[i]])

L = sorted(L)

Kval = K
n = 0
for i in range(len(L) - 1):
	n += L[i][1]
	a = L[i][0]
	b = L[i + 1][0]
	if (b - a) * n >= Kval:
		print(a + int((Kval - 1) // n))
		break
	else:
		Kval -= (b - a) * n
0