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())
#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 collections
import itertools

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

maxS = max(S)
tmp = []
for i in range(N+1):
    tmp.append((maxS-i, len(list(itertools.combinations(range(N), i)))))
#print(tmp)
a = []
for i in range(len(tmp)):
    for j in range(tmp[i][1]):
        a.append(tmp[i][0])
c = collections.Counter(S)
c = sorted(c.items(), key=lambda x:x[0], reverse=True)
#print(c)

b = []
for i in range(len(c)):
    for j in range(c[i][1]):
        b.append(c[i][0])

#print(a)
#print(b)

ans = 'Yes'
if len(b) > len(a):
    ans = 'No'
else:
    

    for i in range(len(b)):
        if a[i] >= b[i]:
            pass
        else:
            ans = 'No'
print(ans)




#%%

Submission status: Wrong Answer

Solution code:

import collections
import itertools

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

maxS = max(S)
tmp = []
for i in range(N+1):
    tmp.append((maxS-i, len(list(itertools.combinations(range(N), i)))))
#print(tmp)
a = []
for i in range(len(tmp)):
    for j in range(tmp[i][1]):
        a.append(tmp[i][0])
c = collections.Counter(S)
c = sorted(c.items(), key=lambda x:x[0], reverse=True)
#print(c)

b = []
for i in range(len(c)):
    for j in range(c[i][1]):
        b.append(c[i][0])

#print(a)
#print(b)

ans = 'Yes'
if len(b) > len(a):
    ans = 'No'
else:
    

    for i in range(len(b)):
        if a[i] >= b[i]:
            pass
        else:
            ans = 'No'
print(ans)



#%%
import itertools
a = len(list(itertools.combinations(range(4), 1)))
print(a)

#%%

Submission status: Wrong Answer

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

for i in range(N):
    add = []
    for j in range(len(X)):
        add.append(X[j] - 1)
    X += add

X.sort()

for s, x in zip(S, X):
    if s > x:
        print('No')
        exit()

print('Yes')

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 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):
            print(S[i],S[itr])
            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:
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

n=int(input())
s=list(map(int,input().split()))
cnt=[0 for i in range(max(s))]
for si in s:
    cnt[si-1]+=1
# print(cnt)

