結果

問題 No.1619 Coccinellidae
ユーザー simansiman
提出日時 2022-05-04 15:10:45
言語 Ruby
(3.3.0)
結果
AC  
実行時間 161 ms / 2,000 ms
コード長 284 bytes
コンパイル時間 47 ms
コンパイル使用メモリ 11,356 KB
実行使用メモリ 18,028 KB
最終ジャッジ日時 2023-09-16 18:14:42
合計ジャッジ時間 3,708 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
15,080 KB
testcase_01 AC 147 ms
17,092 KB
testcase_02 AC 153 ms
18,028 KB
testcase_03 AC 80 ms
15,256 KB
testcase_04 AC 161 ms
17,776 KB
testcase_05 AC 121 ms
16,676 KB
testcase_06 AC 77 ms
15,036 KB
testcase_07 AC 130 ms
16,868 KB
testcase_08 AC 125 ms
16,820 KB
testcase_09 AC 77 ms
15,228 KB
testcase_10 AC 121 ms
16,616 KB
testcase_11 AC 136 ms
17,312 KB
testcase_12 AC 74 ms
15,336 KB
testcase_13 AC 158 ms
17,684 KB
testcase_14 AC 157 ms
17,756 KB
testcase_15 AC 78 ms
15,300 KB
testcase_16 AC 79 ms
15,072 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, M, K = gets.split.map(&:to_i)
tail = [*0..N - 2]
S = M - tail.sum
tail.push(S)

top = []
k = K

while k > 0 && tail.size > 0
  l = tail.size
  v = tail.pop

  if k >= l - 1
    k -= (l - 1)
    top.push(v)
  else
    tail.insert(-(k + 1), v)
    break
  end
end

puts (top + tail)
0