結果

問題 No.817 Coin donation
ユーザー syunsukesyunsuke
提出日時 2019-04-19 22:04:04
言語 Python3
(3.10.1 + numpy 1.22.3 + scipy 1.8.0)
結果
AC  
実行時間 746 ms / 2,000 ms
コード長 646 bytes
コンパイル時間 333 ms
使用メモリ 29,720 KB
最終ジャッジ日時 2022-11-22 10:01:03
合計ジャッジ時間 4,584 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 17 ms
7,840 KB
testcase_01 AC 17 ms
7,840 KB
testcase_02 AC 17 ms
8,052 KB
testcase_03 AC 17 ms
7,940 KB
testcase_04 AC 17 ms
7,764 KB
testcase_05 AC 31 ms
8,800 KB
testcase_06 AC 90 ms
11,696 KB
testcase_07 AC 110 ms
11,868 KB
testcase_08 AC 497 ms
21,728 KB
testcase_09 AC 131 ms
12,160 KB
testcase_10 AC 729 ms
29,720 KB
testcase_11 AC 746 ms
29,660 KB
testcase_12 AC 740 ms
29,648 KB
testcase_13 AC 17 ms
7,704 KB
testcase_14 AC 17 ms
7,684 KB
testcase_15 AC 17 ms
7,776 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