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:
N = int(input())
a = list(map(int,input().split(' ')))
length = len(a)
a.sort(reverse=True)


def do(index,father):
    result = True
    
    if index > length - 1:
        return True
    
    son = a[index - 1] 
    
    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:
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.childs = []
        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)
            node.childs.append(child)
            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()))
s.sort(reverse=True)

# print(s)
ans = "Yes"
for i in range(1, len(s)):
    if s[(i-1)//2] <= s[i]:
        ans = "No"
        break

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(map(int,input().split()))
S.sort(reverse = True)
for i in range(N):
    for j in range(2**i):
        if S[j] <= S[j+2**i]:
            print("No")
            exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(map(int, input().split()))
S.sort(reverse= True)
C = []

temp = -1
for s in S:
  if s==temp:
    C[-1] += 1
  else:
    C.append(1)
    temp = s

if C[0]>1:
  print('No')
  exit()

#print(C)
  
T = [1]* (2**18+2) #各秒の生成力？

i = 1
ans = 0
for c in C[1:]:
  j = i
  while T[j] < c:
    c -= T[j]
    j += 1
  T[j+1] += c
  T[j] -= c
  if T[j]==0:
    T[i+1:j+1] = T[i:j]
    T[i]=0
    i+=1
    ans = max(ans,j)
  else:
    if i==j:
      continue
    else:
      T[j] += T[j-1]
      T[i+1:j] = T[i:j-1]
      T[i] = 0
      i+=1
      ans = max(ans,j)
  #print(i,ans, T[:10])
  
if ans == N:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(map(int, input().split()))
S.sort(reverse= True)
C = []

temp = -1
for s in S:
  if s==temp:
    C[-1] += 1
  else:
    C.append(1)
    temp = s

if C[0]>1:
  print('No')
  exit()

#print(C)
  
T = [1]* (2**18+2) #各秒の生成力？

i = 1
ans = 0
for c in C[1:]:
  j = i
  while T[j] < c:
    c -= T[j]
    j += 1
  T[j+1] += c
  T[j] -= c
  if T[j]==0:
    T[i+1:j+1] = T[i:j]
    T[i]=0
    i+=1
    ans = max(ans,j)
  else:
    if i==j:
      continue
    else:
      T[j] += T[j-1]
      T[i+1:j] = T[i:j-1]
      T[i] = 0
      i+=1
      ans = max(ans,j)
  print(i,ans, T[:10])
  
if ans == N:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


n =  I()
slime = LI()
L = [max(slime)]
for i in range(n):
    L += [i-1 for i in L]



L.sort()
slime.sort()



for i in range(2 ** n):
    if L[i] < slime[i]:
        print('No')
        break
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
N = int(input())
S = sorted([int(a) for a in input().split()])[::-1]
for i in range(1<<N-1):
    if S[i] == S[i+2**i.bit_length()]:
        print("No")
        break
else:
    print("Yes")

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]:
                l += 2
                k += 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:
N = int(input())
S = sorted([int(a) for a in input().split()])
for i in range(1<<N-1):
    if S[i] == S[i+2**i.bit_length()]:
        print("No")
        break
else:
    print("Yes")

Submission status: Wrong Answer

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

s.sort()

a = [s[-1]]
b = s[:-1]

for i in range(n):
    a2 = []
    b2 = []
    for x in a:
        while b:
            y = b.pop()
            if x>y:
                a2.append(y)
                break
            else:
                b2.append(y)
    a = a + a2
    b = b + b2
    b.sort()
    if len(a)!=2**(i+1):
        print('No')
        exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(map(int, input().split()))
S.sort(reverse= True)
C = []

temp = -1
for s in S:
  if s==temp:
    C[-1] += 1
  else:
    C.append(1)
    temp = s

if C[0]>1:
  print('No')
  exit()

#print(C)
  
T = [1]* (2**18+2) #各秒の生成力？

i = 0
ans = 0
for c in C[1:]:
  j = i
  while T[j] < c:
    c -= T[j]
    j += 1
  T[j+1] += c
  T[j] -= c
  if T[j]==0:
    j+=1
  if i!=j:
    T[j] += T[j-1]
    T[i+1:j] = T[i:j-1]
    T[i] = 0
    i += 1
  ans = max(ans, j)
  #print(i,ans, T[:10])
  
