結果

問題 No.942 プレゼント配り
ユーザー simansiman
提出日時 2022-02-17 01:16:56
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 406 bytes
コンパイル時間 480 ms
コンパイル使用メモリ 11,136 KB
実行使用メモリ 18,960 KB
最終ジャッジ日時 2023-09-11 17:20:47
合計ジャッジ時間 5,173 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
15,092 KB
testcase_01 AC 175 ms
18,528 KB
testcase_02 AC 84 ms
15,208 KB
testcase_03 AC 84 ms
15,340 KB
testcase_04 AC 206 ms
18,424 KB
testcase_05 AC 174 ms
18,468 KB
testcase_06 WA -
testcase_07 AC 85 ms
15,112 KB
testcase_08 AC 175 ms
17,796 KB
testcase_09 AC 187 ms
17,816 KB
testcase_10 AC 83 ms
15,296 KB
testcase_11 AC 83 ms
15,296 KB
testcase_12 AC 85 ms
15,088 KB
testcase_13 AC 84 ms
15,308 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 84 ms
15,028 KB
testcase_19 AC 83 ms
15,304 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, K = gets.split.map(&:to_i)

if K == 1
  puts 'Yes'
  puts [*1..N].join(' ')
  exit
end

if N % K != 0
  puts 'No'
  exit
end

S = N * (1 + N) / 2
cnt = N / K

if S % K != 0
  puts 'No'
  exit
end

queue = [*1..N]
puts 'Yes'
v = 1
K.times do
  values = []

  cnt.times do
    if v > 0
      values << queue.shift
    else
      values << queue.pop
    end

    v *= -1
  end

  puts values.join(' ')
end
0