Problem:


Score : 600 points

Problem Statement

We have one slime.

You can set the health of this slime to any integer value of your choice.

A slime reproduces every second by spawning another slime that has strictly less health. You can freely choose the health of each new slime. The first reproduction of our slime will happen in one second.

Determine if it is possible to set the healths of our first slime and the subsequent slimes spawn so that the multiset of the healths of the 2^N slimes that will exist in N seconds equals a multiset S.

Here S is a multiset containing 2^N (possibly duplicated) integers: S_1,~S_2,~...,~S_{2^N}.

Constraints

All values in input are integers.

1 \leq N \leq 18

1 \leq S_i \leq 10^9

Input

Input is given from Standard Input in the following format:

N
S_1 S_2 ... S_{2^N}

Output

If it is possible to set the healths of the first slime and the subsequent slimes spawn so that the multiset of the healths of the 2^N slimes that will exist in N seconds equals S, print Yes; otherwise, print No.

Sample Input 1

2
4 2 3 1

Sample Output 1

Yes

We will show one way to make the multiset of the healths of the slimes that will exist in 2 seconds equal to S.

First, set the health of the first slime to 4.

By letting the first slime spawn a slime whose health is 3, the healths of the slimes that exist in 1 second can be 4,~3.

Then, by letting the first slime spawn a slime whose health is 2, and letting the second slime spawn a slime whose health is 1, the healths of the slimes that exist in 2 seconds can be 4,~3,~2,~1, which is equal to S as multisets.

Sample Input 2

2
1 2 3 1

Sample Output 2

Yes

S may contain multiple instances of the same integer.

Sample Input 3

1
1 1

Sample Output 3

No

Sample Input 4

5
4 3 5 3 1 2 7 8 7 4 6 3 7 2 3 6 2 7 3 2 6 7 3 4 6 7 3 4 2 5 2 3

Sample Output 4

No



Sample input:
2
4 2 3 1


Sample output:
Yes

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
s=list(map(int,input().split()))

a=[]*n
s.sort()
#print(s)
s.reverse()
#print(s)
for i in range(n):
  for j in range(2**i):
#    print(j,j+(2**i))
    if s[j]<=s[j+(2**i)]:
      print("No")
      sys.exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
S = list(map(int, sys.stdin.readline().split()))
S.sort(reverse=True)

slimes = [S[0]]
i = 1
for e in range(N):
    count = len(slimes)
    for j in range(count):
        if S[j + count] < slimes[j]:
            slimes.append(S[j + count])
        else:
            print('No')
            exit()

# print(slimes)

if len(slimes) == 2 ** N:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
S = list(map(int, sys.stdin.readline().split()))
S.sort(reverse=True)

slimes = [S[0]]
i = 1
for e in range(N):
    count = len(slimes)
    for j in range(count):
        if S[j + count] < slimes[j]:
            slimes.append(S[j + count])
        else:
            break

# print(slimes)

if len(slimes) == 2 ** N:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys

def I(): return(int(sys.stdin.readline()))
def LI(): return([int(x) for x in sys.stdin.readline().split()])


def main():
    N = I()
    S = sorted(LI(),reverse=True)

    flag = [True]*len(S)

    cur = []
    cur.append(S[0])
    flag[0] = False

    for i in range(N):
        nxt = [x for x in cur]
        j = 0

        for k in range(len(S)):
            if j >= len(cur):
                break
            elif flag[k] and S[k]<cur[j]:
                nxt.append(S[k])
                j+=1
                flag[k] = False
        if len(cur) != j:
            return("No")
        cur = sorted(nxt)

    return("Yes")

