結果

問題 No.409 ダイエット
ユーザー 0w10w1
提出日時 2017-08-16 02:57:13
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 958 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 119,552 KB
最終ジャッジ日時 2024-04-21 12:48:05
合計ジャッジ時間 14,031 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,760 KB
testcase_01 AC 41 ms
53,888 KB
testcase_02 AC 40 ms
53,632 KB
testcase_03 AC 42 ms
53,888 KB
testcase_04 AC 41 ms
53,760 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 40 ms
53,888 KB
testcase_08 WA -
testcase_09 AC 41 ms
53,632 KB
testcase_10 AC 40 ms
53,888 KB
testcase_11 AC 41 ms
53,760 KB
testcase_12 WA -
testcase_13 AC 42 ms
53,376 KB
testcase_14 AC 43 ms
54,016 KB
testcase_15 AC 41 ms
53,632 KB
testcase_16 AC 43 ms
53,888 KB
testcase_17 WA -
testcase_18 AC 41 ms
53,760 KB
testcase_19 AC 42 ms
53,760 KB
testcase_20 AC 43 ms
53,632 KB
testcase_21 AC 42 ms
53,760 KB
testcase_22 WA -
testcase_23 AC 42 ms
54,016 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 42 ms
53,632 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 41 ms
53,632 KB
testcase_32 WA -
testcase_33 AC 43 ms
53,760 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 AC 200 ms
119,296 KB
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
testcase_62 WA -
testcase_63 WA -
testcase_64 WA -
testcase_65 AC 227 ms
114,560 KB
testcase_66 WA -
testcase_67 WA -
testcase_68 WA -
testcase_69 WA -
testcase_70 WA -
testcase_71 WA -
testcase_72 WA -
testcase_73 WA -
testcase_74 WA -
testcase_75 WA -
testcase_76 WA -
testcase_77 WA -
testcase_78 WA -
testcase_79 WA -
testcase_80 WA -
testcase_81 WA -
testcase_82 WA -
testcase_83 WA -
testcase_84 WA -
testcase_85 WA -
testcase_86 WA -
testcase_87 WA -
testcase_88 WA -
testcase_89 AC 216 ms
108,032 KB
testcase_90 AC 164 ms
89,472 KB
testcase_91 AC 214 ms
111,744 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

N, A, B, W = map( int, input().split() )
D = list( map( int, input().split() ) )
dp = [ 0 for i in range( N + 1 ) ]

def get_cost( x, rb ):
  d = rb - x - 1
  return dp[ x ] + d * ( d + 1 ) // 2 * B - d * A + D[ rb - 1 ]

dq = deque()
dp[ 0 ] = W
dq.append( [ 0, 1, N ] )
for i in range( 1, N + 1 ):
  while dq[ 0 ][ 2 ] < i:
    dq.popleft()
  dp[ i ] = get_cost( dq[ 0 ][ 0 ], i )
  while len( dq ):
    x, lb, rb = dq[ len( dq ) - 1 ]
    if get_cost( x, lb ) >= get_cost( i, lb ):
      dq.pop()
      if len( dq ):
        dq[ len( dq ) - 1 ][ 2 ] = N
    else:
      break
  x, lb, rb = dq[ len( dq ) - 1 ][ 0 ], i + 1, N
  while rb - lb > 1:
    mid = lb + rb >> 1
    if get_cost( x, mid ) >= get_cost( i, mid ):
      rb = mid
    else:
      lb = mid
  dq[ len( dq ) - 1 ][ 2 ] = rb - 1
  dq.append( [ i, rb, N ] )

print( min( dp[ i ] + ( N - i ) * ( N - i + 1 ) // 2 * B - ( N - i ) * A for i in range( N + 1 ) ) )
0