isYes=True
for i in range(n//2+n%2):
    print(cnt[-1*(i+1)],cmb(n,i))
    if cnt[-1*(i+1)]>cmb(n,i):
        isYes=False
        break
if isYes:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:

n=int(input())
lists = [int(i) for i in input().split()]
"""
n = 5
lists =[1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8]"""
lists.sort(reverse=True)
#print("lists",lists)
#print(2**n,len(lists))


listss = []
listssc = []

for i in range(2**n):
    if i == 0:
        listss.append(1)
    else:
        if lists[i] == lists[i-1]:
            listss.append(listss[i-1]+1)
            
        else:
            listss.append(1)
            listssc.append(listss[i-1])

listssc.append(listss[-1])

#print("listss",listss)
#print("listssc",listssc)

listssr = []
ssc_point = 0
for i in range(2**n):
    listssr.append(listssc[ssc_point]-listss[i])
    
    if listssc[ssc_point]-listss[i] == 0:
        ssc_point += 1

        
"""print("lists",lists)     
print("listss",listss)
print("listssc",listssc)
print("listssr",listssr)"""

ans = "Yes"
tmpmin = 10**9
for i in range(n+1):
    tmplistmin = lists[2**i-1]
    #print(tmpmin,tmplistmin)
    if tmpmin==tmplistmin:
        ans = "No"
        break
    
    if i != 0:
        if tmpmin==lists[2**(i-1)+1-1]:
            if listss[2**(i-1)-1]<=listssr[2**(i-1)+1-1]:
                ans = "No"
                break
            
    tmpmin=tmplistmin

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(map(int,input().split()))
s_s = sorted(s)
S = list(set(s))
flag = True
if len(s) > 2**n:flag = False
for i in range(len(S)):
  if s.count(S[-1-i]) > 2**i:
    flag = False
print('Yes' if flag == True else 'No')

Submission status: Wrong Answer

Solution code:
n = int(input())
s = [int(x) for x in input().split()]

set_s = (sorted(set(s)))
len_s = len(set_s)

ans = True

for i in set_s:
    if s.count(i) <= 2 ** (len_s - (set_s.index(i)) - 1):
        pass
    else:
        ans = False

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

Submission status: Wrong Answer

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

if N+1<=S[0]:
    pass
else:
    print("No")
    exit()    

for i in range(1,N+1):
    S1=S[2**(i-1):2**(i)]
    S2=S[:2**(i-1)]
    for j in range(len(S1)):
        if N+1-i<=S1[j]<S2[j]:
            continue
        else:
            print("No")
            exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
def solve():
    N = int(input())
    Ss = list(map(int, input().split()))

    Ss.sort(reverse=True)

    nums = [1] + [2**i for i in range(N-1)]

    iS = 0
    iCh = 1
    for numCh, num in zip(reversed(range(1, N+1)), nums):
        for j in range(num):
            for k in range(numCh):
                if Ss[iS] <= Ss[iCh]:
                    return False
                iCh += 1
            iS += 1
    return True

if solve():
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

import collections

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

maxS = max(S)
tmp = []
for i in range(N):
    tmp.append((maxS-i, 2**i))
#print(tmp)
a = []
for i in range(len(tmp)):
    for j in range(tmp[i][1]):
        a.append(tmp[i][0])
c = collections.Counter(S)
c = sorted(c.items(), key=lambda x:x[0], reverse=True)
#print(c)

b = []
for i in range(len(c)):
    for j in range(c[i][1]):
        b.append(c[i][0])

#print(a)
#print(b)

ans = 'Yes'
if len(b) > len(a):
    ans = 'No'
else:
    

    for i in range(len(b)):
        if a[i] >= b[i]:
            pass
        else:
            ans = 'No'
print(ans)

Submission status: Wrong Answer

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


i=0
result=0

while i<n-1:
  maxV=max(a[i],a[i+1])
  temp=min(a[i],a[i+1])
  result+=temp
  j=i+2
  while j<n:
    if temp>a[j]:
      result+=temp
      #print(i,j)
    else:
      if a[j]>maxV:
        temp=maxV
        result+=temp
        maxV=a[j]
      else:
        temp=a[j]
        result+=temp
    #print(i,j,temp)
        
    j+=1
  
  i+=1
  
print(result)

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)
x=0
for i in range(len(a)):
    if a[i]>cmb(n,i):
        if a[i]>cmb(n,i)+x:
            print('No')
            sys.exit()
        else:
            x-=a[i]-cmb(n,i)
    else:
        x+=cmb(n,i)-a[i]
print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
#template by uwi 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
ar = sorted(na())[::-1]
sz = 1
for t in range(n):
    tmp = sz
    for i in range(tmp):
        if ar[i] > ar[sz]:
            sz += 1
        else:
            print("No")
            exit(0)
print("Yes")

Submission status: Wrong Answer

Solution code:
N = int(input())
S = sorted([int(x) for x in input().split()], reverse=True)
P = [0] * (2 ** N)
C = [0] * (2 ** N)
C[0] = N
cur = 0
pos = 1
while pos < 2 ** N:
  for c in range(C[cur] - 1, -1, -1):
    P[pos] = cur
    C[pos] = c
    pos += 1
  cur += 1
for i in range(2 ** N - 1, 0, -1):
  if S[i] == S[P[i]]:
    print('No')
    break
else:
  print('Yes')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys,bisect as bs,collections as cl
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

n = onem()

p = l()

p.sort(reverse = True)
p = s(p)
k = 1

for i in range(len(p)):
    if k >= p[i][1]:
        k *= 2
    else:
        break
else:
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

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

