結果

問題 No.178 美しいWhitespace (1)
ユーザー TANIGUCHI KousukeTANIGUCHI Kousuke
提出日時 2019-12-04 20:51:23
言語 Ruby
(3.3.0)
結果
AC  
実行時間 84 ms / 2,000 ms
コード長 289 bytes
コンパイル時間 64 ms
コンパイル使用メモリ 11,516 KB
実行使用メモリ 15,296 KB
最終ジャッジ日時 2023-08-21 01:53:07
合計ジャッジ時間 3,654 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
15,264 KB
testcase_01 AC 82 ms
15,292 KB
testcase_02 AC 78 ms
15,116 KB
testcase_03 AC 78 ms
15,040 KB
testcase_04 AC 80 ms
15,296 KB
testcase_05 AC 84 ms
15,172 KB
testcase_06 AC 80 ms
15,260 KB
testcase_07 AC 80 ms
15,168 KB
testcase_08 AC 82 ms
15,024 KB
testcase_09 AC 81 ms
15,044 KB
testcase_10 AC 81 ms
15,084 KB
testcase_11 AC 79 ms
15,196 KB
testcase_12 AC 80 ms
15,168 KB
testcase_13 AC 79 ms
15,112 KB
testcase_14 AC 79 ms
15,084 KB
testcase_15 AC 79 ms
15,064 KB
testcase_16 AC 81 ms
15,064 KB
testcase_17 AC 80 ms
15,068 KB
testcase_18 AC 80 ms
15,120 KB
testcase_19 AC 81 ms
15,128 KB
testcase_20 AC 81 ms
15,156 KB
testcase_21 AC 80 ms
15,292 KB
testcase_22 AC 79 ms
15,152 KB
testcase_23 AC 80 ms
15,120 KB
testcase_24 AC 79 ms
15,160 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:15: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

def max(a,b); a > b ? a : b; end
  
N = gets.to_i
A = [0, 0]
max_w = 0
L = N.times.map do
  a,b = gets.split.map(&:to_i)
  A[a % 2] += 1
  (a + 4 * b).tap do |l|
    max_w = max(max_w, l)
  end
end

if A[0] > 0 && A[1] > 0
  puts -1
else
  puts L.inject(0){|s,l| s + (max_w - l) / 2 }
end
0