結果
問題 | No.817 Coin donation |
ユーザー | 👑 Kazun |
提出日時 | 2021-02-10 17:53:26 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 192 ms / 2,000 ms |
コード長 | 1,199 bytes |
コンパイル時間 | 1,740 ms |
コンパイル使用メモリ | 87,092 KB |
実行使用メモリ | 83,044 KB |
最終ジャッジ日時 | 2023-09-22 12:37:06 |
合計ジャッジ時間 | 4,058 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 71 ms
71,376 KB |
testcase_01 | AC | 70 ms
71,460 KB |
testcase_02 | AC | 78 ms
75,508 KB |
testcase_03 | AC | 77 ms
75,360 KB |
testcase_04 | AC | 72 ms
71,448 KB |
testcase_05 | AC | 101 ms
76,860 KB |
testcase_06 | AC | 111 ms
77,892 KB |
testcase_07 | AC | 116 ms
77,512 KB |
testcase_08 | AC | 159 ms
81,812 KB |
testcase_09 | AC | 120 ms
78,184 KB |
testcase_10 | AC | 192 ms
82,792 KB |
testcase_11 | AC | 192 ms
82,872 KB |
testcase_12 | AC | 190 ms
83,044 KB |
testcase_13 | AC | 72 ms
71,380 KB |
testcase_14 | AC | 71 ms
71,304 KB |
testcase_15 | AC | 72 ms
71,264 KB |
ソースコード
def General_Binary_Increase_Search(L,R,cond,Integer=True,ep=1/(1<<20),Times=50): """条件式が単調増加であるとき,一般的な二部探索を行う. L:解の下限 R:解の上限 cond:条件(1変数関数,広義単調減少 or 広義単調減少を満たす) Integer:解を整数に制限するか? ep:Integer=Falseのとき,解の許容する誤差 """ if not(cond(R)): return None if cond(L): return L if Integer: R+=1 while R-L>1: C=L+(R-L)//2 if cond(C): R=C else: L=C return R else: while (R-L)>=ep and Times: Times-=1 C=L+(R-L)/2 if cond(C): R=C else: L=C return R #================================================ def check(x): M=0 for a,b in X: M+=max(0,min(b,x)-a+1) return M>=K #================================================ N,K=map(int,input().split()) X=[] Sum=0 for _ in range(N): a,b=map(int,input().split()) X.append((a,b)) Sum+=b-a+1 print(General_Binary_Increase_Search(0,10**10,check))