class Node(object):
  def __init__(self, val):
    self.child = []
    self.value = val
    
  def birth(self, score):
    if len(score) == 0:
      return True
    
    tmp = len(score)-1
    while self.value < score[tmp] and tmp>=0:
      tmp -= 1
    if tmp < 0:
      return False
    
   
    if self.value > score[tmp]:
      new_val = score.pop(tmp)
      self.child.append(Node(new_val))
    if len(self.child) > 0:
      for it in self.child[:-1]:
        it.birth(score)
       
        
val = a.pop()
root = Node(val)

for i in range(N):
  root.birth(a)
  
if len(a)==0:
  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 = []
    for x in xs:
        if b == None:
            b = x
            continue
        if c > 0 and x != b:
            nxs.append(x)
            c -= 1
        else:
            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
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 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 = copy.deepcopy(slm)
        for i in slm:
            x = False
            for j in range(1,snum+1):
                jj = -j
                if i > s[jj]:
                    slm.append(s.pop(jj))
                    snum -= 1
                    x = True
                    break
            if x is False:
                break
        if x is False:
            f = False
            break
    if x:
        print("Yes")
    else:
        print("No")     
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

n=int(input())
s=list(map(int,input().split()))
cnt=[0 for i in range(max(s))]
for si in s:
    cnt[si-1]+=1
# print(cnt)

isYes=True
for i in range(n//2+n%2):
    # print(cnt[-1*(i+1)],cmb(n,i))
    if cnt[-1*(i+1)]>cmb(n,i):
        isYes=False
        break
if isYes:
    print('Yes')
else:
    print('False')

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(map(int,input().split()))
num = 1
mm = max(S)
for i in range(1,mm):
  num = 2 ** (i-1)
  m = mm - i + 1
  c = S.count(m)
  
  if c > num:
    print("No")
    break

  S = [j for j in S if j != m]
else:
  print("Yes")

Submission status: Wrong Answer

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

if len(slist)==2**n:
    slist = sorted(slist, reverse=True)
    dekai=slist[0]
    nowret=[n]
    nexret=[]
    nowon=0
    nowon2=1
    nowon3=0
    swit=1
    while len(nowret)>0:
        for nr in range(len(nowret)):
            for i in range(nowret[nr]):
                nexret.append(nowret[nr]-i-1)
        for i in range(len(nowret)):
            if nowret[nowon3]!=0:
                #print(nowon, nowon2)
                #print(slist[nowon], slist[nowon2])
                if slist[nowon]<=slist[nowon2]:
                    swit=0
            nowon+=1
            nowon2+=nowret[nowon3]
            nowon3+=1
        nowret=nexret
        nexret=[]
        nowon3=0
    if swit==1:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())
S = list(map(int,input().split()))
S.sort()
S = S[::-1]
tmp = 0
tmpcount = 0
for i in S:
  if tmp == i:
    tmpcount += 1
  else:
    tmp = i
  if tmpcount > n-1:
    print('No')
    sys.exit()
    
print('Yes')

Submission status: Wrong Answer

Solution code:
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations
import sys
import bisect
import string
import math
import time
ts=time.time()
sys.setrecursionlimit(10**6)
def SI():
    return input().split()
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]
YN=['Yes','No']
mo=10**9+7
import random
n=I()
a=LI()
ans=0
a.sort()
l=0
for i in range(n-1):
    m=2**(n-1-i)
    hm=2**(n-1-i-1)
    for j in range(hm):
        if a[l+hm+j]>=a[l+m+j]:
            ans=1

print(YN[int(random.random()*2)])

Submission status: Wrong Answer

Solution code:
import operator

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

S.sort(reverse=True)

flg = True

for n in range(N):
  R = S[:2**n]
  T = S[2**n:2**(n+1)]
  
  if min(list(map(operator.sub,R,T)))<=0:
    print('No')
    flg = False
    break
    
if flg:
  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)
    itr = 1
    for i in range(N):
        for j in range(N-i):
            if S[j]<=S[itr]:
                ans = "No"
            itr +=1
    print(ans)

Submission status: Wrong Answer

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

