結果
問題 | No.905 Sorted? |
ユーザー |
👑 |
提出日時 | 2019-10-11 22:03:46 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
AC
|
実行時間 | 153 ms / 2,000 ms |
コード長 | 819 bytes |
コンパイル時間 | 107 ms |
コンパイル使用メモリ | 6,820 KB |
実行使用メモリ | 13,876 KB |
最終ジャッジ日時 | 2024-11-25 07:30:46 |
合計ジャッジ時間 | 2,435 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
ソースコード
local function lltonumber(str)local ret = 0LLlocal sign = str:sub(1, 1) ~= "-"local begin = sign and 1 or 2for i = begin, #str doret = ret * 10LLret = ret + tonumber(str:sub(i, i))endif not sign then ret = ret * -1LL endreturn retendlocal n = io.read("*n", "*l")local s = io.read()local t = {}for w in s:gmatch("-?%d+") dolocal num = lltonumber(w)table.insert(t, num)endlocal inc = {1}local dec = {1}for i = 2, n doif t[i - 1] <= t[i] theninc[i] = inc[i - 1]elseinc[i] = iendif t[i] <= t[i - 1] thendec[i] = dec[i - 1]elsedec[i] = iendendlocal q = io.read("*n")for i = 1, q dolocal l, r = io.read("*n", "*n")l, r = l + 1, r + 1local a = inc[r] <= l and 1 or 0local b = dec[r] <= l and 1 or 0print(a .. " " .. b)end