if __name__ == "__main__":
    print(main())

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(map(int, input().split()))
S.sort(reverse = True)
ans = 'Yes'
used = set([0])
L = [S[0]]
for k in range(1, N+1):
    cnt = 0
    for i in range(2**N):
        if i in used:
            continue
        if L[cnt] > S[i]:
            used.add(i)
            cnt += 1
            L.append(S[i])
        if cnt == (2**(k-1)):
            break
    else:
        ans = 'No'
        break
    continue
    L.sort(reverse = True)

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(map(int, input().split()))
S.sort(reverse = True)
ans = 'Yes'
used = set([0])
L = [S[0]]
for k in range(1, N+1):
    cnt = 0
    for i in range(2**N):
        if i in used:
            continue
        if L[cnt] > S[i]:
            used.add(i)
            cnt += 1
            L.append(S[i])
        if cnt == (2**(k-1)):
            break
    else:
        ans = 'No'
        break
    continue

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(map(int, input().split()))
S.sort(reverse = True)
ans = 'Yes'
for i in range(N):
    k = 2**i
    for j in range(k):
        if S[j] == S[k+j]:
            ans = 'No'
            break
    else:
        continue
    break

print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=list(map(int,input().split()))
S.sort()
p=[S.pop(-1)]
r=S

for i in range(N):
    nr=[]
    for p_ in p[::-1]:
        while r:
            nr.append(r.pop())
            if nr[-1]<p_:
                p.append(nr[-1])
                break
    p.sort()
    r+=nr[::-1]

print("Yes" if len(r)==0 else "No")

Submission status: Wrong Answer

Solution code:
import bisect
 
N = int(input())
a = list(map(int,input().split(' ')))
a.sort(reverse = True)
 
 
fathers = [a.pop(0)]
for _ in range(N):
    sons = list()
    index = 0
    for i in a:
        if fathers[index] > i:
            a.remove(i)
            sons.append(i)
            index += 1
        if index > len(fathers) - 1:
            break


if len(fathers) == 2**N:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
def compare(A1,A2):
    for i in range(len(A1)):
        if A1[i]<=A2[i]:
            return False
    return True

def find(A,N):
    A=sorted(A,reverse=True)
    for i in range(0,N):
        if compare(A[:2**i],A[2**i:2**(i+1)]):
            continue
        else:
            return False
    return True
N=int(input())
A=list(map(int,input().strip().split(" ")))
if find(A,N):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N=int(input())
S=list(map(int,input().split()))
S.sort()
p = [S.pop(-1)]
r = S

for i in range(N):
    nr = []
    for p_ in p[::-1]:
        while r:
            r_ = r.pop()
            if r_ < p_:
                p.append(r_)
                break
            nr.append(r_)
    p.sort()
    r+=nr

print("Yes" if len(r)==0 else "No")

Submission status: Wrong Answer

Solution code:
def compare(A1,A2):
    for i in range(len(A1)):
        if A1[i]<=A2[i]:
            return False
    return True

def find(A,N):
    A=sorted(A,reverse=True)
    for i in range(1,N):
        if compare(A[:2**i],A[2**i:2**(i+1)]):
            continue
        else:
            return False
    return True
N=int(input())
A=list(map(int,input().strip().split(" ")))
if find(A,N):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N=int(input())
S=list(map(int,input().split()))
S.sort()
p = [S.pop(0)]
r = S

for i in range(N):
    for p_ in p[::-1]:
        for k in range(len(r)):
            if r[k] < p_:
                p.append(r.pop(k))
                break
    p.sort()

print("Yes" if len(r)==0 else "No")

Submission status: Wrong Answer

Solution code:
N=int(input())
S=list(map(int,input().split()))
S.sort(reverse=True)
p = [S.pop(0)]
c = S
f = True

for i in range(N):
    np = []
    nc = []
    for p_ in p:
        for k in range(len(c)):
            if c[k] < p_:
                np.append(c.pop(k))
                break
        f = False
    p += np
    p.sort(reverse=True)

print("Yes" if f else "No")

Submission status: Wrong Answer

Solution code:
import bisect

N = int(input())
a = list(map(int,input().split(' ')))
a.sort()

b = list()
def do(n,father):
    b.append(father)
        
    if n == N:
        return
    
    sons = list() 
    for i in range(N - n):
        son = a.pop(bisect.bisect_left(a,father)-1)
        if son >= father:
            return
        else:
            sons.append(son)
    
    for i,son in enumerate(sons,1):
        do(n + i,son)
        
do(0,a.pop())  
if len(b) == 2**N:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
from sys import exit, stderr, stdin
input = stdin.readline
from collections import defaultdict

