結果
| 問題 | No.90 品物の並び替え |
| コンテスト | |
| ユーザー |
1235486527
|
| 提出日時 | 2019-11-29 01:07:28 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 961 bytes |
| 記録 | |
| コンパイル時間 | 530 ms |
| コンパイル使用メモリ | 20,696 KB |
| 実行使用メモリ | 15,520 KB |
| 最終ジャッジ日時 | 2026-05-14 11:43:40 |
| 合計ジャッジ時間 | 2,391 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 2 WA * 7 |
ソースコード
from collections import defaultdict
def culc_inc(n, m):
if m in D[n]:
return D[n][m]
else:
return 0
def insertion():
sum = 0
L = [NL.pop()]
while NL:
inc = 0
inc_L = 0
inc_R = 0
max_inc = 0
max_index = 0
n = NL.pop()
lng = len(L)
for i in reversed(range(lng)):
inc_R = culc_inc(L[i], n) + inc_L
inc_L += culc_inc(n, L[i])
inc = max(inc_L, inc_R)
if inc > max_inc:
max_inc = inc
if inc_L < inc_R:
max_index = i+1
else:
max_index = i
L.insert(max_index, n)
sum += max_inc
return sum
N, M = map(int,input().split())
NL = [i for i in range(N)]
D = defaultdict(dict)
for i in range(M):
item1, item2, score = map(int,input().split())
D2 = {item2: score}
D[item1].update(D2)
print(insertion())
1235486527