class Node(object):
  def __init__(self, val):
    self.child = []
    self.value = val
    
  def birth(self, score):
    if len(score) == 0:
      return True
    
    tmp = len(score)-1
    while self.value < score[tmp] and tmp>=0:
      tmp -= 1
    if tmp < 0:
      return False
    
    new_val = score.pop(tmp)
    if self.value > new_val:
      self.child.append(Node(new_val))
    if len(self.child) > 0:
      for it in self.child[:-1]:
        it.birth(score)
        
val = a.pop()
root = Node(val)

for i in range(N):
  root.birth(a)
  
if len(a)==0:
  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 = []
    for x in xs:
        if b == None:
            b = x
            continue
        if c > 0 and c != b:
            nxs.append(x)
            c -= 1
        else:
            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 = list(map(int, input().split()))

S.sort()
print("#", S)

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

tree = [1, 1]
for i in range(N):
    tree_tmp = [tree[0]]
    for j in range(len(tree) - 1):
        tree[1 + j] = tree[j] + tree[j + 1]
    tree_tmp.append(tree[-1])

ans = 'No'
idx = 0
for step in tree[:-1]:
    idx += step
    if S[idx] == S[idx]: break
else:
    ans = 'Yes'
    
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=sorted(list(map(int,input().split())))
f=1
for i in range(n):
  for j in range(2**n-2**(n-i),2**n-2**(n-i-1)):
    if s[j]+1>s[j+2**(n-i-1)]:f=0

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

Submission status: Wrong Answer

Solution code:
import sys,bisect as bs,collections as cl
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

n = onem()

p = l()

p.sort(reverse = True)
p = s(p)
k = 1
for i in range(len(p)):
    if k <= p[i][0]:
        k *= 2
    else:
        break
else:
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

Solution code:
import bisect


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

    S.sort()
    while len(S) > 1:
        k = len(S) // 2
        next_min = S[k]
        n_small = bisect.bisect_left(S, next_min, hi=k)
        if n_small < k and S[k + n_small] == next_min:
            print('No')
            return
        del S[:k]
    print('Yes')


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
current = 0
total = 0
for i in range(n+1):
    cnt = sum( i == hp for i in S)
    hp -= 1
    total += combination_count(n,i)
    if cnt  > total - current:
        ans = "No"
        break
    current += cnt
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(map(int, input().split(" ")))
# n = 18
# s = list(reversed(range(1, 262145)))

s = sorted(s, reverse=True)
from collections import deque

def solve():
    Q = deque()
    Q.appendleft((s[0], 0))
    k = 1
    while k < len(s):
        x, j = Q.pop()
        print("Check", x, j)
        for i in range(j, n):
            if x > s[k]:
                print("    take", s[k], i + 1)
                Q.appendleft((s[k], i + 1))
                k += 1
            else:
                print("No")
                exit(0)
    print("Yes")
solve()

Submission status: Wrong Answer

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

dic = {}
for s in S:
    if s not in dic:
        dic[s] = 1
    else:
        dic[s] += 1
tups = sorted(dic.items(), key=lambda x:x[0], reverse=True)

def main():
    orig, num = tups[0]
    for tup in tups[1:]:
        if tup[1] > num*N:
            print('No')
            return
        orig, num = tup
    print('Yes')

main()

Submission status: Wrong Answer

Solution code:
import bisect


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

    S.sort()
    while len(S) > 1:
        k = len(S) // 2
        next_min = S[k]
        n_small = bisect.bisect_left(S, next_min, hi=k)
        print(S, k, next_min, n_small)
        if n_small < k and S[k + n_small] == next_min:
            print('No')
            return
        del S[:k]
    print('Yes')


main()

Submission status: Wrong Answer

Solution code:
# coding=utf-8
import numpy as np