def main():
    N = int(input())
    S = [int(a) for a in input().split()]
    S = sorted(S, key=lambda x:-x)
    live_nums = defaultdict(int)
    for s in S:
        live_nums[s] += 1
    exist = [S[0]]
    live_nums[S[0]]-= 1
    for i in range(N):
        next_exist = [e for e in exist]
        for e in exist:
            for k in live_nums.keys():
                born = False
                if k < e and live_nums[k] > 0:
                    next_exist.append(k)
                    live_nums[k] -= 1
                    born = True
                    break
            if not born:
                print("No")
                exit()
        exist = sorted(next_exist, key=lambda x:-x)
    if sum(list(live_nums.values())) == 0:
        print("Yes")
        exit()
    else:
        print("No")
        exit()

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def solve_f(n, s_list):
    res = 'Yes'
    s_list_s = sorted(s_list)
    r = n
    right = len(s_list_s) - 1
    left = right - r
    t = 0
    for i in range(len(s_list_s) - 1, -1, -1):
        # print(s_list_s[left:right], s_list_s[i], i)
        if max(s_list_s[left:right]) >= s_list_s[i]:
            res = 'No'
        t += 1
        if t >= 2 ** (n - r - 1):
            r -= 1
            t = 0
        left, right = left - r, left
        if r == 0:
            break

    return res


def main():
    n = int(input())
    s_list = list(map(int, input().split()))
    print(solve_f(n, s_list))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from sys import exit, stderr, stdin
input = stdin.readline
from collections import defaultdict

def main():
    N = int(input())
    S = [int(a) for a in input().split()]
    S = sorted(S, key=lambda x:-x)
    live_nums = defaultdict(int)
    for s in S:
        live_nums[s] += 1
    exist = [S[0]]
    live_nums[S[0]]-= 1
    for i in range(N):
        next_exist = [e for e in exist]
        for e in exist:
            for k in live_nums.keys():
                born = False
                if k < e and live_nums[k] > 0:
                    next_exist.append(k)
                    live_nums[k] -= 1
                    born = True
                    break
            if not born:
                print("No")
                exit()
        exist = next_exist
    if sum(list(live_nums.values())) == 0:
        print("Yes")
        exit()
    else:
        print("No")
        exit()

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from sys import exit, stderr, stdin
input = stdin.readline
from collections import defaultdict
# setrecursionlimit(10**7)
import heapq
def debug(var, name="hoge"):
    print(name +":" + str(type(var)) + " = " + repr(var), file=stderr)
    return


def main():
    N = int(input())
    S = [int(a) for a in input().split()]
    S = sorted(S, key=lambda x:-x)
    live_nums = defaultdict(int)
    for s in S:
        live_nums[s] += 1
    exist = [S[0]]
    live_nums[S[0]]-= 1
    for i in range(N):
        next_exist = [e for e in exist]
        for e in exist:
            for k in live_nums.keys():
                born = False
                if k < e and live_nums[k] > 0:
                    next_exist.append(k)
                    live_nums[k] -= 1
                    born = True
                    break
            if not born:
                print("No")
                exit()
        exist = next_exist
    # print(live_nums)
    if sum(list(live_nums.values())) == 0:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())

S = []
S = input().split()
S = [int(n) for n in S]

m = max(S)
num = [m-(i) for i in range(N+1)]

l = [1, 1]
for i in range(N-1) :
  l.insert(1, l[1]+1)
  if i > 0 :
    for j in range(i) :
      l[j+2] = l[j+2] + l[j+3]





print(N)
print(S)
print(m)
print(num)
print(l)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=list(map(int,input().split()))
S.sort()
S.reverse()
print(S)
p = [S.pop(0)]
c = S
f = False

for i in range(N):
    np = []
    nc = []
    for j in range(len(p)):
        for k in range(len(c)):
            if c[k] < p[j]:
                np.append(c.pop(k))
                f = True
                break
        if f == False:
            print("No")
            exit(0)
        f = False
    print(np)
    p += np
    p.sort()
    p.reverse()

print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int,input().split()))

A.sort()
B = [A.pop()]

