結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
19,640 KB
testcase_01 AC 80 ms
15,200 KB
testcase_02 AC 82 ms
15,316 KB
testcase_03 AC 83 ms
15,088 KB
testcase_04 AC 84 ms
15,200 KB
testcase_05 AC 85 ms
15,356 KB
testcase_06 AC 82 ms
15,164 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 83 ms
15,064 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 83 ms
15,284 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

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