0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ABC086C - Traveling

Posted at

問題

https://atcoder.jp/contests/abs/tasks/arc089_a
スクリーンショット 2019-12-01 17.39.17.png

1回目

回答

N = gets.to_i
T,A,B = N.times.map{gets.split.map(&:to_i)}.transpose

can = true
t, x, y = T[0], A[0], B[0]
for i in 0..N-1
  if i > 0
    t = T[i] - T[i-1]
    x = A[i] - A[i-1]
    y = B[i] - B[i-1]
  end
  if x + y > t || ( t - x - y ) % 2 != 0
    can = false
    break
  end
end

puts can ? "Yes" : "No"

結果

スクリーンショット 2019-12-01 17.38.22.png

感想

他の人の回答を見た所、t,x,yの差を見ていなかったのが不思議だ。
もうちょい考えます。
奇数チェックはodd?にした方が良い。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?