if __name__ == "__main__":
    N = int(input())
    S = list(map(int, input().split()))

    list_ = [[] for i in range(N+1)]
    list_[0].append(S[0])
    S.sort(reverse=True)

    ctr = len(list_)
    iter_ = 1
    while list_:
        now = list_[0].pop(0)
        if np.all((now - np.array(S[iter_:iter_+ctr])) > 0):
            for list_elm, num in zip(list_[1:], S[iter_:iter_+ctr]):
                list_elm.append(num)
            iter_ += ctr
        else:
            print("No")
            break

        if not list_[0]:
            list_ = list_[1:]
            ctr = len(list_)
    else:
        print("Yes")

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) - 1
    what = a[index]
    
    ab = a[0:index]
    how_many = bisect.bisect_right(ab, what) - bisect.bisect_left(ab, what)
    if  how_many >= (index + 1)/2:
        flg = False
        break
    else:
        pass
  
if flg:
    print('Yes')
else:
    print('No')

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

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


if __name__ == '__main__':
    main()

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()
  
K = collections.Counter(S)
score_sorted = sorted(K.items(), key=lambda x:x[0], reverse = True)

if S[0] == S[1]:
  print("No")
  sys.exit()
  

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 > 0:
    print("No")
    break
else:
  for i in range(len(score_sorted)):
    if DP[N][i] != score_sorted[i][1]:
      print("No")
      break
  else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
from itertools import accumulate
from collections import Counter
N = int(input())

A = [0]*(2**N)
for i in range(1, N+1):
    A.extend([i-1]*(max(1, 2**(N-i))))
A.sort(reverse = True)
A = A[:2**N]
A = list(accumulate([1] + A))
A = [min(A[i], 2**N - i) for i in range(2**N+1)]

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

ss = list(set(S))
ss.sort(reverse = True)

k = 0
ans = 'Yes'
for s in ss:
    if A[k] < C[s] :
        ans = 'No'
        break
    k += C[s]

print(ans)

Submission status: Wrong Answer

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

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

from itertools import groupby


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(bl)-list(groupby(bl))[-1][0] < list(groupby(li))[0][0]:
            ans='No'
            break
    bl=S[:2**(i+1)]

print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdout
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
s = inl()
s.sort(reverse=True)
for i in range(n):
    for j in range(2**i):
        if s[j]<=s[2**i+j]:
            print('No')
            exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations
import sys
import bisect
import string
import math
import time
ts=time.time()
sys.setrecursionlimit(10**6)
def SI():
    return input().split()
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]
YN=['Yes','No']
mo=10**9+7

n=I()
a=LI()
ans=0
a.sort()
l=0
for i in range(n-1):
    m=2**(n-1-i)
    hm=2**(n-1-i-1)
    for j in range(hm):
        if a[l+hm+j]>=a[l+m+j]:
            ans=1

print(YN[ans])

Submission status: Wrong Answer

Solution code:

n=int(input())
lists = [int(i) for i in input().split()]
"""
n = 5
lists =[1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8]"""
lists.sort(reverse=True)
#print("lists",lists)

listss = []
listssc = []

for i in range(2**n):
    if i == 0:
        listss.append(1)
    else:
        if lists[i] == lists[i-1]:
            listss.append(listss[i-1]+1)
            
        else:
            listss.append(1)
            listssc.append(listss[i-1])

listssc.append(listss[-1])

#print("listss",listss)
#print("listssc",listssc)

listssr = []
ssc_point = 0
for i in range(2**n):
    listssr.append(listssc[ssc_point]-listss[i])
    
    if listssc[ssc_point]-listss[i] == 0:
        ssc_point += 1

        
"""print("lists",lists)     
print("listss",listss)
print("listssc",listssc)
print("listssr",listssr)"""

ans = "Yes"
tmpmin = 10**9
for i in range(n):
    tmplistmin = lists[2**i]
    if tmpmin==tmplistmin:
        ans = "No"
        break
    
    if i != 0:
        if tmpmin==lists[2**(i-1)+1]:
            if listss[2**(i-1)]<=listssr[2**(i-1)+1]:
                ans = "No"
                break
            
    tmpmin=tmplistmin

print(ans)

Submission status: Wrong Answer

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

s = sorted(S)
for i in range(N//2):
    if s[i] <= s[i+1] or s[i] <= s[2*i]:
        ret = "No"
        break
else:
    ret = "Yes"
print(ret)