We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Python
- Collections
- Piling Up!
- Discussions
Piling Up!
Piling Up!
Sort by
recency
|
968 Discussions
|
Please Login in order to post a comment
My Soln:
from math import ceil T = int(input()) my_list = [] for _ in range(T*2): my_list.append(list(map(int, input().split())))
new_list = []
for i in range(1,len(my_list),2): new_list.append(my_list[i])
for j in range(0,len(new_list)): for k in range(0,ceil(len(new_list[j])/3)): if ( (new_list[j][k + 1] <= new_list[j][len(new_list[j]) - (k + 1)] and new_list[j][len(new_list[j]) - (k + 2)] <= new_list[j][len(new_list[j]) - (k + 1)]) or (new_list[j][k + 1] <= new_list[j][k] and new_list[j][len(new_list[j]) - (k + 2)] <= new_list[j][k])): passed_all = True
# Enter your code here. Read input from STDIN. Print output to STDOUT from collections import deque
t = int(input())
for _ in range(t): n=int(input()) blocks=list(map(int,input().split()))
I am not sure when did things turned into the wrong but i got all of my test case right except for the first two one's possible = True for _ in range(int(input())): block = int(input()) block_dict = list(int(i) for i in list(input().split())) answers = [block_dict[0] if block_dict[0] > block_dict[-1] else block_dict[0] if len(block_dict) == 1 else block_dict[-1]] block_dict.remove(answers[0]) for i in range(len(block_dict)): x = max(block_dict[0], block_dict[-1]) if len(block_dict) > 1 else block_dict[0] if x <= answers[i]: answers.append(x) else: possible = False break print("Yes" if possible else "No")