結果

問題 No.817 Coin donation
ユーザー 双六双六
提出日時 2019-04-19 22:32:33
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,211 ms / 2,000 ms
コード長 470 bytes
コンパイル時間 744 ms
コンパイル使用メモリ 11,868 KB
実行使用メモリ 46,068 KB
最終ジャッジ日時 2023-10-24 05:27:00
合計ジャッジ時間 6,338 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,184 KB
testcase_01 AC 29 ms
10,184 KB
testcase_02 AC 29 ms
10,192 KB
testcase_03 AC 29 ms
10,220 KB
testcase_04 AC 29 ms
10,184 KB
testcase_05 AC 46 ms
11,004 KB
testcase_06 AC 120 ms
14,624 KB
testcase_07 AC 147 ms
15,680 KB
testcase_08 AC 666 ms
32,928 KB
testcase_09 AC 172 ms
16,472 KB
testcase_10 AC 1,114 ms
46,068 KB
testcase_11 AC 1,134 ms
46,068 KB
testcase_12 AC 1,211 ms
46,068 KB
testcase_13 AC 30 ms
10,184 KB
testcase_14 AC 29 ms
10,184 KB
testcase_15 AC 29 ms
10,184 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