for i in range(n):
    for i in range(len(B)):
        if B[i] > A[-i]:
            B += [A.pop()]
    else:
        break
if len(A) == 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import bisect

N = int(input())
a = list(map(int,input().split(' ')))
length = len(a)
a.sort()

def do(n,father):
    
    result = True
        
    if n == N:
        return True
    
    sons = list() 
    for i in range(N - n):
        son = a.pop(bisect.bisect_left(a,father)-1)
        if son >= father:
            return False
        else:
            sons.append(son)
    
    for i,son in enumerate(sons,1):
        result = do(n + i,son) and result
        
    return result
        
if do(0,a.pop()):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
from sys import exit, stderr, stdin
input = stdin.readline
# setrecursionlimit(10**7)
import heapq
def debug(var, name="hoge"):
    print(name +":" + str(type(var)) + " = " + repr(var), file=stderr)
    return


def main():
    N = int(input())
    S = [-int(a) for a in input().split()]
    heapq.heapify(S)
    live = [S[0]]
    heapq.heappop(S)
    # iはステップ
    for i in range(N):
        # 各スライムに生んでもらう
        livenext = live.copy()
        for l in live:
            if l < S[0]:
                livenext.append(heapq.heappop(S))
                continue
            else:
                print("No")
                exit()
        live = livenext
    print("Yes")



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from sys import exit, stderr, stdin
input = stdin.readline
# setrecursionlimit(10**7)
import heapq
def debug(var, name="hoge"):
    print(name +":" + str(type(var)) + " = " + repr(var), file=stderr)
    return


def main():
    N = int(input())
    S = [int(a) for a in input().split()]
    heapq.heapify(S)
    live = [S[0]]
    heapq.heappop(S)
    # iはステップ
    for i in range(N):
        # 各スライムに生んでもらう
        livenext = live.copy()
        for l in live:
            if l < S[0]:
                livenext.append(heapq.heappop(S))
                continue
            else:
                # print(l,S[0])
                print("No")
                exit()
        live = livenext
    print("Yes")



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline

N = int(input().strip())
S = list(map(int,input().strip().split()))

S.sort(reverse=True)
parent = S[0]

numlist = []
for i in range(N):
	numlist.append(2**i)

count = [0 for i in range(N)]
countcom = [1 for i in range(N)]

slime = []
for i in range(N):
	temp = [0 for i in range(2**i)]
	slime.append(temp)
	slime[i][0] = parent

ans = 'yes'
for i in range(1,2**N):
	flag = False
	for level in range(N):
		if count[level]<numlist[level]:
			if slime[level][count[level]]>S[i]:
				flag = True
				count[level] = count[level]+1
				levelt = level+1
				while levelt<=N-1:
					slime[levelt][countcom[levelt]] = S[i]
					countcom[levelt] = countcom[levelt]+1
					levelt = levelt+1
				break

	if flag==False:
		ans = 'no'
		break

print(ans)

Submission status: Wrong Answer

Solution code:
import bisect
import sys
N=int(input())
S=[int(x) for x in input().split()]
T=sorted(S)
A=[]
A.append(T.pop(-1))
M=2**(N-1)-1
for j in range(0,N):
   # print('***'+ str(j) +'***')
    for i in range(0,2**j):
        k=bisect.bisect_left(T,A[i])-1
        #print(i,A[i],T[k])
        if A[i] < T[k]:
            print("No")
            sys.exit()
        A.append(T.pop(k))
print('Yes')

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(map(int, input().split()))
se = list(set(s))
d = {}
for i in se:
    d[i] = s.count(i)
    if d[i] > 2 ** (n - 1):
        print('No')
        break    
else:
    if d[se[-1]] != 1:
        print('No')
    elif d[se[-2]] > n:
        print('No')
    else:
        print('Yes')

Submission status: Wrong Answer

Solution code:
import bisect

N = int(input())
a = list(map(int,input().split(' ')))
length = len(a)
a.sort()


def do(n,father):
    
    result = True
        
    if n == N:
        return True
    
    sons = list() 
    for i in range(N - n):
        son = a.pop(bisect.bisect_left(a,father)-1)
        if son >= father:
            return False
        else:
            sons.append(son)
            
    for i,son in enumerate(sons,1):
        result = do(n + i,son) and result
        
    return result
        
