結果

問題 No.545 ママの大事な二人の子供
ユーザー masaktmasakt
提出日時 2017-07-15 00:10:08
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 322 bytes
コンパイル時間 59 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 19,232 KB
最終ジャッジ日時 2024-04-16 20:52:17
合計ジャッジ時間 7,878 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
17,536 KB
testcase_01 AC 92 ms
12,160 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 92 ms
12,160 KB
testcase_05 AC 90 ms
12,288 KB
testcase_06 AC 91 ms
12,160 KB
testcase_07 AC 91 ms
12,160 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 91 ms
12,288 KB
testcase_11 AC 91 ms
12,288 KB
testcase_12 WA -
testcase_13 AC 99 ms
12,288 KB
testcase_14 WA -
testcase_15 AC 92 ms
12,160 KB
testcase_16 AC 125 ms
12,288 KB
testcase_17 AC 222 ms
12,160 KB
testcase_18 TLE -
testcase_19 TLE -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

$r=10**18
def dfs(a,b,i,n,f,sa,sb)
	return 0 if i == n
	sa += a[i] if f == true
	sb += b[i] if f == false
	dfs(a,b,i+1,n,true,sa,sb)
	dfs(a,b,i+1,n,false,sa,sb)
	return $r=[$r,(sa - sb).abs].min
end

a=[]
b=[]
n=gets.to_i
n.times{|i|a[i],b[i]=gets.split.map &:to_i}
puts [dfs(a,b,0,n,true,0,0), dfs(a,b,0,n,false,0,0)].min
0