結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 83 ms
15,256 KB
testcase_03 AC 80 ms
15,088 KB
testcase_04 AC 190 ms
18,468 KB
testcase_05 WA -
testcase_06 AC 80 ms
15,272 KB
testcase_07 WA -
testcase_08 AC 167 ms
17,628 KB
testcase_09 WA -
testcase_10 AC 80 ms
15,260 KB
testcase_11 AC 80 ms
15,348 KB
testcase_12 AC 82 ms
15,104 KB
testcase_13 AC 79 ms
15,164 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 80 ms
15,340 KB
testcase_19 AC 79 ms
15,020 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

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

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

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

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

if cnt % 2 != 0
  puts 'No'
  exit
end

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

  (cnt / 2).times do
    values << queue.shift
  end
  (cnt / 2).times do
    values << queue.pop
  end

  puts values.join(' ')
end
0