You are viewing a single comment's thread. Return to all comments →
import math def main(): t = int(input()) for _ in range(t): _, blocks = int(input()), list(map(int, input().split())) result = True top = math.inf i, j = 0, len(blocks) - 1 while i <= j and result: left = blocks[i] right = blocks[j] if left >= right: if left <= top: top=left i+=1 else: result = False else: if right <= top: top=right j-=1 else: result = False if result: print("Yes") else: print("No") if __name__ == "__main__": main()
Seems like cookies are disabled on this browser, please enable them to open this website
Piling Up!
You are viewing a single comment's thread. Return to all comments →