結果
| 問題 |
No.409 ダイエット
|
| ユーザー |
jj
|
| 提出日時 | 2016-08-06 00:59:49 |
| 言語 | Fortran (gFortran 14.2.0) |
| 結果 |
AC
|
| 実行時間 | 73 ms / 2,000 ms |
| コード長 | 738 bytes |
| コンパイル時間 | 383 ms |
| コンパイル使用メモリ | 33,280 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-26 09:44:31 |
| 合計ジャッジ時間 | 4,184 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 92 |
ソースコード
program main
implicit none
integer*8::N,A,B,W,i,str,str_max,tmp,uplimit
integer*8,allocatable::D(:)
integer*8,allocatable::dp(:)
read *, N,A,B,W
allocate(D(N))
allocate(dp(0:N))
read *, D
if(B.eq.0) then
print '(i0)', (W-N*A)
return
end if
dp(0) = W
dp(1) = W - A + B*1
dp(0) = W + D(1)
str_max = 1
do i=2,N
tmp = MINVAL(dp(0:str_max))
if(tmp.eq.dp(0)) then
!tabeta houga kanarazu yoi
str_max = 0
end if
!str ha tamesugi nai
str_max = MIN(str_max, (D(i)+A)/B)
do str=str_max+1,1,-1
dp(str) = dp(str-1) - A + B*str
end do
dp(0) = tmp + D(i)
str_max = str_max + 1
end do
print '(i0)', MINVAL(dp(0:str_max))
end program
jj