結果
| 問題 | 
                            No.178 美しいWhitespace (1)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             nobigomu
                         | 
                    
| 提出日時 | 2018-05-04 15:00:42 | 
| 言語 | Lua  (LuaJit 2.1.1734355927)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 402 bytes | 
| コンパイル時間 | 49 ms | 
| コンパイル使用メモリ | 5,120 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-06-28 01:04:09 | 
| 合計ジャッジ時間 | 1,037 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 21 | 
ソースコード
local ffi = require 'ffi'
local C, ct = ffi.C, ffi.typeof("int32_t[1]")
ffi.cdef 'int scanf(const char *, ...);'
print((function (n)
	local a,p,q,m,t,r={},ct(),ct(),0,0,0
	C.scanf("%d %d",p,q) t=p[0]+4*q[0] a[1],m=t,t
	for i=2,n do
		C.scanf("%d %d",p,q) t=p[0]+4*q[0] a[i]=t if t>m then m=t end
	end
	for i=1,#a do t=m-a[i] if t%2~=0 then return -1 end r=r+t/2 end return r
end)(io.stdin:read("*n")))
            
            
            
        
            
nobigomu