結果

問題 No.1225 I hate I hate Matrix Construction
ユーザー 👑 obakyan
提出日時 2021-05-30 17:44:23
言語 Lua
(LuaJit 2.1.1734355927)
結果
WA  
実行時間 -
コード長 714 bytes
コンパイル時間 381 ms
コンパイル使用メモリ 5,376 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-08 20:54:56
合計ジャッジ時間 1,704 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 32 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

local n = io.read("*n")
local a, b = {}, {}
for i = 1, n do
  a[i] = io.read("*n")
end
for i = 1, n do
  b[i] = io.read("*n")
end
for i = 1, n do
  if a[i] == 2 then
    local c = 0
    for j = 1, n do
      if a[j] == 1 then c = c + 1
      elseif a[j] == 2 then c = c + n
      end
    end
    print(c)
    os.exit()
  end
end
for i = 1, n do
  if b[i] == 2 then
    local c = 0
    for j = 1, n do
      if b[j] == 1 then c = c + 1
      elseif b[j] == 2 then c = c + n
      end
    end
    print(c)
    os.exit()
  end
end
local a1cnt = 0
local b1cnt = 0
for i = 1, n do
  if a[i] == 1 then a1cnt = a1cnt + 1 end
end
for i = 1, n do
  if b[i] == 1 then b1cnt = b1cnt + 1 end
end
print(math.max(a1cnt, b1cnt))
0