結果

問題 No.817 Coin donation
ユーザー syunsukesyunsuke
提出日時 2019-04-19 22:04:04
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 763 ms / 2,000 ms
コード長 646 bytes
コンパイル時間 377 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 31,816 KB
最終ジャッジ日時 2023-10-24 02:26:24
合計ジャッジ時間 4,805 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,144 KB
testcase_01 AC 31 ms
10,144 KB
testcase_02 AC 31 ms
10,148 KB
testcase_03 AC 32 ms
10,188 KB
testcase_04 AC 31 ms
10,144 KB
testcase_05 AC 47 ms
11,052 KB
testcase_06 AC 106 ms
13,924 KB
testcase_07 AC 127 ms
14,256 KB
testcase_08 AC 505 ms
24,088 KB
testcase_09 AC 148 ms
14,524 KB
testcase_10 AC 763 ms
31,816 KB
testcase_11 AC 761 ms
31,816 KB
testcase_12 AC 761 ms
31,816 KB
testcase_13 AC 30 ms
10,144 KB
testcase_14 AC 30 ms
10,144 KB
testcase_15 AC 31 ms
10,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect
N,K=map(int,input().split())
A=[]
B=[]
for i in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b+1)
    
C=A+B
D=set(C)
D=list(D)
D.sort()

F=[0 for i in range(len(D))]
for i in range(N):
    F[bisect.bisect_left(D,A[i])]+=1
    F[bisect.bisect_left(D,B[i])]-=1
E=[F[0]]
for i in range(1,len(F)):
    E.append(E[i-1]+F[i])
ans=0
#print(D)
#print(E)
for i in range(10**6):
    if (ans+E[i]*(D[i+1]-D[i]))>=K:
        if (K-ans)%E[i]==0:
            print(D[i]+(K-ans)//E[i]-1)
            exit()
        else:
            print(D[i]+(K-ans)//E[i])
            exit()
    else:
        ans+=(D[i+1]-D[i])*E[i]
0