結果

問題 No.723 2つの数の和
ユーザー nobigomunobigomu
提出日時 2018-08-05 14:02:17
言語 Lua
(LuaJit 2.1.1696795921)
結果
TLE  
実行時間 -
コード長 545 bytes
コンパイル時間 88 ms
コンパイル使用メモリ 5,152 KB
実行使用メモリ 8,812 KB
最終ジャッジ日時 2023-10-19 22:04:23
合計ジャッジ時間 11,031 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,812 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 250 ms
4,444 KB
testcase_04 TLE -
testcase_05 TLE -
testcase_06 AC 428 ms
4,488 KB
testcase_07 AC 88 ms
4,348 KB
testcase_08 AC 155 ms
4,488 KB
testcase_09 WA -
testcase_10 AC 622 ms
4,348 KB
testcase_11 AC 15 ms
4,348 KB
testcase_12 AC 87 ms
4,444 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

local ffi = require 'ffi'
local C = ffi.C
ffi.cdef 'int scanf(const char *, ...);'

print((function (n, x, cd)
	local a,h,r={},{},0
	for _=1,n do C.scanf("%d",cd) if h[cd[0]]==nil then h[cd[0]]=0 end h[cd[0]]=h[cd[0]]+1 end
	for k,_ in pairs(h) do table.insert(a,k) end table.sort(a)
	for i=1,#a do
		if a[i]*2==x then r=r+h[a[i]] goto bot end
		for j=i+1,#a do
			local t=a[i]+a[j]
			if t>x then break end
			if t==x then r=r+h[a[i]]*h[a[j]]*2 end
		end ::bot::
	end
	return r
end)(io.stdin:read("*n"), io.stdin:read("*n"), ffi.new("int[1]")))
0