結果

問題 No.527 ナップサック容量問題
ユーザー 37zigen37zigen
提出日時 2018-04-10 22:39:25
言語 Fortran
(gFortran 13.2.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 644 bytes
コンパイル時間 689 ms
コンパイル使用メモリ 27,188 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-09 03:55:01
合計ジャッジ時間 2,455 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 2 ms
4,380 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 14 ms
4,380 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 18 ms
4,384 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 7 ms
4,380 KB
testcase_15 AC 11 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 9 ms
4,380 KB
testcase_18 AC 11 ms
4,384 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 8 ms
4,380 KB
testcase_21 AC 20 ms
4,380 KB
testcase_22 AC 14 ms
4,376 KB
testcase_23 AC 20 ms
4,380 KB
testcase_24 AC 5 ms
4,376 KB
testcase_25 WA -
testcase_26 AC 12 ms
4,380 KB
testcase_27 AC 12 ms
4,384 KB
testcase_28 WA -
testcase_29 AC 20 ms
4,380 KB
testcase_30 WA -
testcase_31 AC 9 ms
4,380 KB
testcase_32 AC 12 ms
4,380 KB
testcase_33 AC 10 ms
4,380 KB
testcase_34 AC 12 ms
4,380 KB
testcase_35 AC 12 ms
4,376 KB
testcase_36 WA -
testcase_37 AC 9 ms
4,380 KB
testcase_38 AC 12 ms
4,376 KB
testcase_39 AC 10 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.f90:12:10:

     do i=0,size(g)
                  2
         g(i)=0
          1
Warning: Array reference at (1) out of bounds (100001 > 100000) in loop beginning at (2)
Main.f90:12:0:

         g(i)=0
 
Warning: iteration 100001 invokes undefined behavior [-Waggressive-loop-optimizations]
Main.f90:11:0:

     do i=0,size(g)
 
note: within this loop

ソースコード

diff #

program main
    implicit none
    integer::n,m,i,j,k,v(100),w(100),valTarget,valMax=0,ma=-1,mi=1000000
    integer::g(0:100000)
    read*,n
    do i=1,n
        read(*,*)v(i),w(i)
        valMax=valMax+v(i)
    end do
    read*,valTarget
    do i=0,size(g)
        g(i)=0
    end do
    do i=1,n
        do j=100000-w(i),0,-1
            g(j+w(i))=max(g(j+w(i)),g(j)+v(i))
        end do
    end do
    do i=1,size(g)-1
        if(g(i)==valTarget)then
            mi=min(mi,i)
            ma=max(ma,i)
        end if
    end do
    print*,mi
    if(valMax==valTarget)then
        print*,"inf"
    else
        print*,ma
    end if
end program
0