if do(0,a.pop(bisect.bisect_left(a,10*9+1)-1)):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
from collections import Counter
from heapq import heappop, heappush


def solve(n, sss):
    ccc = Counter(sss)
    keys = sorted(ccc.keys(), reverse=True)
    if ccc[keys[0]] != 1:
        return False

    q = [(0, keys[0])]
    for k in keys[1:]:
        nq = []
        for _ in range(ccc[k]):
            try:
                r, s = heappop(q)
            except IndexError:
                return False
            if r < n:
                nq.append((r + 1, k))
                heappush(q, (r + 1, s))
        for item in nq:
            heappush(q, item)

    return True


n = int(input())
sss = list(map(int, input().split()))
print('Yes' if solve(n, sss) else 'No')

Submission status: Wrong Answer

Solution code:
import numpy as np

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

max_n = max(A)
B = [max_n]

for i in range(n):
    for j in range(len(B)):
        B.append(B[j]-1)
A.sort(reverse=True)
B.sort(reverse=True)

A = np.array(A)
B = np.array(B)
C = B -A

c = min(C)
if c >= 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import bisect
N = int(input())
S = list(map(int,input().split()))
S.sort(reverse=True)
slime = [S[0]]
S[0] = -1
for i in range(N):
    slime.sort()
    S.sort(reverse=True)
    ai = 0
    for j in range(2**N):
        while S[ai] != -1:
            if slime[j] > S[ai]:
                slime.append(S[ai])
                S[ai] = -1
                ai += 1
                break
            ai += 1
        if S[ai] == -1:
            print("No")
            exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
input = sys.stdin.readline

class Node:
    def __init__(self, num, parent=None):
        self.num = num
        self.parent = parent
        self.hp = 0

def main():
    N = int(input())
    a= sorted(list(map(int, input().split())), reverse=True)
    # print(a)

    root = Node(N)
    q = deque()
    count = 0
    ok = True
    q.append(root)
    while len(q) > 0:
        node = q.popleft()
        # 一番大きいhpの割り当て
        node.hp = a[count]
        print(node.num, node.hp, a[count])
        count += 1
        # hpが親より小さいか確認
        if node.parent != None:
            print(node.parent.hp, node.hp)
            if node.parent.hp == node.hp:# 親のhpの方が小さかったら無理
                ok = False
                break
        # 自身のnumだけ子ノードを生成
        for i in range(node.num):
            child = Node(node.num-1-i, parent=node)
            q.append(child)
    
    if ok:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
s = list(map(int, input().split()))
s.sort(reverse=True)


ans = "Yes"
for i in range(1, len(s)):
    par = i - 2**math.floor(math.log2(i))
    if s[par] <= s[i]:
        ans = "No"
        break

# print(s)
# print([i for i in range(len(s))])
# print([0] + [math.floor(math.log2(i)) + 1 for i in range(1, len(s))])
# print([0] + [i - 2**math.floor(math.log2(i)) for i in range(1, len(s))])
# for i in range(1, len(s)):


print(ans)

Submission status: Wrong Answer

Solution code:
import bisect

N = int(input())
a = list(map(int,input().split(' ')))
length = len(a)
a.sort()


def do(index,father):
    result = True
    
    if index >= length:
        return True
    
    if len(a) == 0 :
        return True
    
    son = a.pop(bisect.bisect_left(a,father)-1)
    
    print(father,son,index)
    
    if father > son:
        result = do(index*2,father) and result
        result =do(index*2 + 1,son) and result
    else:
        return False
    
    return result
        
if do(1,a.pop(bisect.bisect_left(a,10**9 + 1)-1)):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
print("No")

Submission status: Wrong Answer

Solution code:
import collections

N = int(input())

data = collections.defaultdict(int)
for s in map(int, input().split()):
  data[s] += 1

n = 1
total = 0
for s in sorted(data.keys(), reverse=True):
  if data[s] > n:
    print('No')
    break
  total += data[s]
  if total >= n:
    n *= 2
else:
  print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
input = sys.stdin.readline

