結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
53,888 KB
testcase_01 AC 54 ms
53,760 KB
testcase_02 AC 54 ms
53,632 KB
testcase_03 AC 54 ms
53,760 KB
testcase_04 AC 54 ms
53,760 KB
testcase_05 WA -
testcase_06 AC 55 ms
53,632 KB
testcase_07 AC 54 ms
53,632 KB
testcase_08 AC 55 ms
53,888 KB
testcase_09 AC 54 ms
53,760 KB
testcase_10 AC 54 ms
53,760 KB
testcase_11 AC 55 ms
53,632 KB
testcase_12 AC 55 ms
53,632 KB
testcase_13 AC 54 ms
53,632 KB
testcase_14 AC 54 ms
53,632 KB
testcase_15 AC 54 ms
53,760 KB
testcase_16 AC 53 ms
54,144 KB
testcase_17 WA -
testcase_18 AC 53 ms
53,632 KB
testcase_19 AC 55 ms
53,888 KB
testcase_20 AC 54 ms
53,888 KB
testcase_21 AC 54 ms
53,760 KB
testcase_22 AC 55 ms
53,760 KB
testcase_23 AC 54 ms
53,632 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 55 ms
53,632 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 54 ms
53,632 KB
testcase_31 AC 54 ms
53,760 KB
testcase_32 AC 54 ms
53,376 KB
testcase_33 AC 55 ms
53,632 KB
testcase_34 WA -
testcase_35 AC 118 ms
76,672 KB
testcase_36 AC 114 ms
77,056 KB
testcase_37 AC 116 ms
77,056 KB
testcase_38 WA -
testcase_39 AC 114 ms
76,680 KB
testcase_40 AC 109 ms
76,928 KB
testcase_41 AC 107 ms
77,056 KB
testcase_42 WA -
testcase_43 AC 96 ms
73,984 KB
testcase_44 AC 113 ms
76,800 KB
testcase_45 AC 108 ms
76,928 KB
testcase_46 AC 110 ms
76,800 KB
testcase_47 AC 115 ms
76,800 KB
testcase_48 AC 110 ms
76,672 KB
testcase_49 AC 110 ms
76,544 KB
testcase_50 AC 115 ms
76,800 KB
testcase_51 AC 117 ms
76,656 KB
testcase_52 AC 111 ms
77,056 KB
testcase_53 AC 109 ms
76,672 KB
testcase_54 AC 116 ms
76,800 KB
testcase_55 AC 238 ms
96,896 KB
testcase_56 AC 239 ms
119,168 KB
testcase_57 AC 297 ms
117,376 KB
testcase_58 WA -
testcase_59 AC 239 ms
102,656 KB
testcase_60 AC 210 ms
92,672 KB
testcase_61 WA -
testcase_62 AC 272 ms
118,784 KB
testcase_63 AC 279 ms
114,176 KB
testcase_64 AC 219 ms
96,256 KB
testcase_65 AC 310 ms
114,688 KB
testcase_66 WA -
testcase_67 AC 258 ms
109,952 KB
testcase_68 AC 244 ms
102,784 KB
testcase_69 AC 286 ms
114,304 KB
testcase_70 AC 276 ms
103,692 KB
testcase_71 AC 206 ms
95,616 KB
testcase_72 AC 313 ms
113,504 KB
testcase_73 AC 280 ms
107,216 KB
testcase_74 WA -
testcase_75 WA -
testcase_76 AC 243 ms
107,392 KB
testcase_77 AC 242 ms
95,488 KB
testcase_78 AC 202 ms
97,920 KB
testcase_79 WA -
testcase_80 AC 299 ms
109,904 KB
testcase_81 AC 312 ms
107,304 KB
testcase_82 AC 250 ms
107,648 KB
testcase_83 WA -
testcase_84 AC 217 ms
104,320 KB
testcase_85 AC 122 ms
77,568 KB
testcase_86 AC 244 ms
101,376 KB
testcase_87 AC 274 ms
103,800 KB
testcase_88 AC 192 ms
91,008 KB
testcase_89 AC 299 ms
107,648 KB
testcase_90 AC 204 ms
89,088 KB
testcase_91 AC 278 ms
111,488 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, N
  while rb - lb > 1:
    mid = lb + rb >> 1
    if get_cost( x, mid ) >= get_cost( i, mid ):
      rb = mid
    else:
      lb = mid
  if rb - lb != 1: continue
  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