結果

問題 No.904 サメトロ
ユーザー wipexwipex
提出日時 2019-10-18 23:44:18
言語 Ruby
(3.3.0)
結果
AC  
実行時間 80 ms / 1,000 ms
コード長 481 bytes
コンパイル時間 494 ms
コンパイル使用メモリ 11,372 KB
実行使用メモリ 15,340 KB
最終ジャッジ日時 2023-09-08 02:53:07
合計ジャッジ時間 6,725 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
15,292 KB
testcase_01 AC 80 ms
15,288 KB
testcase_02 AC 78 ms
15,184 KB
testcase_03 AC 79 ms
15,168 KB
testcase_04 AC 78 ms
15,096 KB
testcase_05 AC 79 ms
15,172 KB
testcase_06 AC 78 ms
15,308 KB
testcase_07 AC 78 ms
15,192 KB
testcase_08 AC 77 ms
15,152 KB
testcase_09 AC 76 ms
15,196 KB
testcase_10 AC 79 ms
15,300 KB
testcase_11 AC 79 ms
15,060 KB
testcase_12 AC 78 ms
15,164 KB
testcase_13 AC 78 ms
15,144 KB
testcase_14 AC 78 ms
15,100 KB
testcase_15 AC 79 ms
15,296 KB
testcase_16 AC 77 ms
15,168 KB
testcase_17 AC 77 ms
15,288 KB
testcase_18 AC 78 ms
15,200 KB
testcase_19 AC 78 ms
15,132 KB
testcase_20 AC 79 ms
15,104 KB
testcase_21 AC 79 ms
15,152 KB
testcase_22 AC 79 ms
15,340 KB
testcase_23 AC 79 ms
15,280 KB
testcase_24 AC 77 ms
15,064 KB
testcase_25 AC 78 ms
15,300 KB
testcase_26 AC 78 ms
15,208 KB
testcase_27 AC 79 ms
15,340 KB
testcase_28 AC 78 ms
15,172 KB
testcase_29 AC 77 ms
15,104 KB
testcase_30 AC 78 ms
15,288 KB
testcase_31 AC 78 ms
15,168 KB
testcase_32 AC 79 ms
15,176 KB
testcase_33 AC 78 ms
15,208 KB
testcase_34 AC 78 ms
15,200 KB
testcase_35 AC 79 ms
15,060 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.chomp.to_i
a =[]
b =[]
sum0=sum1=min0=min1=0

(0..(n-2)).each do |i|
 a[i], b[i] = gets.chomp.split(" ").map!(&:to_i)
end

max1=sum0=a.sum
max0=sum1=b.sum

def max(a,b)
 if a > b
   return a
 elsif b > a
   return b
 else
   return a
 end
end

def min(a,b)
 if a > b
   return b
 elsif b > a
   return a
 else
   return a
 end
end

a.each do |x|
 b.each do |y|
   min1 = max(min1, x-(sum1-y))
   min0 = max(min0, y-(sum0-x))
 end
end

p (min((max0-min0+1),(max1-min1+1)))
0