結果
| 問題 |
No.602 隠されていたゲーム2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-12-02 18:37:40 |
| 言語 | Ruby (3.4.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 426 bytes |
| コンパイル時間 | 232 ms |
| コンパイル使用メモリ | 7,424 KB |
| 実行使用メモリ | 20,096 KB |
| 最終ジャッジ日時 | 2024-11-28 03:39:50 |
| 合計ジャッジ時間 | 3,491 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 WA * 4 |
コンパイルメッセージ
Main.rb:14: warning: ambiguous first argument; put parentheses or a space even after `-' operator Main.rb:20: warning: ambiguous first argument; put parentheses or a space even after `-' operator Main.rb:1: warning: assigned but unused variable - n Syntax OK
ソースコード
n = gets.to_i
d = gets.split.map(&:to_i)
x, y = gets.split.map(&:to_i)
sum = x.abs + y.abs
if x == 0 && y == 0
p 0
elsif d.include?(sum)
p 1
else
if sum % 2 == 0
if d.max * 2 >= sum
p 2
else
p -1
end
else
if d.select{|x| x % 2 == 0}.max.to_i + d.select{|x| x % 2 == 1}.max.to_i >= sum
p 2
else
p -1
end
end
end