差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン前のリビジョン
次のリビジョン両方とも次のリビジョン
programming_algorithm:contest_history:atcoder:2019:0323_agc032 [2019/04/19] ikatakosprogramming_algorithm:contest_history:atcoder:2019:0323_agc032 [2019/04/19] ikatakos
行 363: 行 363:
  
 <sxh python> <sxh python>
-from collections import defaultdict +from bisect import bisect
-from operator import itemgetter+
  
 n, a, b = map(int, input().split()) n, a, b = map(int, input().split())
-ppp = list(map(int, input().split())) +ppp = map(int, input().split()) 
-qqq = list(map(itemgetter(0)sorted(enumerate(ppp, start=1), key=itemgetter(1))))+qqq = [0] * n 
 +for ip in enumerate(ppp, start=1)
 +    qqq[p - 1] i
  
-dp = {00}+dp = [(00)]
 for i in qqq: for i in qqq:
-    ndp defaultdict(lambda: 10 ** 18+    bisect(dp, (i,)
-    for j, cost in dp.items()+    ndp = [(j, cost + b) for j, cost in dp[:s]] 
-        if j < i: +    stay_cost = dp[s - 1][1] 
-            ndp[imin(ndp[i], cost) +    ndp.append((i, stay_cost)) 
-            ndp[j] = min(ndp[j], cost + b+    remain iter(dp[s:]
-        else: +    for j, cost in remain: 
-            ndp[j] = min(ndp[j], cost + a)+        if stay_cost > cost + a: 
 +            ndp.append((j, cost + a)
 +            break 
 +    ndp.extend((j, cost + a) for j, cost in remain)
     dp = ndp     dp = ndp
- +print(dp[-1][1])
-print(min(dp.values()))+
 </sxh> </sxh>
  
programming_algorithm/contest_history/atcoder/2019/0323_agc032.txt · 最終更新: 2019/04/21 by ikatakos
CC Attribution 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0