結果

問題 No.904 サメトロ
ユーザー TANIGUCHI KousukeTANIGUCHI Kousuke
提出日時 2019-12-08 17:37:39
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 269 bytes
コンパイル時間 61 ms
コンパイル使用メモリ 11,564 KB
実行使用メモリ 15,380 KB
最終ジャッジ日時 2023-08-29 21:47:44
合計ジャッジ時間 5,075 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,028 KB
testcase_01 WA -
testcase_02 AC 81 ms
15,232 KB
testcase_03 AC 79 ms
15,028 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 81 ms
15,320 KB
testcase_08 WA -
testcase_09 AC 82 ms
15,328 KB
testcase_10 AC 80 ms
15,080 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 80 ms
15,116 KB
testcase_14 AC 79 ms
15,120 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 77 ms
15,280 KB
testcase_19 AC 78 ms
15,236 KB
testcase_20 AC 76 ms
15,108 KB
testcase_21 WA -
testcase_22 AC 78 ms
15,076 KB
testcase_23 AC 78 ms
15,140 KB
testcase_24 AC 78 ms
15,024 KB
testcase_25 AC 79 ms
15,184 KB
testcase_26 WA -
testcase_27 AC 78 ms
15,152 KB
testcase_28 AC 79 ms
15,228 KB
testcase_29 AC 78 ms
15,252 KB
testcase_30 AC 77 ms
15,256 KB
testcase_31 WA -
testcase_32 AC 79 ms
15,112 KB
testcase_33 AC 80 ms
15,140 KB
testcase_34 AC 79 ms
15,140 KB
testcase_35 AC 79 ms
15,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def min(a,b); a < b ? a : b; end
def max(a,b); a > b ? a : b; end

N = gets.to_i
AB = (2 .. N).map{ gets.split.map(&:to_i) }
SA, SB = AB.transpose.map(&:sum)
b_min = AB.inject(0) do |m, (a,b)|
  max(a + b - SB, m)
end
puts min(SB + 1, SA + 1) - max(b_min - SA + SB, 0)
0