結果

問題 No.409 ダイエット
ユーザー 0w10w1
提出日時 2017-08-16 02:45:37
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 957 bytes
コンパイル時間 205 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 19,432 KB
最終ジャッジ日時 2024-04-21 12:41:54
合計ジャッジ時間 7,845 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
16,256 KB
testcase_01 AC 25 ms
10,880 KB
testcase_02 AC 27 ms
10,880 KB
testcase_03 AC 29 ms
10,752 KB
testcase_04 AC 30 ms
10,880 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 28 ms
10,752 KB
testcase_08 WA -
testcase_09 AC 25 ms
11,008 KB
testcase_10 AC 24 ms
10,880 KB
testcase_11 AC 24 ms
10,880 KB
testcase_12 WA -
testcase_13 AC 25 ms
10,880 KB
testcase_14 AC 26 ms
10,880 KB
testcase_15 AC 26 ms
10,880 KB
testcase_16 AC 27 ms
10,880 KB
testcase_17 WA -
testcase_18 AC 26 ms
10,880 KB
testcase_19 AC 25 ms
10,880 KB
testcase_20 AC 24 ms
10,752 KB
testcase_21 AC 26 ms
10,880 KB
testcase_22 WA -
testcase_23 AC 25 ms
10,880 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 25 ms
10,880 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 25 ms
10,752 KB
testcase_32 WA -
testcase_33 AC 25 ms
11,008 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 TLE -
testcase_56 TLE -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
testcase_67 -- -
testcase_68 -- -
testcase_69 -- -
testcase_70 -- -
testcase_71 -- -
testcase_72 -- -
testcase_73 -- -
testcase_74 -- -
testcase_75 -- -
testcase_76 -- -
testcase_77 -- -
testcase_78 -- -
testcase_79 -- -
testcase_80 -- -
testcase_81 -- -
testcase_82 -- -
testcase_83 -- -
testcase_84 -- -
testcase_85 -- -
testcase_86 -- -
testcase_87 -- -
testcase_88 -- -
testcase_89 -- -
testcase_90 -- -
testcase_91 -- -
権限があれば一括ダウンロードができます

ソースコード

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