結果
問題 | No.2408 Lakes and Fish |
ユーザー |
![]() |
提出日時 | 2023-08-13 14:32:24 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,073 bytes |
コンパイル時間 | 229 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 28,820 KB |
最終ジャッジ日時 | 2024-05-01 07:30:26 |
合計ジャッジ時間 | 11,537 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 32 ms
10,752 KB |
testcase_01 | AC | 33 ms
10,752 KB |
testcase_02 | AC | 33 ms
10,752 KB |
testcase_03 | AC | 30 ms
10,880 KB |
testcase_04 | AC | 619 ms
28,104 KB |
testcase_05 | AC | 621 ms
28,232 KB |
testcase_06 | AC | 611 ms
28,092 KB |
testcase_07 | AC | 700 ms
28,820 KB |
testcase_08 | AC | 695 ms
27,604 KB |
testcase_09 | AC | 683 ms
27,800 KB |
testcase_10 | AC | 690 ms
27,660 KB |
testcase_11 | AC | 389 ms
19,816 KB |
testcase_12 | WA | - |
testcase_13 | AC | 141 ms
14,964 KB |
testcase_14 | AC | 297 ms
17,992 KB |
testcase_15 | AC | 567 ms
25,144 KB |
testcase_16 | AC | 171 ms
16,472 KB |
testcase_17 | AC | 175 ms
14,692 KB |
testcase_18 | AC | 312 ms
19,260 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | AC | 586 ms
25,472 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 #Lの先頭と末尾に番兵を追加することで場合分けが不要になる INF = 1000000010 L[:0] = [-INF] L.append(INF) 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)