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 3 years have passed since last update.

はじめに

前回
ABC160ができなくてつらかったので諦めてこっち書きます。
疲れているのでとっても雑に書きます。すみません

#19

問題

考えたこと
h[i]とh[i-1]の関係を比較したときに単調非減少になるにはh[i]の方が大きいか同じでなければならない。今回はマスの高さを-1することができるのでもし-1した場合にはcheckerの真偽を変更して対応している

n = int(input())
h = list(map(int,input().split()))

seed = h[0]
checker = True

for i in range(1,n):
    if h[i] == h[i-1]:
        continue
    d = h[i] - h[i-1] + 1
    if d > 0:
        checker = True
        pass
    elif d == 0:
        if checker:
            checker = False
        else:
            print('No')
            quit()
    else:
        print('No')
        quit()


print('Yes')

まとめ

疲れているときと眠いときは絶対にコンテストにでるな!!。では、また

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?