if ans == N:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
xs = sorted(list(map(int, input().split())))[::-1]

while True:
    b = None
    c = 1
    nxs = []
    rr = True
    for x in xs:
        if b == None:
            b = x
            continue
        if c == 0:
            b = x
            c += 1
            rr = True
            continue
        if rr and x == b:
            c += 1
            continue
        rr = False
        nxs.append(x)
        c -= 1
        b = x
    xs = nxs
    if c != 0:
        r = "No"
        break
    if len(xs) == 1:
        r = "Yes"
        break
print(r)

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline
n=int(input())
s=list(map(int,input().split()))
s.sort(reverse=True)
o=0
if n==1:
    if s[0]==s[1]:
        print("No")
    else:
        print("Yes")
    exit()
for i in range(n):
    if s[o+n-i+1]>=s[i]-1:
        print("No")
        exit()
    o=o+n-i+1
    if o>=n:
        break
print("Yes")

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
S = list(map(int,input().split()))
if len(S)!=2**N:
    print("No")
else:
    ans ="Yes"
    S.sort(reverse = True)
    sedai =[1]
    for i in range(N-1):
        sedai.append(sum(sedai))
    itr = 1
    for i in range(N):
        for j in range(sedai[i]):
            for k in range(N-i):
                if S[i+j]<=S[itr]:
                    ans = "No"
                itr +=1
    if S[2*(N-1)]<=S[-1]:
        ans ="No"
    print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter


