結果
問題 |
No.4 おもりと天秤
|
ユーザー |
![]() |
提出日時 | 2016-07-23 19:44:41 |
言語 | Fortran (gFortran 14.2.0) |
結果 |
AC
|
実行時間 | 4 ms / 5,000 ms |
コード長 | 622 bytes |
コンパイル時間 | 146 ms |
コンパイル使用メモリ | 33,024 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-26 09:37:02 |
合計ジャッジ時間 | 940 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
ソースコード
program main implicit none integer::N,total,i,j, total_weight integer::W(100) integer::dp_memo(0:5000,1:101) data dp_memo/505101*0/ read *, N, W(1:N) total = SUM(W(1:N)) if(MOD(total,2).eq.1) then print '(a)','impossible' return end if do i=N,1,-1 do j=0,total/2 if(j.lt.W(i)) then dp_memo(j,i) = dp_memo(j, i+1) else dp_memo(j,i) = MAX(dp_memo(j,i+1),dp_memo(j-W(i), i+1)+W(i)) endif end do end do if(dp_memo(total/2, 1).eq.total/2) then print '(a)','possible' else print '(a)','impossible' end if end program main