結果
| 問題 |
No.817 Coin donation
|
| コンテスト | |
| ユーザー |
tomarint2
|
| 提出日時 | 2019-04-19 22:24:41 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 694 ms / 2,000 ms |
| コード長 | 547 bytes |
| コンパイル時間 | 292 ms |
| コンパイル使用メモリ | 82,328 KB |
| 実行使用メモリ | 112,504 KB |
| 最終ジャッジ日時 | 2024-09-22 21:40:07 |
| 合計ジャッジ時間 | 4,541 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 14 |
ソースコード
import collections
def solve():
N,K=map(int,input().split())
dn=collections.defaultdict(int)
for i in range(N):
a,b=map(int,input().split())
dn[a]+=1
dn[b+1]-=1
d1=list(dn.items())
d1.sort()
#print(d1)
d2=[]
b=1
d=0
for di in d1:
d2.append((b,di[0],d))
b=di[0]
d+=di[1]
#print(d2)
for di in d2:
if K > (di[1]-di[0])*di[2]:
K -= (di[1]-di[0])*di[2]
else:
return (K+di[2]-1) // di[2] + di[0] - 1
print(solve())
tomarint2