結果

問題 No.2493 K-th in L2 with L1
ユーザー osada-yumosada-yum
提出日時 2023-10-06 22:42:15
言語 Fortran
(gFortran 13.2.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 973 bytes
コンパイル時間 805 ms
コンパイル使用メモリ 26,636 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-10-06 22:42:17
合計ジャッジ時間 1,482 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

program yukicoder_2493
  use, intrinsic :: iso_fortran_env
  implicit none
  integer(int32) :: q, d, k
  integer(int32) :: lt_points, le_points
  integer(int32) :: x, y
  integer(int32) :: i
  read(input_unit, *) q
  query: do i = 1, q
     read(input_unit, *) d, k
     if (d == 0) then
        if (k == 1) then
           write(output_unit, '(a)') "Yes"
           write(output_unit, '(*(i0, 1x))') 0, 0
        else
           write(output_unit, '(a)') "No"
        end if
        cycle query
     end if
     lt_points = 0_int32
     le_points = 0_int32
     do x = d / 2, 0, -1
        y = d - x
        lt_points = le_points
        le_points = le_points + merge(4, 8, 2 * x == d .or. x == 0)
        if (lt_points < k .and. le_points >= k) then
           write(output_unit, '(a)') "Yes"
           write(output_unit, '(*(i0, 1x))') x, y
           cycle query
        end if
     end do
     write(output_unit, '(a)') "No"
  end do query
end program yukicoder_2493
0