結果
問題 | No.2408 Lakes and Fish |
ユーザー | irohasu19_ |
提出日時 | 2023-08-13 13:46:27 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 686 ms / 2,000 ms |
コード長 | 935 bytes |
コンパイル時間 | 210 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 28,720 KB |
最終ジャッジ日時 | 2024-05-01 06:58:45 |
合計ジャッジ時間 | 11,790 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 29 ms
11,008 KB |
testcase_01 | AC | 32 ms
10,880 KB |
testcase_02 | AC | 32 ms
11,008 KB |
testcase_03 | AC | 30 ms
11,008 KB |
testcase_04 | AC | 623 ms
28,136 KB |
testcase_05 | AC | 629 ms
28,260 KB |
testcase_06 | AC | 605 ms
27,664 KB |
testcase_07 | AC | 686 ms
28,720 KB |
testcase_08 | AC | 681 ms
28,080 KB |
testcase_09 | AC | 676 ms
28,212 KB |
testcase_10 | AC | 680 ms
28,016 KB |
testcase_11 | AC | 384 ms
20,320 KB |
testcase_12 | AC | 483 ms
23,028 KB |
testcase_13 | AC | 141 ms
15,124 KB |
testcase_14 | AC | 295 ms
17,748 KB |
testcase_15 | AC | 562 ms
25,820 KB |
testcase_16 | AC | 169 ms
16,564 KB |
testcase_17 | AC | 178 ms
14,720 KB |
testcase_18 | AC | 318 ms
19,292 KB |
testcase_19 | AC | 565 ms
24,244 KB |
testcase_20 | AC | 607 ms
23,668 KB |
testcase_21 | AC | 571 ms
24,824 KB |
ソースコード
import bisect n, m = map(int, input().split()) L = list(map(int, input().split())) F = [] B = [] W = [] for _ in range(m): li = list(map(int, input().split())) F.append(li[0]) B.append(li[1]) W.append(li[2]) total_cost = 0 is_move = [False]*m for i in range(m): ind_1 = bisect.bisect_left(L, F[i]) if ind_1>0 and ind_1 < n: ind_2 = ind_1 - 1 cost = min(abs(F[i]-L[ind_1]), abs(F[i]-L[ind_2])) if cost < (W[i]-B[i]) : is_move[i] = True total_cost += cost else: continue elif ind_1 == 0: cost = abs(F[i]-L[ind_1]) if cost < (W[i]-B[i]) : is_move[i] = True total_cost += cost elif ind_1 == n: cost = abs(F[i]-L[ind_1-1]) if cost < (W[i]-B[i]) : is_move[i] = True total_cost += cost total_score = 0 for j in range(m): if is_move[j]: total_score += W[j] else: total_score += B[j] total_score -= total_cost print(total_score)