結果

問題 No.505 カードの数式2
ユーザー koba-e964koba-e964
提出日時 2017-04-21 22:37:03
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 390 bytes
コンパイル時間 58 ms
コンパイル使用メモリ 11,552 KB
実行使用メモリ 15,400 KB
最終ジャッジ日時 2023-09-27 11:22:27
合計ジャッジ時間 3,524 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
15,168 KB
testcase_01 AC 76 ms
15,248 KB
testcase_02 AC 70 ms
15,220 KB
testcase_03 AC 70 ms
15,144 KB
testcase_04 AC 70 ms
15,308 KB
testcase_05 AC 70 ms
15,076 KB
testcase_06 AC 72 ms
15,204 KB
testcase_07 AC 71 ms
15,080 KB
testcase_08 AC 71 ms
15,068 KB
testcase_09 AC 70 ms
15,176 KB
testcase_10 AC 70 ms
15,156 KB
testcase_11 AC 73 ms
14,992 KB
testcase_12 AC 74 ms
15,024 KB
testcase_13 WA -
testcase_14 AC 70 ms
15,156 KB
testcase_15 WA -
testcase_16 AC 70 ms
15,164 KB
testcase_17 WA -
testcase_18 AC 71 ms
15,140 KB
testcase_19 WA -
testcase_20 AC 71 ms
15,176 KB
testcase_21 AC 72 ms
15,068 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 71 ms
15,128 KB
testcase_31 AC 71 ms
15,248 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.to_i
a = gets.split.map(&:to_i)

cur = a[0]
for i in 1 ... n
  op = a[i]
  ma = -1000000
  if op != 0
    c = cur
    o = op
    t = 0
    if c < 0
      t = 1 - t
      c = -c
    end
    if o < 0
      t = 1 - t
      o = -o
    end
    ma = [ma, (-1) ** t * c / o].max
  end
  ma = [ma, cur * op].max
  ma = [ma, cur + op].max
  ma = [ma, cur - op].max
  cur = ma
end
puts cur

0