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, B = map(int,input().split())
lst = [list(map(int,input().split())) for i in range(M)]
A = list(map(int,input().split()))
"""

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

## Sの要素を大きい順に並べ、それぞれ何体ずついるのか出力
S.sort(reverse=True)
lst = []
pre = S[0]
cnt = 0
for i in range(2**N):
  if S[i] == pre:
    cnt += 1
  else:
    lst.append(cnt)
    pre = S[i]
    cnt = 1
else:
  lst.append(cnt)
#print(lst)
  
## 理想的な増殖を続けた場合
dp = [[0 for j in range(N+1)] for i in range(N+1)] ## dp[i][j]: i秒目の上からj番目
for i in range(N+1): dp[i][0] = 1
for i in range(N):
  for j in range(N):
    dp[i+1][j+1] = dp[i][j+1] + dp[i][j]

ideal = dp[N]
#print(dp[N])


if len(lst) < len(ideal):
  print('No')
  exit()
  
"""
margin = 0
idx = 0
for i in range(N):
  if ideal[i] + margin < lst[idx]:
    print('No')
    exit()
  else:
    margin = ideal[i] + margin - lst[idx]
    idx += 1
"""

margin = 0
for i in range(len(lst)):
  if i <= N:
    margin += ideal[i]
  margin -= lst[i]
  if margin < 0:
    print('No')
    exit()
else:
  print('Yes')

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
S = list(map(int,input().split()))

npS = np.array(sorted(S,reverse = True))

# print(npS)
ans = True
if (npS[0]-npS[1]) <= 0:
    ans = False
if N>=2:
    for i in range(1,N):
        # print(npS[0:2**i],npS[2**i:2**(i*1)],npS[0:2**i]-npS[2**i:2**(i*1)])
        if min(npS[0:2**i]-npS[2**i:2**(i+1)]) <= 0:
            ans = False
            break

if ans == True:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import collections, sys

N = int(input())
S = list(map(int, input().split()))
if N ==1 :
  if S[0] == S[1]:
    print("No")
  else:
    print("Yes")
  sys.exit()
S.sort(reverse = 1)
K = collections.Counter(S)
score_sorted = sorted(K.items(), key=lambda x:x[0], reverse = True)


DP = [[0 for i in range(len(K))] for j in range(N+1)]
DP[0][0] = 1
for i in range(N):#日数
  nokoshi = 0
  for k in range(len(K)):
    if k == 0:
      DP[i+1][k] = DP[i][k]
    else:
      hairu = score_sorted[k][1] - DP[i][k]
      ireru = min(hairu, DP[i][k-1] + nokoshi)
      
      DP[i+1][k] = DP[i][k] + ireru
      nokoshi = DP[i][k-1] + nokoshi - ireru
  if nokoshi:
    print("No")
    break
else:
  print("Yes")

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+=comb(n,cur)
  if tot>room:
    chk=False
  cur+=1
print("Yes" if chk==True else "No")

Submission status: Wrong Answer

Solution code:
N = int(input())
Sp = [int(x) for x in input().split()]
ans = 1
S = sorted(Sp, reverse=True)
# print(S)
for i in range(N):
    for j in range(2 ** i):
        if S[j] <= S[j + (2 ** i)]:
            ans = 0
            break
if ans == 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

now = 0
for i in range(n):
    k = 1<<(n-i-1)
    if any(s[now+j]>= s[now+k+j] for j in range(k)):
        print("No")
        exit()
    now += k
print("Yes")

Submission status: Wrong Answer

Solution code:
import bisect

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

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

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(map(int,input().split()))
s = sorted(s,reverse = True)
index = []
count = 1
 
while (len(index) < n):
    index.append(count)
    count += 1
print(index)
for i in range(len(s)//2):
    for k in index[i:]:
        if(s[i] <= s[i+k]):
            print("Yes")
            break
    else:
        continue
    break
else:
    print("No")

Submission status: Wrong Answer

Solution code:

N = int(input())

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

S.sort()
S.reverse()
flag = True


for i in range(N):

    for j in range(2 ** i):

        if S[j] <= S[(j+1)*2-1]:
            print ("No")
            exit()

print ("Yes")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(map(int,input().split()))
s = sorted(s,reverse = True)
index = []
count = 1
 
while (len(index) < n):
    index.append(count)
    count += 1
print(index)
for i in range(len(s)//2):
    for k in index[i:]:
        if(s[i] > s[i+k]):
            print("No")
            break
    else:
        continue
    break
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
a = Counter(map(int, input().split()))
b = [a[i] for i in sorted(a.keys())] 
tmp = 0
cnt = b.pop()
if cnt != 1:
    print('No')
    exit()
for i in range(n):
    if cnt + tmp > 2**i:
        cnt = tmp - (2**i - cnt)
    elif b:
        cnt = b.pop()
    tmp = 0
    while b and cnt + tmp < 2**i:
        cnt += tmp
        tmp = b.pop()
    if cnt > 2**i or (cnt + tmp > 2**i and cnt <= tmp - (2**i - cnt)):
        print('No')
        break
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
#F問題
N = int(input())
S = list(map(int,input().split()))
S.sort(reverse=True)

old = S.pop(0)
flag = 0
for i in range(N):
    M = 2**i
    for j in range(M):
        now = S.pop(0)

    #print(old,now)
    if old > now:
        old = now
    else:
        flag = 1
        break
        
if flag == 1:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())

s = list(map(int, input().split( )))

list.sort(s,reverse = True)
#print(*s)
lst = []
tmp0 = -1
tmp1 = 0
for i in range(2**n):
    if tmp0 == s[i]:
        tmp1 +=1

    else:
        tmp0 = s[i]
        lst.append(tmp1)
        tmp1 = 1


lst.append(tmp1)
#print(*lst)
ans = "Yes"
def chs(m,k):
    out = 1
    for i in range(m-k+1,m+1):
        out *= i
    for j in range(1,k+1):
        out //= j
    return out
lst2 =[0]+ [chs(n,i) for i in range(n+1)]
#print(*lst)
#print(*lst2)
for i in range(1,n+1):#???
    #print("test",lst[i],chs(n,i-1))

    if sum(lst[:i+1]) > sum(lst2[:i+1]):
        ans = "No"
        break

print(ans)

Submission status: Wrong Answer

Solution code:
def main():    
    _ = int(input())
    s = list(map(int,input().split()))
    s = sorted(s)
    slm = [s.pop(-1)]
    f = True
    snum = len(s)
    while s:
        tmp_slm = sorted(slm,reverse=True)
        for i in tmp_slm:
            for j in range(1,snum+1):
                jj = -j
                if i > s[jj]:
                    slm.append(s.pop(jj))
                    snum -= 1
                    break
                f = False
                break
        if not f:
            break
    if f:
        print("Yes")
    else:
        print("No")     
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

c = collections.Counter(S)

def pascal(N):
  P = [1]
  l = 1
  for i in range(N):
    for j in range(l-1):
      P[j] = P[j] + P[j+1]
    P[l-1] = 1
    P.insert(0, 1)
    l += 1
  return P

P = pascal(N)
for i in range(len(P)-1):
  P[i+1]+=P[i]

c = sorted(c.items(), key=lambda x:x[0], reverse = True)
C = []
for cc in c:
  C.append(cc[1])

for i in range(len(C)-1):
  C[i+1]+=C[i]

LC = len(C)
LP = len(P)

f = True
for i in range(min(LC,LP)):
  if C[i] > P[i]:
    f = False
    break
if f:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
slimes = list(map(int, input().split()))
slimes.sort(reverse=True)
parents = []
idx = 0
while idx <= N-1:
  parents = slimes[:2**idx]
  parents.sort(reverse=True)
  childs = slimes[2**idx:2**(idx+1)]
  childs.sort(reverse=True)
  division = True
  for i, parent in enumerate(parents):
    if childs[i] >= parent:
      division = False
  if not division:
    print('No')
    exit()
  else:
    idx += 1
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)
    for i in range(N):
        for j in range(2**i):
            if S[j]<S[j+2**i]:
                ans = "No"
    print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
*S, = map(int, input().split())
S = sorted(S, reverse=True)
current = [S[0]]
hist = [S[2**i: 2**(i+1)] for i in range(N)]
flag = True
for his in hist:
    for c, h in zip(current, his):
        if c <= h: flag = False; break
    if flag:
        current += his
        continue
    print('No'); break
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
n = int(input())
s = sorted(list(map(int, input().split())),reverse=True)
for i in range(1, n+1):
  if len(set(s[:2**i])) <= i:
    print('No')
    exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
b=list(set(a))
b.sort()
#print(a)
#print(b)

c=[[0 for i in range(j+1)] for j in range(n+1)]
c[0][0]=1
for i in range(1,n+1):
	for j in range(i+1):
		if j==0:
			c[i][j]=c[i-1][j]
		elif j==i:
			c[i][j]=c[i-1][j-1]
		else:
			c[i][j]=c[i-1][j]+c[i-1][j-1]
c=c[-1]

import sys

x=[]
if len(b)<=n:
	print("No")
	sys.exit()
for i in range(n+1):
	t=[b[-i-1] for _ in range(c[i])]
	x+=t
#print(x)

y=[]
for i in range(n):
	t1=[b[-i-1] for _ in range(c[i]-i)]
	t2=[b[-i-2] for _ in range(i)]
	y+=t1+t2
y+=[b[-n-1]]
#print(y)

a=a[::-1]
for i in range(len(a)):
	if y[i]<=a[i]<=x[i]:
		continue
	else:
		print("No")
		sys.exit()
print("Yes")

Submission status: Wrong Answer

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

S.sort(reverse=True)

if all(S[2**i-1] > S[2**(i+1)-1] for i in range(N)):
    print("Yes")
else:
    print("No")

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)

if min(s[1:n+1])>=s[0]:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:

import sys
import math
from copy import deepcopy
from collections import deque, defaultdict
from operator import mul
from functools import reduce
sys.setrecursionlimit(20000000)

# input = sys.stdin.readline


def main():
    n = int(input())
    s = list(map(int, input().split()))

    s.sort()
    s.reverse()
    x = 1

    if n == 0:
        if len(s) == 1:
            print('Yes')
            sys.exit()
        else:
            print('No')
            sys.exit()

    if s[0] > s[1]:

        for _ in range(n):
            a = s[0: x]
            b = s[x:x*2]

            for i in range(x):
                if a[i] > b[i]:
                    pass
                else:
                    print('No')
                    sys.exit()

            x = x * 2

        print('Yes')

    else:
        print('No')
        sys.exit()


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
def cmb(n, r):
    if n-r<r:r=n-r
    if r==0:return 1
    if r==1:return n
    numerator=[n-r+k+1 for k in range(r)]
    denominator=[k+1 for k in range(r)]
    for p in range(2,r+1):
        pivot=denominator[p-1]
        if pivot>1:
            offset=(n-r)%p
            for k in range(p-1,r,p):
                numerator[k-offset]/=pivot
                denominator[k]/=pivot
    result=1
    for k in range(r):
        if numerator[k]>1:
            result*=int(numerator[k])
    return result
n=int(input())
s=sorted(list(map(int,input().split())),reverse=True)
a,b,c=[],s[0],0
for i in range(len(s)-1):
    if b==s[i+1]:
        c+=1
    else:
        a.append(c+1)
        c=0
    b=s[i+1]
if c!=0:
    a.append(c)
if s[-2]==s[-1]:
    a[-1]+=1
else:
    a.append(1)
for i in range(n):
    if a[i]>cmb(n,i):
        print('No')
        sys.exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
import heapq
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):
        for i in range(self.child_num):
            self.childs.append(Node(self.child_num - i - 1, parent=self))
    
    def __lt__(self, other):
        self.child_num < other.child_num
            

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

    root = Node(N)
    q = []
    heapq.heappush(q, (-N, root))
    ok = True
    while len(q) > 0:
        c, node = heapq.heappop(q)
        node.hp = a[i]
        i += 1
        if node.parent:
            if node.parent.hp <= node.hp:
                ok = False
                break
        node.make_nodes()
        for nex in node.childs:
            heapq.heappush(q, (-nex.child_num, 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:
def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r)*(math.factorial(r)))

import math

n = int(input())
S = list(map(int,input().split()))
ans = "Yes"
hp = max(S)
cnt = 0
for i in range(n+1):
    cnt = sum( i == hp for i in S)
    hp -= 1
    if cnt > combination_count(n,i):
        ans = "No"
        break
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = sorted(list(map(int, input().split())),reverse=True)
for i in range(1, n+1):
  print(len(set(s[:2**i])),i)
  if len(set(s[:2**i])) <= i:
    print('No')
    exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
l = []
t = []
n = int(input())
s = list(map(int,input().split()))
a = sorted(s,reverse = True)
while(len(a) != 1):
    l.append(a[len(a)//2:])
    t.append(a[:len(a)//2])
    a = a[:len(a)//2]
l.reverse()
t.reverse()
for i,k in zip(t,l):
    for n,m in zip(i,k):
        if(n >= m):
            print("No")
            break
    else:
        continue
    break
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:

# Setup
import sys
import collections
sys.setrecursionlimit(4100000)

n = int(input())
k = [int(i) for i in input().split()]
d = collections.Counter(k)
od = collections.OrderedDict(sorted(d.items(), reverse=True))

current = 0
gf = True
csum = 0
for i in od.keys():
    csum += od[i]
    if csum > 2**current:
        gf = False
    current += 1
if gf:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
def resolve():
    n=int(input())
    S=sorted(list(map(int,input().split())), reverse=True)
    flag = True
    for i in range(2**(n-1)):
        j=(i+2**(len(bin(i))-2)) if i!=0 else 1
        if S[i]<=S[j]:
            flag = False
            break
    print("Yes" if flag else "No")
resolve()

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 = 2
    for i in range(N-1):
        now = pow(2,i)
        for j in range(now):
            for k 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 bisect


def main():
    N = int(input())
    S = list(map(int, input().split()))

    S.sort()
    k = 2 ** (N - 1)
    while k > 0:
        next_min = S[k]
        next_min_l = bisect.bisect_left(S, next_min, hi=k)
        next_min_r = bisect.bisect_right(S, next_min, lo=k)
        if k - next_min_l > 2 * k - next_min_r:
            print('No')
            return
        del S[:k]
        k //= 2
    print('Yes')


main()

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)
    for i in range(N):
        for j in range(2**i):
            if S[j]<=S[j+2**i]:
                ans = "No"
    print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=sorted(list(map(int,input().split())))
ans="Yes"
for i in range(n):
  for j in range(2**i):
    if s[-(j+1)]<=s[-(j+1)-2**i]:
      ans="No"
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = sorted(list(map(int, input().split())))
total = 2**N
for n in range(N):
    target = 2**(N-n)
    half = target//2
    top = total - target
    for i in range(top, top + half):
        if S[i] >= S[half+i]:
            print("No")
            exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
import copy
def main():    
    _ = int(input())
    s = list(map(int,input().split()))
    s = sorted(s)
    slm = [s.pop(-1)]
    f = True
    snum = len(s)
    while s:
        tmp_slm = sorted(slm)
        for i in tmp_slm:
            for j in range(1,snum+1):
                jj = -j
                if i > s[jj]:
                    slm.append(s.pop(jj))
                    snum -= 1
                    break
                f = False
                break
        if not f:
            break
    if f:
        print("Yes")
    else:
        print("No")     
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from heapq import heapify, heappop

n = int(input())
s = list(map(int, input().split()))
heapify(s)

l = []
for i in range(n, 0, -1):
    tmp = []
    for j in range(2 ** i // 2):
        tmp.append(heappop(s))
    l.append(tmp)

for li in range(len(l) - 1):
    for i in range(len(l[li])):
        if l[li][i] >= l[li + 1][i//2]:
            print("No")
            quit()
if l[-1][0] >= s[0]:
    print("No")
    quit()
print("Yes")

Submission status: Wrong Answer

Solution code:
import sys

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

S.sort()

a = 1
b = 0

for i in range(N):
    m = int(2**(N-i-1))

    mm = int(2**(N-i-2))

    lm = m - mm - 1
    rm = m + mm

    if S[lm] == S[rm]:
        print('No')
        sys.exit()

    del S[0:int(m)]

print('Yes')

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 = 2
    for i in range(N-1):
        now = pow(2,i)
        for j in range(now):
            for k in range(N-i-1):
                if S[now+j] <= S[check]:
                    print('No')
                    return
                check += 1
            if check == N:
                break
    print('Yes')
        
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# Setup
import sys
import collections
sys.setrecursionlimit(4100000)

n = int(input())
k = [int(i) for i in input().split()]
d = collections.Counter(k)
od = collections.OrderedDict(sorted(d.items(), reverse=True))

current = 0
gf = True
for i in od.keys():
    if od[i] > 2**current:
        gf = False
    current += 1
if gf:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N=int(input())
S=list(map(int, input().split()))
S.sort(reverse=True)
beforechecker=1
checker=0
now=1000000001
flag=0
first=1000000001
for i in S:
    if checker==0:
        first=i
    elif first==i:
        flag=1
    if now==i:
        checker+=1
    else:
        if checker>2**beforechecker:
            flag=1
        else:
            beforechecker==beforechecker
        now=i
        checker=1
if checker>2**beforechecker:
    flag=1
if flag==0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys
import math

n = int(input())
ss = list(map(int, input().split()))
ss.sort(reverse = True)

num_1 = sum([1 for x in ss if x == 1])
if num_1 == 2 ** n:
	print("No")
	sys.exit()

for i in reversed(range(n - 1)):
	if ss[2 ** i] == 1:
		ss = ss[:(2 ** i)]

n = int(math.log2(len(ss)))
for i in range(n):
	#print(ss[2 ** i - 1], ss[2 ** i])
	if ss[2 ** i - 1] == ss[2 ** i]:
		print("No")
		sys.exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
N = int(input())
Sp = [int(x) for x in input().split()]
ans = 1
S = sorted(Sp, reverse=True)
# print(S)
for i in range(N):
    if S[(2**i)-1] <= S[(2**(i+1))-1]:
        ans = 0
        break
if ans == 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N=int(input())
S=list(map(int, input().split()))
S.sort(reverse=True)
beforechecker=1
checker=0
now=1000000001
flag=0
first=1000000001
for i in S:
    if checker==0:
        first=i
    elif first==i:
        flag=1
    if now==i:
        checker+=1
    else:
        if checker>beforechecker**2:
            flag=1
        else:
            beforechecker==beforechecker
        now=i
        checker=1
if checker>2**beforechecker:
    flag=1
if flag==0:
    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()
ans = 'Yes'
for i in range(N)[::-1]:
    a = s_list[:2**i]
    b = s_list[2**i:]
    if not np.all(a <= b):
        ans = 'No'
        break
    s_list = s_list[2**i:]
print(ans)

Submission status: Wrong Answer

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

P.sort(reverse=True)
for i in range(N):
    k = 2**i
    for a,b in zip(P[:k], P[k:2*k]):
         if a<=b:
             print('No')
             exit()


P.sort()
pascal = [[1] for i in range(N+2)]

for i in range(N+1):
    for j in range(i):
        pascal[i+1].append(pascal[i][j] + pascal[i][j+1])
    pascal[i+1].append(0)

pascal = pascal[-1]
pascal.pop()

c = 0
for a,b in zip(pascal,pascal[1:]):
    m = min(a,b)
    p,q = P[c:c+a], P[c+a:c+a+b]
    for x,y in zip(p[-m:], q[-m:]):
        if x >= y:
            print('No')
            exit()
    c += a
print('Yes')

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
a = Counter(map(int, input().split()))
b = [a[i] for i in sorted(a.keys())] 
tmp = 0
cnt = b.pop()
if cnt != 1:
    print('No')
    exit()
for i in range(n):
    if cnt + tmp > 2**i:
        cnt = tmp - (2**i - cnt)
    elif b:
        cnt = b.pop()
    tmp = 0
    while b and cnt + tmp < 2**i:
        cnt += tmp
        tmp = b.pop()
    if cnt + tmp > 2**i and cnt <= tmp - (2**i - cnt):
        print('No')
        break
else:
    print('Yes')

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()
ans = 'Yes'
for i in range(N)[::-1]:
    a = s_list[:2**i]
    b = s_list[2**i:]
    if not np.all(a < b):
        ans = 'No'
        break
    s_list = s_list[2**i:]
print(ans)

Submission status: Wrong Answer

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

if len(S) != N**2:
  print("No")
elif int(max(S))-int(min(S))>=N-len(S):
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
s=list(map(int,input().split()))
s.sort()
b=1
if s[-1]==s[-2]:print("No");exit()
for i in range(1,2**n):
  if s[i-1]==s[i]:b+=1
  else:b=1
  if b>n:print("No");exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r)*(math.factorial(r)))

import math

n = int(input())
S = list(map(int,input().split()))
ans = "Yes"
hp = max(S)
cnt = 0
for i in range(n):
    cnt = sum( i == hp for i in S)
    hp -= 1
    if cnt > combination_count(n,i):
        ans = "No"
        break
print(ans)

Submission status: Wrong Answer

Solution code:
# there can be at most N slimes of second-highest health
# there are at least N+1 different healths (look at a single family line)
# if there are x slimes of second-highest health, there are at most N(1+x)-x of
# third-highest health
N = int(input())
S = [int(i) for i in input().split()]
frequencies = {}
for s in S:
    frequencies[s] = frequencies.get(s, 0) + 1
frequencies_by_health = list(sorted(frequencies.items(), reverse=True))
if len(frequencies) < N+1:
    print('No')
else:
    max_in_level = 1
    slimes_seen = 0
    for _, freq in frequencies_by_health:
        if freq > max_in_level:
            print('No')
            break
        slimes_seen += freq
        if max_in_level == 1:
            max_in_level = slimes_seen*N
        # each slime seen can have at most N-1 additional children after this
        max_in_level = slimes_seen*(N-1)
    else:
        print('Yes')

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(map(int,input().split()))
l = sorted(l, reverse = True)
a = 0
for i in range(1,n+1):
    for j in range(0, 2**(i-1)):
        if l[2**(i-1)+j] >= l[j]:
            a = 1
if a == 1:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(map(int, input().split()))
S.sort()
str = "Yes"
num = 1
min_num = S.pop()
for i in range(N):
  if i != 0:
    max_size = S.count(min_num)
    if (num - min_size) < max_size:
      str = "No"
      break
  else:
    if min_num == S[-1]:
      str = "No"
      break
  min_size = 0
  for j in range(num):
    if j == 0:
      min_num = S.pop()
      min_size = 1
    else:
      if S[-1]==min_num:
        S.pop()
        min_size += 1
      else:
        min_num = S.pop()
        min_size = 1
  num *=2
print(str)

Submission status: Wrong Answer

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

S.sort()

ans = 'Yes'
idx_str = 0
for i in range(N):
    step = 2 ** (N - 1 - i)
    for j in range(idx_str, idx_str + step):
        if S[j] >= S[j + step]:
            ans = 'No'
            break
    #
    if ans == 'No':
        break
    else:
        idx_str += step
        continue
    
print(ans)

Submission status: Wrong Answer

Solution code:
def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r)*(math.factorial(r)))

import math

n = int(input())
S = list(map(int,input().split()))
ans = "Yes"
hp = max(S)
cnt = 0
for i in range(n):
    cnt = sum( i >= hp for i in S)
    hp -= 1
    if cnt > combination_count(n,i):
        ans = "No"
        break
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.hp = -1
        self.parent = parent
        self.child_num = num
        self.childs = []
    
    def make_nodes(self):
        for i in range(self.child_num):
            self.childs.append(Node(self.child_num - i - 1, parent=self))
            

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:
            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:
N = int(input())
Sp = [int(x) for x in input().split()]
ans = 1
S = sorted(Sp, reverse=True)
# print(S)
for i in range(N):
    if S[2**i-1] <= S[2**(i+1)-1]:
        ans = 0
        break
if ans == 1:
    print("Yes")
else:
    print("No")