結果

問題 No.4 おもりと天秤
ユーザー jjjj
提出日時 2016-07-23 19:42:38
言語 Fortran
(gFortran 13.2.0)
結果
RE  
実行時間 -
コード長 619 bytes
コンパイル時間 254 ms
コンパイル使用メモリ 32,640 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 08:02:12
合計ジャッジ時間 2,023 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 RE -
testcase_06 AC 1 ms
5,376 KB
testcase_07 RE -
testcase_08 AC 1 ms
5,376 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

program main
  implicit none
  integer::N,total,i,j, total_weight
  integer::W(100)
  integer::dp_memo(0:5000,1:100)
  data dp_memo/500100*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
0