def solve(n, sss):
    for i in range(n, 0, -1):
        ccc = Counter(sss)
        keys = [-1] + sorted(ccc.keys(), reverse=True)
        ttt = []

        for _ in range(len(sss) // 2):
            s = keys[-1]
            t = keys[-2]
            if t == -1:
                return False
            ccc[s] -= 1
            ccc[t] -= 1
            if ccc[t] == 0:
                p = keys.pop()
                keys.pop()
                if ccc[s] > 0:
                    keys.append(p)
            elif ccc[s] == 0:
                keys.pop()
            ttt.append(t)

        # print(sss, ttt)
        sss = ttt
    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:
n=int(input())
s=sorted([int(_) for _ in input().split()])[::-1]
f=1
for i in range(n):
    for j in range(2**i):
        if s[j]==s[j+2**i]:
            f=0;break
    if not f:break
print("Yes" if f else "No")

Submission status: Wrong Answer

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

s.sort()

a = [s[-1]]
s.pop(-1)

for i in range(n):
    b = len(a)
    for j in range(b):
        if a[i] > s[-1]:
            a.append(s[-1])
            s.pop(-1)
    if len(a)!=2**(i+1):
        print('No')
        exit()

print('Yes')

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n = I()
    print(n**3)
    return

#B
def B():
    n = I()
    a = LI()
    b = LI()
    c = LI()
    ans = sum(b)
    for i in range(n-1):
        x = a[i]
        y = a[i+1]
        if y == x+1:
            ans += c[x-1]
    print(ans)
    return

#C
def C():
    n = I()
    b = LI()
    b.append(float("inf"))
    a = [min(b[i],b[i-1]) for i in range(n)]
    print(sum(a))
    return

#D
def D():
    n,k = LI()
    a = S()
    if a.count("L") in [0,n]:
        print(n-1)
        return
    if n == 1:
        print(0)
        return
    if n == 2:
        print(1)
        return
    ans = 0
    f = [0]*n
    for i in range(n-1):
        if a[i] == a[i+1]:
            ans += 1
            if a[i] == "L":
                f[i+1] = 1
            else:
                f[i] = 1
    f.append(0)
    f.append(0)
    d = defaultdict(lambda : 0)
    l = 0
    s = a[0]
    for i in range(n):
        if a[i] != s:
            d[(l,i-1)] = 1
            s = a[i]
            l = i
    r = n-1
    l = 0
    m = 0
    for i in range(k):
        if not i%2:
            while a[r] != "R":
                r -= 1
            while a[l] != "R":
                l += 1
        else:
            while a[r] != "L":
                r -= 1
            while a[l] != "L":
                l += 1
        if d[(l,r)]:
            print(n-1)
            return
        else:
            m += 2-f[l-1]-f[r+1]
    r = n-1
    l = 0
    m_ = 0
    for i in range(k):
        if i%2:
            while a[r] != "R":
                r -= 1
            while a[l] != "R":
                l += 1
        else:
            while a[r] != "L":
                r -= 1
            while a[l] != "L":
                l += 1
        if d[(l,r)]:
            print(n-1)
            return
        else:
            m_ += 2-f[l-1]-f[r+1]
    print(ans+max(m,m_))
    return

#E
def E():
    def add(i):
        while i <= n:
            bit[i] += 1
            i += i&-i

    def sum(i):
        res = 0
        while i > 0:
            res += bit[i]
            i -= i&-i
        return res

    n = I()
    p = LI()
    r = [0]*n
    bit = [0]*(n+1)
    for i in range(n)[::-1]:
        r[i] = (n-i-1)-sum(p[i])
        add(p[i])
    print(r)
    l = [0]*n
    bit = [0]*(n+1)
    for i in range(n):
        l[i] = i-sum(p[i])
        add(p[i])
    print(l)

    return

#F
def F():
    def add(i,x):
        while i <= m:
            bit[i] += x
            i += i&-i

    def sum(i):
        res = 0
        while i > 0:
            res += bit[i]
            i -= i&-i
        return res

    n = I()
    s = LI()
    s.sort()
    f = []
    a = s[0]
    k = 1
    for i in s[1:]:
        if a != i:
            f.append(k)
            k = 0
            a = i
        k += 1
    f.append(k)
    f = f[::-1]
    f.insert(0,0)
    m = len(f)
    bit = [0]*(m+1)
    add(1,1)
    if f[1] > 1:
        print("No")
        return
    j = 2
    for i in range(n):
        su = sum(j-1)
        while su > 0:
            aj = sum(j)-sum(j-1)
            mi = min(f[j]-aj, su)
            add(j,mi)
            aj += mi
            su -= mi
            if aj == f[j]:
                j += 1
    k = [sum(i+1)-sum(i) for i in range(m-1)]
    if k == f[1:]:
        print("Yes")
    else:
        print("No")
    return

#Solve
if __name__ == "__main__":
    F()

Submission status: Wrong Answer

Solution code:
N = int(input())
#S = list(input())

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



ans='Yes'

S.sort()
S.reverse()

bl=[S[0]]
for i in range(N):
    li=S[2**(i):2**(i+1)]
    print(bl,li)
    
    k=max(li)
    if len([x for x in bl if x>k]) < li.count(k):
        print(len([x for x in bl if x>k]),li.count(max(li)))
        ans='No'
        break
    bl=S[:2**(i+1)]

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
from collections import deque
def main():
    N = int( input())
    S = list( map( int, input().split()))
    S.sort(reverse=True)
    for i in range(N):
        if S[0] <= S[i+1]:
            print('No')
            return
    check = N+1
    for i in range(N-1):
        now = pow(2,i)
        for j in range(now):
            for _ in range(N-i-1):
                if S[now+j] <= S[check]:
                    print('No')
                    return
                check += 1

    print('Yes')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
from collections import deque
def main():
    N = int( input())
    S = list( map( int, input().split()))
    S.sort(reverse=True)
    for i in range(N):
        if S[0] <= S[i+1]:
            print('No')
            return
    check = N+1
    for i in range(N-1):
        now = pow(2,i)
        for j in range(now):
            for _ in range(N-i-1):
                print(now+j, check)
                if S[now+j] <= S[check]:
                    print('No')
                    return
                check += 1

    print('Yes')
        
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
#S = list(input())

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



ans='Yes'

S.sort()
S.reverse()

bl=[S[0]]
for i in range(N):
    li=S[2**(i):2**(i+1)]
#    print(bl,li)
    
    if min(bl)==max(li):
        if 2**i-bl.count(min(bl)) < li.count(max(li)):
#            print(2**i-bl.count(min(bl)),li.count(max(li)))
            ans='No'
            break
    bl=S[:2**(i+1)]

print(ans)

Submission status: Wrong Answer

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

while True:
    b = None
    c = 1
    nxs = []
    rr = True
    for x in xs:
        if b == None:
            b = x
            continue
        if c == 0:
            b = x
            c += 1
            rr = True
            continue
        if rr and x == b:
            c += 1
            continue
        rr = False
        nxs.append(x)
        c -= 1
        b = x
    xs = nxs
    if c != 0:
        r = "No"
        break
    if len(xs) == 1:
        r = "Yes"
        break
print(r)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=sorted([int(_) for _ in input().split()])[::-1]
f=1
for i in range(n):
    for j in range(2**i):
        if s[j]==s[j+2**i]:
            f=0
            break
print("Yes" if f else "No")

Submission status: Wrong Answer

Solution code:

n = int(input())

lss = [int(x) for x in input().split(' ')]
lss.sort(reverse = True)	
pos = True
leg = len(lss)
while leg > 1:
	temp = int(leg/2);
	other = lss[temp: leg]
	lss = lss[:temp]

	leg = temp
	for i in range(leg):
		if(lss[i] <= other[i]):
			pos = False
			break
	if pos == False:
		break

if pos:
	print("Yes")
else:
	print("No")

Submission status: Wrong Answer

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

while True:
    b = None
    c = 1
    nxs = []
    rr = False
    for x in xs:
        if b == None:
            b = x
            continue
        if c == 0:
            b = x
            c += 1
            rr = True
            continue
        if rr and x == b:
            c += 1
            continue
        rr = False
        nxs.append(x)
        c -= 1
        b = x
    xs = nxs
    if c != 0:
        r = "No"
        break
    if len(xs) == 1:
        r = "Yes"
        break
print(r)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=sorted([int(_) for _ in input().split()])[::-1]
f=1
for i in range(n):
    for j in range(2**i):
        if s[j]<=s[j+2**i]:
            f=0
            break
print("Yes" if f else "No")

Submission status: Wrong Answer

Solution code:
n = int(input())

lss = [int(x) for x in input().split(' ')]
lss.sort(reverse = True)	
pos = True
leg = len(lss)
print(lss)
while leg > 1:
	temp = int(leg/2);
	other = lss[temp: leg]
	lss = lss[:temp]

	leg = temp
	for i in range(leg):
		if(lss[i] <= other[i]):
			pos = False
			break
	if pos == False:
		break

if pos:
	print("Yes")
else:
	print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
#S = list(input())

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



ans='Yes'

S.sort()
S.reverse()

bl=[S[0]]
for i in range(N):
    li=S[2**(i):2**(i+1)]
#    print(bl,li)
    
#    if bl[-1]==li[0]:
    if len([x for x in bl if x!=bl[-1]]) < len([x for x in li if x==bl[-1]]):
#        print(len([x for x in bl if x!=bl[-1]]),len([x for x in li if x==bl[-1]]))
        ans='No'
        break
    bl=S[:2**(i+1)]

print(ans)

Submission status: Wrong Answer

Solution code:
import bisect

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

flg = True
for i in range(N):
    index = 2**(i) - 1
    what = a[index]
    
    ab = a[0:(index + 1)*2]
    ab.sort()
    how_many = bisect.bisect_right(ab, what) - bisect.bisect_left(ab, what)

    if  how_many > (index + 1):
        flg = False
        break
    else:
        pass
  
if flg:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import bisect

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

flg = True
for i in range(N):
    index = 2**(i) - 1
    what = a[index]
    
    ab = a[0:(index + 1)*2]
    ab.sort()
    how_many = bisect.bisect_right(ab, what) - bisect.bisect_left(ab, what)
    
    print(what,ab,how_many,(index + 1)*2)
    if  how_many > (index + 1):
        flg = False
        break
    else:
        pass
  
if flg:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
*S, = map(int, input().split())
C = Counter(S)

memo = [[-1]*(N+1) for i in range(N+1)]
def comb(n, k):
    if memo[n][k] != -1:
        return memo[n][k]
    if k == 0 or n == k:
        return 1
    memo[n][k] = r = comb(n-1, k) + comb(n-1, k-1)
    return r

*CS, = C.items()
CS.sort(reverse=1)
S = [0]
for k, v in CS:
    S.append(S[-1]+v)
T = [0]
for i in range(N+1):
    T.append(T[-1]+comb(N, i))
ok = 1
if len(S) < len(T):
    ok = 0
else:
    ok = all(a <= b for a, b in zip(S, T))
print("Yes" if ok else "No")

Submission status: Wrong Answer

Solution code:
print('Yes')

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()

    result = []
    result.append(S.pop(-1))

    ans = "Yes"

    for i in range(N):
        x = 1
        for j in range(2**i):
            while(True):
                if len(S)<x:
                    ans = "No"
                    break
                if result[j]>S[-1*x]:
                    result.append(S.pop(-1*x))
                    break
                else:
                    x += 1
            if ans == "No":
                break
        else:
            continue
        break
    print(ans)

if __name__ == "__main__":
    main()

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.hp = -1
        self.parent = parent
        self.child_num = num
        self.childs = []
    
    def make_nodes(self):
        tmp = self.child_num - 1
        for i in range(self.child_num):
            self.childs.append(Node(tmp, parent=self))
            tmp -= 1
            

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

    root = Node(N)
    q = deque()
    q.append(root)
    ok = True
    while len(q) > 0:
        node = q.popleft()
        node.hp = a[i]
        i += 1
        if node.parent != None:
            if node.parent.hp <= node.hp:
                ok = False
                break
        node.make_nodes()
        for nex in node.childs:
            q.append(nex)
    
    if ok:
        print("Yes")
    else:
        print("No")
    # node = root
    # print(node.hp)
    # while node.child_num > 0:
    #     node = node.childs[0]
    #     print(node.hp)
    # q = deque()
    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n = I()
    print(n**3)
    return

#B
def B():
    n = I()
    a = LI()
    b = LI()
    c = LI()
    ans = sum(b)
    for i in range(n-1):
        x = a[i]
        y = a[i+1]
        if y == x+1:
            ans += c[x-1]
    print(ans)
    return

#C
def C():
    n = I()
    b = LI()
    b.append(float("inf"))
    a = [min(b[i],b[i-1]) for i in range(n)]
    print(sum(a))
    return

#D
def D():
    n,k = LI()
    a = S()
    if a.count("L") in [0,n]:
        print(n-1)
        return
    if n == 1:
        print(0)
        return
    if n == 2:
        print(1)
        return
    ans = 0
    f = [0]*n
    for i in range(n-1):
        if a[i] == a[i+1]:
            ans += 1
            if a[i] == "L":
                f[i+1] = 1
            else:
                f[i] = 1
    f.append(0)
    f.append(0)
    d = defaultdict(lambda : 0)
    l = 0
    s = a[0]
    for i in range(n):
        if a[i] != s:
            d[(l,i-1)] = 1
            s = a[i]
            l = i
    r = n-1
    l = 0
    m = 0
    for i in range(k):
        if not i%2:
            while a[r] != "R":
                r -= 1
            while a[l] != "R":
                l += 1
        else:
            while a[r] != "L":
                r -= 1
            while a[l] != "L":
                l += 1
        if d[(l,r)]:
            print(n-1)
            return
        else:
            m += 2-f[l-1]-f[r+1]
    r = n-1
    l = 0
    m_ = 0
    for i in range(k):
        if i%2:
            while a[r] != "R":
                r -= 1
            while a[l] != "R":
                l += 1
        else:
            while a[r] != "L":
                r -= 1
            while a[l] != "L":
                l += 1
        if d[(l,r)]:
            print(n-1)
            return
        else:
            m_ += 2-f[l-1]-f[r+1]
    print(ans+max(m,m_))
    return

#E
def E():
    def add(i):
        while i <= n:
            bit[i] += 1
            i += i&-i

    def sum(i):
        res = 0
        while i > 0:
            res += bit[i]
            i -= i&-i
        return res

    n = I()
    p = LI()
    r = [0]*n
    bit = [0]*(n+1)
    for i in range(n)[::-1]:
        r[i] = (n-i-1)-sum(p[i])
        add(p[i])
    print(r)
    l = [0]*n
    bit = [0]*(n+1)
    for i in range(n):
        l[i] = i-sum(p[i])
        add(p[i])
    print(l)

    return

#F
def F():
    def add(i,x):
        while i <= m:
            bit[i] += x
            i += i&-i

    def sum(i):
        res = 0
        while i > 0:
            res += bit[i]
            i -= i&-i
        return res

    n = I()
    s = LI()
    s.sort()
    f = []
    a = s[0]
    k = 1
    for i in s[1:]:
        if a != i:
            f.append(k)
            k = 0
            a = i
        k += 1
    f.append(k)
    f = f[::-1]
    f.insert(0,0)
    m = len(f)
    bit = [0]*(m+1)
    add(1,1)
    if f[1] > 1:
        print("No")
        return
    j = 1
    for i in range(n):
        su = sum(j)
        su_ = sum(j-1)
        aj = su-su_
        while j < m and aj >= f[j]:
            j += 1
            su = sum(j)
            su_ = sum(j-1)
            aj = su-su_
        mi = min(f[j]-aj, su_)
        add(j,mi)
        su -= mi
        add(j+1,su)
        k = [sum(i+1)-sum(i) for i in range(m-1)]
    if j == m-1:
        print("Yes")
    else:
        print("No")
    return

#Solve
if __name__ == "__main__":
    F()

Submission status: Wrong Answer

Solution code:
import collections
n=int(input())
S=[int(i) for i in input().split()]
SS=collections.Counter(S)
SK=sorted(list(SS.keys()),reverse=True)

n_max=20
F=[0]*(n_max+1)
F[0]=1
for i in range(n_max):
  F[i+1]=(F[i]*(i+1))
def comb(x,y):
  return (F[x]//F[y]//F[x-y])

tot=0
cur=0
room=0
chk=True
for sk in SK:
  tot+=SS[sk]
  if cur<=n:
    room=max(2*room,room+comb(n,cur))

  if tot>room:
    chk=False
  cur+=1
print("Yes" if chk==True else "No")

Submission status: Wrong Answer

Solution code:
from math import factorial
n=int(input())
s=sorted(list(map(int,input().split())))

a=s[2**n-1]

li=[]
for i in range(n+1):
  li=li+[a-i]*(int(factorial(n) / factorial(i) / factorial(n - i)))
li.sort()
f=1
for i in range(2**n):
  if s[i]>li[i]:f=0

if f==1:print("Yes")
else:print("No")

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
S = list(map(int,input().split()))
if len(S)!=2**N:
    print("No")
else:
    ans ="Yes"
    S.sort(reverse = True)
    itr = 1
    for i in range(2**(N-1)):
        for j in range(N-i):
            if S[i]<=S[itr]:
                ans = "No"
            itr +=1
    if S[2*(N-1)]<=S[-1]:
        ans ="No"
    print(ans)

Submission status: Wrong Answer

Solution code:
import collections
n=int(input())
S=[int(i) for i in input().split()]
SS=collections.Counter(S)
SK=sorted(list(SS.keys()),reverse=True)

n_max=20
F=[0]*(n_max+1)
F[0]=1
for i in range(n_max):
  F[i+1]=(F[i]*(i+1))
def comb(x,y):
  return (F[x]//F[y]//F[x-y])

tot=0
cur=0
room=0
chk=True
for sk in SK:
  tot+=SS[sk]
  if cur<=n:
    room=max(2*room,comb(n,cur))

  if tot>room:
    chk=False
  cur+=1
print("Yes" if chk==True else "No")

Submission status: Wrong Answer

Solution code:
from math import factorial
n=int(input())
s=sorted(list(map(int,input().split())))

a=s[2**n-1]

li=[]
for i in range(n+1):
  li=li+[a-i]*(int(factorial(n) / factorial(i) / factorial(n - i)))
f=1
for i in range(2**n):
  if s[i]>li[i]:f=0

if f==1:print("Yes")
else:print("No")

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()

    result = []
    result.append(S.pop(-1))

    ans = "Yes"

    for i in range(N):
        x = 1
        for j in range(2**i):
            while(True):
                if len(S)>=x:
                    ans = "No"
                    break
                if result[j]>S[-1*x]:
                    result.append(S.pop(-1*x))
                    break
                else:
                    x += 1
            if ans == "No":
                break
        else:
            continue
        break
    print(ans)

if __name__ == "__main__":
    main()