結果
問題 | No.390 最長の数列 |
ユーザー | 👑 obakyan |
提出日時 | 2019-07-18 22:20:20 |
言語 | Lua (LuaJit 2.1.1696795921) |
結果 |
AC
|
実行時間 | 2,297 ms / 5,000 ms |
コード長 | 763 bytes |
コンパイル時間 | 262 ms |
コンパイル使用メモリ | 5,304 KB |
実行使用メモリ | 4,664 KB |
最終ジャッジ日時 | 2023-08-26 20:35:25 |
合計ジャッジ時間 | 6,398 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | AC | 1 ms
4,380 KB |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | AC | 1 ms
4,384 KB |
testcase_04 | AC | 1 ms
4,380 KB |
testcase_05 | AC | 74 ms
4,492 KB |
testcase_06 | AC | 2,297 ms
4,552 KB |
testcase_07 | AC | 1 ms
4,380 KB |
testcase_08 | AC | 1 ms
4,380 KB |
testcase_09 | AC | 3 ms
4,380 KB |
testcase_10 | AC | 396 ms
4,560 KB |
testcase_11 | AC | 432 ms
4,632 KB |
testcase_12 | AC | 412 ms
4,556 KB |
testcase_13 | AC | 706 ms
4,568 KB |
testcase_14 | AC | 403 ms
4,664 KB |
testcase_15 | AC | 1 ms
4,376 KB |
testcase_16 | AC | 1 ms
4,380 KB |
testcase_17 | AC | 11 ms
4,380 KB |
testcase_18 | AC | 20 ms
4,376 KB |
ソースコード
local mfl = math.floor local mma = math.max local function lower_bound(ary, x, min, k) local max = #ary if(x <= ary[min]) then return min end if(ary[max] < x) then return max + 1 end while(1 < max - min) do local mid = mfl((min + max) / 2) if(ary[mid] < x) then min = mid else max = mid end end return max end local n = io.read("*n") local t, len = {}, {} for i = 1, n do t[i] = io.read("*n") len[i] = 1 end table.sort(t) for i = n - 1, 1, -1 do local k = 2 local pos = i + 1 while pos <= n do pos = lower_bound(t, k * t[i], pos) if k * t[i] == t[pos] then len[i] = mma(len[i], len[pos] + 1) end k = k + 1 end end local ret = 1 for i = 1, n - 1 do ret = mma(ret, len[i]) end print(ret)