結果

問題 No.2492 Knapsack Problem?
ユーザー osada-yumosada-yum
提出日時 2023-10-06 21:33:30
言語 Fortran
(gFortran 13.2.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 508 bytes
コンパイル時間 1,613 ms
コンパイル使用メモリ 27,884 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-10-06 21:33:32
合計ジャッジ時間 2,340 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

program yukicoder_2492
  use, intrinsic :: iso_fortran_env
  implicit none
  integer(int32) :: n, w
  integer(int32), allocatable :: vs(:), ws(:), ws_le_idx(:)
  integer(int32) :: i
  read(input_unit, *) n, w
  allocate(vs(n), ws(n))
  do i = 1, n
     read(input_unit, *) vs(i), ws(i)
  end do
  ws_le_idx = pack([(i, i = 1, n)], ws(:) <= w)
  if (size(ws_le_idx) == 0) then
     write(output_unit, '(i0)') -1
  else
     write(output_unit, '(i0)') maxval(vs(ws_le_idx))
  end if
end program yukicoder_2492
0