結果
問題 | No.2100 [Cherry Alpha C] Two-way Steps |
ユーザー | 👑 obakyan |
提出日時 | 2022-10-23 21:04:05 |
言語 | Lua (LuaJit 2.1.1696795921) |
結果 |
AC
|
実行時間 | 259 ms / 2,000 ms |
コード長 | 1,144 bytes |
コンパイル時間 | 466 ms |
コンパイル使用メモリ | 6,684 KB |
実行使用メモリ | 38,512 KB |
最終ジャッジ日時 | 2024-07-02 11:10:45 |
合計ジャッジ時間 | 9,864 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,376 KB |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | AC | 1 ms
5,376 KB |
testcase_04 | AC | 180 ms
26,496 KB |
testcase_05 | AC | 133 ms
21,248 KB |
testcase_06 | AC | 26 ms
7,936 KB |
testcase_07 | AC | 32 ms
9,984 KB |
testcase_08 | AC | 185 ms
33,764 KB |
testcase_09 | AC | 130 ms
15,996 KB |
testcase_10 | AC | 73 ms
6,400 KB |
testcase_11 | AC | 137 ms
23,424 KB |
testcase_12 | AC | 93 ms
13,052 KB |
testcase_13 | AC | 109 ms
27,408 KB |
testcase_14 | AC | 77 ms
9,472 KB |
testcase_15 | AC | 118 ms
26,504 KB |
testcase_16 | AC | 85 ms
9,864 KB |
testcase_17 | AC | 77 ms
24,436 KB |
testcase_18 | AC | 115 ms
27,616 KB |
testcase_19 | AC | 241 ms
32,732 KB |
testcase_20 | AC | 44 ms
10,212 KB |
testcase_21 | AC | 86 ms
14,216 KB |
testcase_22 | AC | 81 ms
9,596 KB |
testcase_23 | AC | 160 ms
29,308 KB |
testcase_24 | AC | 237 ms
36,856 KB |
testcase_25 | AC | 242 ms
36,920 KB |
testcase_26 | AC | 227 ms
36,980 KB |
testcase_27 | AC | 232 ms
36,896 KB |
testcase_28 | AC | 237 ms
36,908 KB |
testcase_29 | AC | 249 ms
37,088 KB |
testcase_30 | AC | 258 ms
36,948 KB |
testcase_31 | AC | 255 ms
37,016 KB |
testcase_32 | AC | 259 ms
37,064 KB |
testcase_33 | AC | 240 ms
36,980 KB |
testcase_34 | AC | 120 ms
10,496 KB |
testcase_35 | AC | 108 ms
8,576 KB |
testcase_36 | AC | 105 ms
8,832 KB |
testcase_37 | AC | 103 ms
8,320 KB |
testcase_38 | AC | 115 ms
9,728 KB |
testcase_39 | AC | 91 ms
7,808 KB |
testcase_40 | AC | 89 ms
7,680 KB |
testcase_41 | AC | 91 ms
7,808 KB |
testcase_42 | AC | 92 ms
7,808 KB |
testcase_43 | AC | 94 ms
7,808 KB |
testcase_44 | AC | 135 ms
38,424 KB |
testcase_45 | AC | 136 ms
38,420 KB |
testcase_46 | AC | 138 ms
38,476 KB |
testcase_47 | AC | 135 ms
38,512 KB |
ソースコード
local mmi, mma = math.min, math.max local n, m = io.read("*n", "*n") local h = {} local edge = {} local invedge = {} for i = 1, n do h[i] = io.read("*n") edge[i] = {} invedge[i] = {} end for i = 1, m do local x, y = io.read("*n", "*n") table.insert(edge[x], y) table.insert(invedge[y], x) end local function solve() local upped = {0} local downed = {0} for i = 2, n do upped[i], downed[i] = -1, -1 end for i = 1, n - 1 do for j = 1, #edge[i] do local dst = edge[i][j] if h[i] < h[dst] and 0 <= downed[i] then upped[dst] = mma(upped[dst], downed[i] + h[dst] - h[i]) end if h[dst] < h[i] and 0 <= upped[i] then downed[dst] = mma(downed[dst], upped[i]) end if h[dst] < h[i] and 0 <= downed[i] then downed[dst] = mma(downed[dst], downed[i]) end end end print(mma(downed[n], upped[n])) end solve() for i = 1, n do edge[i] = {} local z = n + 1 - i if i < z then h[i], h[z] = h[z], h[i] end end for i = 1, n do for j = 1, #invedge[i] do local dst = invedge[i][j] table.insert(edge[n + 1 - i], n + 1 - dst) end end solve()