結果
問題 | No.489 株に挑戦 |
ユーザー | 👑 obakyan |
提出日時 | 2019-05-02 15:11:44 |
言語 | Lua (LuaJit 2.1.1696795921) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,664 bytes |
コンパイル時間 | 97 ms |
コンパイル使用メモリ | 5,296 KB |
実行使用メモリ | 4,384 KB |
最終ジャッジ日時 | 2023-08-30 04:46:56 |
合計ジャッジ時間 | 4,072 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 25 ms
4,380 KB |
testcase_01 | AC | 38 ms
4,380 KB |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | AC | 1 ms
4,380 KB |
testcase_04 | AC | 2 ms
4,380 KB |
testcase_05 | AC | 1 ms
4,380 KB |
testcase_06 | AC | 1 ms
4,384 KB |
testcase_07 | AC | 1 ms
4,380 KB |
testcase_08 | AC | 1 ms
4,380 KB |
testcase_09 | AC | 2 ms
4,380 KB |
testcase_10 | AC | 1 ms
4,380 KB |
testcase_11 | AC | 1 ms
4,380 KB |
testcase_12 | AC | 1 ms
4,376 KB |
testcase_13 | AC | 1 ms
4,376 KB |
testcase_14 | AC | 1 ms
4,380 KB |
testcase_15 | AC | 3 ms
4,380 KB |
testcase_16 | AC | 66 ms
4,380 KB |
testcase_17 | AC | 4 ms
4,376 KB |
testcase_18 | AC | 23 ms
4,380 KB |
testcase_19 | AC | 27 ms
4,376 KB |
testcase_20 | AC | 64 ms
4,376 KB |
testcase_21 | AC | 12 ms
4,380 KB |
testcase_22 | AC | 4 ms
4,380 KB |
testcase_23 | AC | 17 ms
4,376 KB |
testcase_24 | AC | 84 ms
4,380 KB |
testcase_25 | AC | 1 ms
4,380 KB |
testcase_26 | WA | - |
testcase_27 | AC | 39 ms
4,376 KB |
testcase_28 | AC | 1 ms
4,376 KB |
testcase_29 | AC | 1 ms
4,376 KB |
testcase_30 | AC | 94 ms
4,380 KB |
testcase_31 | AC | 93 ms
4,376 KB |
testcase_32 | AC | 23 ms
4,380 KB |
testcase_33 | AC | 79 ms
4,380 KB |
testcase_34 | AC | 47 ms
4,376 KB |
testcase_35 | AC | 19 ms
4,376 KB |
testcase_36 | AC | 8 ms
4,380 KB |
testcase_37 | AC | 37 ms
4,380 KB |
ソースコード
local ior = io.input() local n, d, k = ior:read("*n", "*n", "*n") local t = {} for i = 1, n do t[i] = ior:read("*n") end local ret_stt_pos = 1 local ret_val = 0 local mma = math.max if(d < 50) then for i = 1, n - 1 do local max = 0 local lst = math.min(n, i + d) for j = i + 1, lst do max = mma(max, t[j]) end if(ret_val < max - t[i]) then ret_val = max - t[i] ret_stt_pos = i end end else local sqd = math.floor(math.sqrt(d)) local blockmax = {} local blockcount = math.ceil(n / sqd) for i = 1, blockcount do blockmax[i] = 0 end for i = 1, n do local b_idx = math.ceil(i / sqd) blockmax[b_idx] = mma(blockmax[b_idx], t[i]) end for i = 1, n - 1 do local max = 0 local lst = math.min(n, i + d) local block_start_idx = math.ceil(i / sqd) + 1 local block_end_idx = math.ceil(lst / sqd) - 1 local block_start_pos = (block_start_idx - 1) * sqd + 1 block_start_pos = math.min(n + 1, block_start_pos) local block_end_pos = block_end_idx * sqd for j = block_start_idx, block_end_idx do max = mma(max, blockmax[j]) end for j = i + 1, block_start_pos - 1 do max = mma(max, t[j]) end for j = block_end_pos + 1, lst do max = mma(max, t[j]) end if(ret_val < max - t[i]) then ret_val = max - t[i] ret_stt_pos = i end end end print(ret_val * k) if(0 < ret_val) then local max = t[ret_stt_pos + 1] local maxj = ret_stt_pos + 1 local lst = math.min(n, ret_stt_pos + d) for j = ret_stt_pos + 1, lst do if(max < t[j]) then max, maxj = t[j], j end end print(ret_stt_pos - 1 .. " " .. maxj - 1) end