結果

問題 No.602 隠されていたゲーム2
ユーザー zodi_G12zodi_G12
提出日時 2021-12-01 10:58:20
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 717 bytes
コンパイル時間 216 ms
コンパイル使用メモリ 11,464 KB
実行使用メモリ 20,416 KB
最終ジャッジ日時 2023-09-17 15:06:12
合計ジャッジ時間 5,660 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
19,540 KB
testcase_01 AC 85 ms
15,288 KB
testcase_02 AC 85 ms
15,328 KB
testcase_03 AC 83 ms
15,368 KB
testcase_04 AC 83 ms
15,272 KB
testcase_05 AC 84 ms
15,328 KB
testcase_06 AC 82 ms
15,172 KB
testcase_07 AC 85 ms
15,140 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 82 ms
15,312 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 83 ms
15,052 KB
testcase_16 TLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:1: warning: assigned but unused variable - n
Syntax OK

ソースコード

diff #

n = gets.to_i

l = gets.to_s.chop.split(" ").map{|i|i.to_i}

xy = gets.to_s.chop.split(" ").map{|i|i.to_i}

x = xy[0] < 0 ? xy[0] * -1 : xy[0]  
y = xy[1] < 0 ? xy[1] * -1 : xy[1]            

sum = x+y

if x == 0 && y == 0
  puts 0
  return
end              
                 
step = -1      
               
(l.size).times{|i|    
  if l[i] == sum  
    step = 1
    break          
  end              
  (l.size-1-i).times{|j| 
    if l[i] + l[i+j+1] == sum || (l[i] - l[i+j+1]).abs == sum
      step = 2                                               
    end              
  }                                      
  if step == 1 
    break
  end              
}                                        

puts step
0