結果

問題 No.2567 A_1 > A_2 > ... > A_N
ユーザー ngng628ngng628
提出日時 2023-12-02 16:21:05
言語 Crystal
(1.11.2)
結果
AC  
実行時間 137 ms / 2,000 ms
コード長 310 bytes
コンパイル時間 10,988 ms
コンパイル使用メモリ 294,100 KB
実行使用メモリ 9,984 KB
最終ジャッジ日時 2023-12-02 16:21:18
合計ジャッジ時間 11,491 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 16 ms
6,912 KB
testcase_02 AC 19 ms
9,984 KB
testcase_03 AC 16 ms
9,836 KB
testcase_04 AC 20 ms
9,540 KB
testcase_05 AC 19 ms
9,836 KB
testcase_06 AC 116 ms
6,676 KB
testcase_07 AC 123 ms
6,676 KB
testcase_08 AC 137 ms
6,676 KB
testcase_09 AC 118 ms
6,676 KB
testcase_10 AC 121 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 4 ms
6,676 KB
testcase_13 AC 4 ms
6,676 KB
testcase_14 AC 4 ms
6,676 KB
testcase_15 AC 4 ms
6,676 KB
testcase_16 AC 4 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

t = read_line.to_i64
t.times do
  n, x = read_line.split.map &.to_i64
  a = [*(1_i64..n)].reverse
  if a.sum <= x
    t = x - a.sum
    k = t // n  # 全要素に k を足す
    r = t - k * n
    n.times do |i|
      a[i] += k
      a[i] += 1 if i < r
    end
    puts a.join(' ')
  else
    puts -1
  end
end
0