結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
15,124 KB
testcase_01 AC 171 ms
18,672 KB
testcase_02 AC 79 ms
15,144 KB
testcase_03 AC 79 ms
15,152 KB
testcase_04 AC 190 ms
18,440 KB
testcase_05 AC 169 ms
18,556 KB
testcase_06 AC 80 ms
15,132 KB
testcase_07 AC 79 ms
15,024 KB
testcase_08 AC 163 ms
17,516 KB
testcase_09 AC 175 ms
17,784 KB
testcase_10 AC 79 ms
15,324 KB
testcase_11 AC 80 ms
15,312 KB
testcase_12 AC 82 ms
15,316 KB
testcase_13 AC 80 ms
15,076 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 80 ms
15,032 KB
testcase_19 AC 80 ms
15,228 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

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