結果

問題 No.2027 (1, 2, 3, …, N) 's Subset Sum
ユーザー 👑 obakyanobakyan
提出日時 2022-08-06 00:40:11
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 182 ms / 2,000 ms
コード長 265 bytes
コンパイル時間 275 ms
コンパイル使用メモリ 5,332 KB
実行使用メモリ 12,052 KB
最終ジャッジ日時 2023-10-14 02:57:47
合計ジャッジ時間 3,859 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,356 KB
testcase_02 AC 179 ms
10,928 KB
testcase_03 AC 1 ms
4,352 KB
testcase_04 AC 179 ms
11,544 KB
testcase_05 AC 182 ms
11,516 KB
testcase_06 AC 182 ms
12,052 KB
testcase_07 AC 22 ms
4,348 KB
testcase_08 AC 129 ms
10,168 KB
testcase_09 AC 11 ms
4,348 KB
testcase_10 AC 56 ms
5,836 KB
testcase_11 AC 18 ms
4,348 KB
testcase_12 AC 33 ms
4,596 KB
testcase_13 AC 26 ms
4,372 KB
testcase_14 AC 12 ms
4,352 KB
testcase_15 AC 25 ms
4,352 KB
testcase_16 AC 42 ms
4,880 KB
testcase_17 AC 1 ms
4,352 KB
testcase_18 AC 2 ms
4,352 KB
testcase_19 AC 2 ms
4,352 KB
testcase_20 AC 1 ms
4,348 KB
testcase_21 AC 1 ms
4,352 KB
testcase_22 AC 93 ms
7,228 KB
testcase_23 AC 47 ms
4,920 KB
testcase_24 AC 14 ms
4,352 KB
testcase_25 AC 119 ms
10,516 KB
testcase_26 AC 24 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local n, s = io.read("*n", "*n")
local t = {}
for i = n, 1, -1 do
  if i <= s then
    table.insert(t, i)
    s = s - i
  end
end
for i = 1, #t do
  local j = #t + 1 - i
  if j <= i then break end
  t[i], t[j] = t[j], t[i]
end
print(#t)
print(table.concat(t, " "))
0