結果
問題 | No.409 ダイエット |
ユーザー |
![]() |
提出日時 | 2016-08-06 11:58:33 |
言語 | Fortran (gFortran 14.2.0) |
結果 |
AC
|
実行時間 | 65 ms / 2,000 ms |
コード長 | 733 bytes |
コンパイル時間 | 357 ms |
コンパイル使用メモリ | 32,768 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-26 09:47:04 |
合計ジャッジ時間 | 4,327 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 92 |
ソースコード
program mainimplicit noneinteger*8::N,A,B,W,i,str,str_max,tmp,dp_mininteger*8,allocatable::D(:)integer*8,allocatable::dp(:)read *, N,A,B,Wallocate(D(N))allocate(dp(0:N))read *, Dif(B.eq.0) thenprint '(i0)', (W-N*A)returnend ifdp(0) = Wdp(1) = W - A + B*1dp(0) = W + D(1)str_max = 0tmp = MIN(dp(0),dp(1))do i=2,Nif(tmp.eq.dp(0)) thenstr_max = 0elsestr_max = MIN(str_max + 1, (D(i)+A)/B)end iftmp = tmp + D(i)dp_min = tmpdo str=str_max+1,1,-1dp(str) = dp(str-1) - A + B*strdp_min = MIN(dp_min, dp(str))end dodp(0) = tmptmp = dp_minend doprint '(i0)', tmpend program main