class Node:
    def __init__(self, num, parent=None):
        self.num = num
        self.parent = parent
        self.hp = 0

def main():
    N = int(input())
    a= sorted(list(map(int, input().split())), reverse=True)
    # print(a)

    root = Node(N)
    q = deque()
    count = 0
    ok = True
    q.append(root)
    while len(q) > 0:
        node = q.popleft()
        # 一番大きいhpの割り当て
        node.hp = a[count]
        print(node.num, node.hp, a[count])
        count += 1
        # hpが親より小さいか確認
        if node.parent != None:
            print(node.parent.hp, node.hp)
            if node.parent.hp < node.hp:# 親のhpの方が小さかったら無理
                ok = False
                break
        # 自身のnumだけ子ノードを生成
        for i in range(node.num):
            child = Node(node.num-1-i, parent=node)
            q.append(child)
    
    if ok:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import bisect

N = int(input())
a = list(map(int,input().split(' ')))
a.sort(reverse=True)

# print(a)


def do(index,father):
    result = True
    
    if len(a) == 0 :
        return True
    
    son = a.pop(bisect.bisect_left(a,father)-1)
    
#     print(father,son,index)
    
    if father > son:
        result = do(index*2,son) and result
        result =do(index*2 + 1,son) and result
    else:
        return False
    
    return result
        
if do(1,10**9 + 1):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(map(int,input().split()))
m = max(s)
f = 0
l = [0]*n
cnt= 0
if m < n+1:
  f = 1
for i in range(n):
  l[i] = s.count(m-i)
  if l[i] > 2**i:
    f = 1
  if i>0 and l[i] > cnt:
    f = 1
  cnt = cnt*2 + l[i]
if f == 0:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(map(int, input().split()))

S.sort()
def compress(s):
    n = (len(s)-1).bit_length()
    j = 0
    comp = [0] * (2 ** n)
    comp[j] += 1
    for i in range(1,2**n):
        if s[i] > s[i-1]:
            j += 1
        comp[j] += 1
    return comp, j

comp, m = compress(S)

valid = True
for i in range(N):
    k = 0
    l = 1
    if l >= len(comp):
        valid = False
        break
    news = []
    for j in range(2**(N-i-1)):
        comp[k] -= 1
        comp[l] -= 1
        news.append(l)
        if not comp[l]:
            if not comp[k]:
                k = l + 1
                l += 2
            else:
                l += 1
        else:
            if not comp[k]:
                l += 1
                k += 1
            else:
                pass
        if l > m:
            break
    if j < 2**(N-i-1) - 1:
        break
    comp, m = compress(news)
if i < N - 1:
    valid = False

print('Yes' if valid else 'No')

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
s = list(map(int, input().split()))
s.sort(reverse=True)

par = [0] + [i - 2**math.floor(math.log2(i)) for i in range(1, len(s))]
par.sort()
# print(par)

ans = "Yes"
for i in range(1, len(s)):
    if s[par[i]] <= s[i]:
        ans = "No"
        break

# print(s)
# print([i for i in range(len(s))])
# print([0] + [math.floor(math.log2(i)) + 1 for i in range(1, len(s))])
# print([0] + [i - 2**math.floor(math.log2(i)) for i in range(1, len(s))])
# for i in range(1, len(s)):


print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
input = sys.stdin.readline

class Node:
    def __init__(self, num, parent=None):
        self.num = num
        self.parent = parent
        self.hp = 0

def main():
    N = int(input())
    a= sorted(list(map(int, input().split())), reverse=True)
    # print(a)

    root = Node(N)
    q = deque()
    count = 0
    ok = True
    q.append(root)
    while len(q) > 0:
        node = q.popleft()
        # 一番大きいhpの割り当て
        node.hp = a[count]
        # print(node.num, node.hp, a[count])
        count += 1
        # hpが親より小さいか確認
        if node.parent != None:
            if node.parent.hp == node.hp:# 親のhpの方が小さかったら無理
                ok = False
                break
        # 自身のnumだけ子ノードを生成
        for i in range(node.num):
            child = Node(node.num-1-i, parent=node)
            q.append(child)
    
    if ok:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(map(int,input().split()))
