結果
問題 | No.2408 Lakes and Fish |
ユーザー | グミ |
提出日時 | 2023-08-11 21:47:10 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 224 ms / 2,000 ms |
コード長 | 463 bytes |
コンパイル時間 | 166 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 90,624 KB |
最終ジャッジ日時 | 2024-04-29 12:39:03 |
合計ジャッジ時間 | 4,967 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 44 ms
51,712 KB |
testcase_01 | AC | 42 ms
51,840 KB |
testcase_02 | AC | 43 ms
51,968 KB |
testcase_03 | AC | 42 ms
51,712 KB |
testcase_04 | AC | 184 ms
89,728 KB |
testcase_05 | AC | 183 ms
90,112 KB |
testcase_06 | AC | 192 ms
89,216 KB |
testcase_07 | AC | 222 ms
90,624 KB |
testcase_08 | AC | 224 ms
90,112 KB |
testcase_09 | AC | 220 ms
89,984 KB |
testcase_10 | AC | 221 ms
90,496 KB |
testcase_11 | AC | 164 ms
80,640 KB |
testcase_12 | AC | 185 ms
86,528 KB |
testcase_13 | AC | 126 ms
79,488 KB |
testcase_14 | AC | 151 ms
80,128 KB |
testcase_15 | AC | 196 ms
85,632 KB |
testcase_16 | AC | 132 ms
82,432 KB |
testcase_17 | AC | 127 ms
77,568 KB |
testcase_18 | AC | 157 ms
83,968 KB |
testcase_19 | AC | 196 ms
82,560 KB |
testcase_20 | AC | 192 ms
76,544 KB |
testcase_21 | AC | 196 ms
83,968 KB |
ソースコード
import bisect def main(): n,m=map(int,input().split()) ls=list(map(int,input().split())) ans = 0 for i in range(m): f,b,w=map(int,input().split()) idx = bisect.bisect(ls,f) cost = 10**10 if idx < n: cost1 = abs(f-ls[idx]) if cost1 < cost: cost = cost1 if 0 <= idx-1: cost2 = abs(f-ls[idx-1]) if cost2 < cost: cost = cost2 if cost < w-b: ans += w - cost else: ans += b print(ans) if __name__ == "__main__": main()