結果
問題 | No.77 レンガのピラミッド |
ユーザー |
👑 |
提出日時 | 2019-05-06 10:57:55 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 472 bytes |
コンパイル時間 | 50 ms |
コンパイル使用メモリ | 5,248 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-27 05:31:38 |
合計ジャッジ時間 | 1,062 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 20 |
ソースコード
local n = io.read("*n") local tot = 0 local a = {} for i = 1, n do local tmp = io.read("*n") tot, a[i] = tot + tmp, tmp end local minmvcnt = 10000 for i = 1, 100 do if(tot < i * i) then break end local mvcnt = 0 -- check only MINUS count for j = 1, n do local tgt = 0 if(j <= i) then tgt = j elseif(j < 2 * i) then tgt = 2 * i - j end mvcnt = mvcnt + math.max(0, a[j] - tgt) end minmvcnt = math.min(minmvcnt, mvcnt) end print(minmvcnt)