m = max(s)
f = 0
l = [0]*n
if m < n+1:
  f = 1
for i in range(n):
  l[i] = s.count(m-i)
  if l[i] > 2**i:
    f = 1
  if i>0 and l[i]*2 > l[i-1]:
    f = 1
if f == 0:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
s = list(map(int, input().split()))
s.sort(reverse=True)

child = [[] for i in range(n)]
# print(s)

ans = "Yes"
for i in range(1, len(s)):
    if s[i - 2**math.floor(math.log2(i))] <= s[i]:
        ans = "No"
        break

# print(s)
# print([i for i in range(len(s))])
# print([0] + [math.floor(math.log2(i)) + 1 for i in range(1, len(s))])
# print([0] + [i - 2**math.floor(math.log2(i)) for i in range(1, len(s))])
# for i in range(1, len(s)):


print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
input = sys.stdin.readline

class Node:
    def __init__(self, num, parent=None):
        self.num = num
        self.parent = parent
        self.hp = 0

def main():
    N = int(input())
    a= sorted(list(map(int, input().split())), reverse=True)
    # print(a)

    root = Node(N)
    q = deque()
    count = 0
    ok = True
    q.append(root)
    while len(q) > 0:
        node = q.popleft()
        # 一番大きいhpの割り当て
        node.hp = a[count]
        # print(node.num, node.hp, a[count])
        count += 1
        # hpが親より小さいか確認
        if node.parent != None:
            if node.parent.hp <= node.hp:# 親のhpの方が小さかったら無理
                ok = False
                break
        # 自身のnumだけ子ノードを生成
        for i in range(node.num):
            child = Node(node.num-1-i, parent=node)
            q.append(child)
    
    if ok:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(map(int,input().split()))
m = max(s)
f = 0
if m < n+1:
  f = 1
for i in range(n):
  l = s.count(m-i)
  if l > 2**i:
    f = 1
if f == 0:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split(' ')))
length = len(a)
a.sort(reverse=True)

# print(a)


def do(index,father):
    result = True
    
    if index > length :
        return True
    
    son = a[index - 1] 
    
#     print(father,son,index)
    
    if father > son:
        result = do(index*2,son) and result
        result =do(index*2 + 1,son) and result
    else:
        return False
    
    return result
        
if do(1,10**9 + 1):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from sys import stdin
import numpy as np
# import sys
# sys.setrecursionlimit(10**4)

def _li(): return list(map(int, stdin.readline().split()))
def _li_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def _lf(): return list(map(float, stdin.readline().split()))
def _ls(): return stdin.readline().split()
def _i(): return int(stdin.readline())
def _f(): return float(stdin.readline())
def _s(): return stdin.readline()[:-1]


N = _i()
s_list = np.array(_li())
s_list.sort()
cand = np.zeros(2**N, dtype=int)
cand[0] = s_list[-1]
count = -1
offset = 0
i = 0
j = 0
for s in s_list[:-1][::-1]:
    # print(cand, i, j, offset)
    cand[2**i + j] = s
    i += 1
    if i == N:
        j += 1
        count -= 1
        if count <= 0:
            offset += 1
            count = 2 ** (offset-1)
        i = offset
# print(cand)

ans = 'Yes'
for i in range(N)[::-1]:
    a = cand[:2**i]
    b = cand[2**i:]
    if not np.all(a > b):
        ans = 'No'
        break
    cand = cand[:2**i]
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    S = [int(s) for s in input().split()]
    S.sort(reverse = True)

    result = []
    result.append(S[0])

    left = 1
    que = []
    que.append([])

    for i in range(N):
        for j in range(2**i):
            que.append([])
            for q in que[-2]:
                if result[j]<=q:
                    que[-1].append(q)
                else:
                    result.append(q)
                    break
            else:
                for k in range(left,len(S)):
                    if result[j]<=S[k]:
                        que[-1].append(S[k])
                    else:
                        result.append(S[k])
                        left = k+1
                        break
                else:
                    print("No")
                    break
        else:
            continue
        break
    else:
        print("Yes")

if __name__ == "__main__":
    main()