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 = input().split(' ')

S.sort(reverse=True)
n = 0
flg = 0
slime = []
slime.append(int(S[0]))
while True:
  if flg == 1:
    break
  if n >= N:
    print('Yes')
    break
  itr = 2 ** n
  for i in range(itr):
    if slime[i] <= int(S[itr + i]):
      print('No')
      flg = 1
      break
    slime.append(int(S[itr + i]))  
  n = n + 1

Submission status: Wrong Answer

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

s = sorted(s, reverse=True)

for i in range(n):
    i2 = 2**i
    ss = s[i2]
    for j in range(i2-1):
        if s[i2-j-1] > ss:
            break
        if s[i2-j-1] == s[i2*2-j-1]:
            print('No')
            exit(0)

print('Yes')

Submission status: Wrong Answer

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

s = sorted(s, reverse=True)

for i in range(n):
    i2 = 2**i
    ss = s[i2]
    for j in range(i2//2+1):
        if s[i2-j-1] > ss:
            break
        if s[i2-j-1] == s[i2*2-j-1]:
            print('No')
            exit(0)

print('Yes')

Submission status: Wrong Answer

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

s = sorted(s, reverse=True)

for i in range(n):
    i2 = 2**i
    ss = s[i2]
    for j in range(i2//2):
        if s[i2-j-1] > ss:
            break
        if s[i2-j-1] == s[i2*2-j-1]:
            print('No')
            exit(0)

print('Yes')

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(map(int, input().split()))
if len(s) != 2**n:
    print('No')
    exit(0)

s = sorted(s, reverse=True)

for i in range(n):
    if s[2**i] >= s[2**i-1]:
        print('No')
        exit(0)

print('Yes')

Submission status: Wrong Answer

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

s = sorted(s, reverse=True)

for i in range(n):
    if s[2**i] >= s[2**i-1]:
        print('No')
        exit(0)

print('Yes')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
a.sort()

big =  [a[-1]]
rest = a[:-1]

for _ in range(n):
    not_yet = []
    for b in big:
        while rest:
            r = rest.pop()
            if r < b:
                big.append(r)
                break
            not_yet.append(r)
    big.sort(reverse=True)
    rest += not_yet[::-1]
print("Yes" if len(rest)==0 else "No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
a = [int(item) for item in input().split()]
cnt = Counter(a)

key_num = len(cnt.keys())
rank = [0] * key_num 
keys = list(cnt.keys())
keys.sort(reverse=True)
for i, key in enumerate(keys):
    rank[i] = cnt[key]
cur = [0] * key_num 
cur[0] = 1
for i in range(n):
    tmp = cur[:]
    for j in range(key_num-1):
        par = tmp[j]
        for k in range(j+1, key_num):
            if rank[k] < cur[k] + par and par > 0:
                cur[k] = rank[k]
                par -= rank[k] - tmp[k]
            else:
                cur[k] += par
                par = 0
                break
if sum(cur) == 2**n:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
a = [int(item) for item in input().split()]
cnt = Counter(a)

key_num = len(cnt.keys())
rank = [0] * key_num 
keys = list(cnt.keys())
keys.sort(reverse=True)
for i, key in enumerate(keys):
    rank[i] = cnt[key]
cur = [0] * key_num 
cur[0] = 1
for i in range(n):
    tmp = cur[:]
    for j in range(key_num-1):
        par = tmp[j]
        for k in range(j+1, key_num):
            if rank[k] < tmp[k] + par and par > 0:
                cur[k] = rank[k]
                par -= rank[k] - tmp[k]
            else:
                cur[k] += par
                par = 0
if sum(cur) == 2**n:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
s = [int(i) for i in input().split()]
s.sort()
s += [0]

slime = []
count = 0

if n == 18: exit()

for i in range(2**n):
    count += 1
    if s[i] != s[i+1]:
        slime.append([s[i], count, 0])
        count = 0

slime_mother = [[slime.pop()[0], -1, 1]]


for i in range(n):
    for j in range(len(slime_mother)):
        for h in range(slime_mother[j][2]):
            k = 0
            try:
                while slime[slime_mother[j][1]-k][1] == 0:
                    k += 1
            except:

                for ii in range(len(slime)):
                    if slime[ii][1] != 0:
                        print("No")
                        exit()
                else:
                    if len(slime) == 0:
                        print("No")
                    else:
                        print("Yes")
                    exit()

            slime_mother[j][1] -= k
            slime[slime_mother[j][1]][1] -= 1
            if slime[slime_mother[j][1]][2] == 0:
                slime[slime_mother[j][1]][2] = 1
                slime_mother.append([slime[slime_mother[j][1]][0], slime_mother[j][1]-1, 1])
            else:
                slime_mother[-slime_mother[j][1]][2] += 1



print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())
s = [int(i) for i in input().split()]
s.sort()
s += [0]

slime = []
count = 0
for i in range(2**n):
    count += 1
    if s[i] != s[i+1]:
        slime.append([s[i], count, 0])
        count = 0

slime_mother = [[slime.pop()[0], -1, 1]]


for i in range(n):
    for j in range(len(slime_mother)):
        for h in range(slime_mother[j][2]):
            k = 0
            try:
                while slime[slime_mother[j][1]-k][1] == 0:
                    k += 1
            except:

                for ii in range(len(slime)):
                    if slime[ii][1] != 0:
                        print("No")
                        exit()
                else:
                    print("Yes")
                    exit()

            slime_mother[j][1] -= k
            slime[slime_mother[j][1]][1] -= 1
            if slime[slime_mother[j][1]][2] == 0:
                slime[slime_mother[j][1]][2] = 1
                slime_mother.append([slime[slime_mother[j][1]][0], slime_mother[j][1]-1, 1])
            else:
                slime_mother[-slime_mother[j][1]][2] += 1



print("Yes")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
s = [int(i) for i in input().split()]
s.sort()
s += [0]

slime = []
count = 0
for i in range(2**n):
    count += 1
    if s[i] != s[i+1]:
        slime.append([s[i], count, 0])
        count = 0

slime_mother = [[slime.pop()[0], -1, 1]]


for i in range(n):
    for j in range(len(slime_mother)):
        for h in range(slime_mother[j][2]):
            k = 0
            try:
                while slime[slime_mother[j][1]-k][1] == 0:
                    k += 1
            except:
                print("No")
                exit()

            slime_mother[j][1] -= k
            slime[slime_mother[j][1]][1] -= 1
            if slime[slime_mother[j][1]][2] == 0:
                slime[slime_mother[j][1]][2] = 1
                slime_mother.append([slime[slime_mother[j][1]][0], slime_mother[j][1]-1, 1])
            else:
                slime_mother[-slime_mother[j][1]][2] += 1



print("Yes")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a=sorted(a, reverse=True)
for i in range(n):
  if i == 0:
    continue
  elif sum(a[:2**(i-1)]) > sum(a[2**(i-1):2**i])+2**(i-1)-1:
    continue
  else:
    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)
def solve():
    for i in range(N):
        for j in range(1<<i):
            if S[j] == S[j+(1<<i)]:
                return False
    return True

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

Submission status: Wrong Answer

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

S = sorted(S,reverse=True)

def solve(S):
    for i in range(N):
        gap = 2**i
        for j in range(gap):
            if S[j] == S[j+gap]:
                return False
    return True

print("Yes" if solve(S) else "No" )

Submission status: Wrong Answer

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

S = sorted(S,reverse=True)
print(S)

def solve(S):
    for i in range(N):
        gap = 2**i
        for j in range(gap):
            if S[j] == S[j+gap]:
                return False
    return True

print("Yes" if solve(S) else "No" )

Submission status: Wrong Answer

Solution code:
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
ts=time.time()
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
show_flg=False
#show_flg=True

ans='Yes'
n=I()
a=LI()
a=sorted(a)[::-1]
for i in range(n):
    m=2**i
    for j in range(m):
        show(m,j,'prnt=',a[j],'chrd=',a[j+m])
        if a[j]<=a[j+m]:
            ans='No'

print(ans)

Submission status: Wrong Answer

Solution code:
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
import sys
sys.setrecursionlimit(10**6)
n=i1()
s=i2()
def f(n,y):
 if n==0:
    return "Yes"
 x=[0 for i in range(1<<n)]
 y.sort()
 j=0
 z=-1
 for i in range(1<<n)[::-1]:
  if z==y[i]:
    j+=2
  else:
    j=0
  xi=(1<<n)-1-x[::-1].index(0)
  if xi+j>(1<<n)-1:
     return "No"
  x[xi+j]=y[i]
  z=y[i]
 return f(n-1,x)
print(f(n,s))

Submission status: Wrong Answer

Solution code:
from heapq import heapify, heappush, heappop


class BIT:
    def __init__(self, N):
        self.size = N
        self.tree = [0] * (N + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    def __str__(self):
        return "BIT: [{}]".format(
            ", ".join(str(self.sum(i + 1) - self.sum(i))
                      for i in range(self.size))
        )

    def bisect_left(self, r):
        bit = self.tree
        if r == 0:
            return 0
        l = 1 << (r.bit_length() - 1)
        k = l // 2
        while r - l > 1:
            if bit[r] > bit[l]:
                l += k
            else:
                r = l
                l //= 2
            k //= 2
        return r if bit[r] > bit[l] else l


N, *S = map(int, open(0).read().split())
memo = {n: i for i, n in enumerate(sorted(set(S)), 1)}
T = [memo[s] for s in S]
bit = BIT(len(memo))
for t in T:
    bit.add(t, 1)

Q = [-max(T)]
for _ in range(N):
    R = []
    while Q:
        t = -heappop(Q)
        heappush(R, -t)

        i = bit.bisect_left(t - 1)
        if i == 0:
            print("No")
            quit()
        bit.add(i, -1)
        heappush(R, -i)
    Q = R

print("Yes")

Submission status: Wrong Answer

Solution code:
from heapq import heapify, heappush, heappop


class BIT:
    def __init__(self, N):
        self.size = N
        self.tree = [0] * (N + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    def __str__(self):
        return "BIT: [{}]".format(
            ", ".join(str(self.sum(i + 1) - self.sum(i))
                      for i in range(self.size))
        )

    def bisect_left(self, r):
        bit = self.tree
        if r == 0:
            return 0
        l = 1 << (r.bit_length() - 1)
        k = l // 2
        while r - l > 1:
            if bit[r] > bit[l]:
                l += k
            else:
                r = l
                l //= 2
            k //= 2
        return r if bit[r] > bit[l] else l


N, *S = map(int, open(0).read().split())
memo = {n: i for i, n in enumerate(sorted(set(S)), 1)}
T = [memo[s] for s in S]
bit = BIT(len(T))
for t in T:
    bit.add(t, 1)

Q = [max(T)]
for _ in range(N):
    R = []
    while Q:
        t = heappop(Q)
        heappush(R, t)

        i = bit.bisect_left(t - 1)
        if i == 0:
            print("No")
            quit()
        bit.add(i, -1)
        heappush(R, i)
    Q = R

print("Yes")

Submission status: Wrong Answer

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

parents = [(S.pop(),N)]

flg = True
while parents and flg:
    s,n = parents.pop(0)
    for i in range(1,n+1):
        x = S.pop()
        if s > x and n-i != 0:
            parents.append((x,n-i))
            
        elif s <= x:
            flg = False
            break
 
if flg:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

parents = [(S.pop(),N)]

flg = True
while parents and flg:
    s,n = parents.pop()
    for i in range(1,n+1):
        x = S.pop()
        if s > x and n-i != 0:
            parents.append((x,n-i))
            print(parents)
        elif s <= x:
            flg = False
            break
    parents = parents[::-1]
 
if flg:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
from queue import Queue

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

parents = Queue()
parents.put((S.pop(),N))

flg = True
while parents and flg:
    s,n = parents.get()
    for i in range(1,n+1):
        x = S.pop()
        if s > x and n-i != 0:
            parents.put((x,n-i))
        elif s <= x:
            flg = False
            break
 
if flg:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
a = [int(item) for item in input().split()]
cnt = Counter(a)

t = 1
used = 0
initialized = False
for c in range(2**18, 0, -1):
    if c in cnt.keys():
        if not initialized:
            if cnt[c] > 1:
                print("No")
                exit()
            initialized = True
        if cnt[c] > t:
            print("No")
            exit()
        t = (used + 1) * n - used
        used += cnt[c]
print("Yes")

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
a = [int(item) for item in input().split()]
cnt = Counter(a)

t = 1
used = 0
initialized = False
for c in range(2**18, 0, -1):
    if c in cnt.keys():
        print(c, t, used)
        if not initialized:
            if cnt[c] > 1:
                print("No")
                exit()
            initialized = True
        if cnt[c] > t:
            print("No")
            exit()
        t = (used + 1) * n - used
        used += cnt[c]
print("Yes")

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
a = [int(item) for item in input().split()]
cnt = Counter(a)

t = 1
used = 0
initialized = False
for c in range(2**18, 0, -1):
    if c in cnt.keys():
        # print(c, t, used)
        if not initialized:
            if cnt[c] > 1:
                print("No")
                exit()
            initialized = True
            continue
        if cnt[c] > t * n - used:
            print("No")
            exit()
        used += cnt[c]
        t *= n
print("Yes")

Submission status: Wrong Answer

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

from collections import Counter as ct

s.sort()
t = ct(s)

pre = 0
now = 1 << (n - 1)
tot = 0
for i in s:
    if i == pre:
        continue
    v = t[i]
    mx = now
    if tot > (now >> 1):
        mx = now + (now >> 1) - tot

    if v > mx:
        print("No")
        exit(0)
    tot += v
    while tot >= now:
        tot -= now
        now >>= 1
        if now == 0:
            now = 1
    pre = i
print("Yes")

Submission status: Wrong Answer

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

from collections import Counter as ct

s.sort()
t = ct(s)

pre = 0
now = 1 << (n - 1)
tot = 0
for i in s:
    if i == pre:
        continue
    v = t[i]
    mx = now
    if tot > (now >> 1):
        mx = now + (now >> 1) - tot
    if v > mx:
        print("No")
        exit(0)
    tot += v
    if tot >= now:
        tot -= now
        now >>= 1
        if now == 0:
            now = 1
    pre = i
print("Yes")

Submission status: Wrong Answer

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

from collections import Counter as ct

s.sort()
t = ct(s)

pre = 0
now = 1 << (n - 1)
tot = 0
for i in s:
    if i == pre:
        continue
    v = t[i]
    mx = now
    if tot > (now >> 1):
        mx = now + (now >> 1) - tot
    if v > mx:
        print("no")
        exit(0)
    tot += v
    if tot >= now:
        tot -= now
        now >>= 1
        if now == 0:
            now = 1
    pre = i
print("yes")

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
import bisect
def solve():
  n = int(input())
  s = list(int(i) for i in input().split())
  s = sorted(s)
  s = [0] + [0] + s + [10**10]
  query = s[-2]
  count = 1
  genkai = 2+2**n -1
  #print(query)
  #print(s)
  for i in range(n):
    nextplace = bisect.bisect_left(s,query)-1
    genkai -= 2**i
    #print(nextplace,genkai)

    if nextplace < genkai:
      print("No")
      exit()
    count += 2**(i)
    #print(s)
    query = s[-1*count -1]
    #print(query)
  print("Yes")
solve()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
import bisect
def solve():
  n = int(input())
  s = list(int(i) for i in input().split())
  s = sorted(s)
  s = [0] + [0] + s + [10**10]
  query = s[-2]
  count = 1
  genkai = 2+2**n -1
  #print(query)
  #print(s)
  for i in range(n):
    nextplace = bisect.bisect_left(s,query)-count
    genkai -= 2**i
    #print(s[nextplace],s[genkai])
    if s[nextplace] == query:
      print("No")
      exit()
    if s[nextplace] < s[genkai]:
      print("No")
      exit()
    count += 2**(i)
   # print(s)
    query = s[-1*count -1]
    #print(query)
  print("Yes")
solve()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
import bisect
def solve():
  n = int(input())
  s = list(int(i) for i in input().split())
  s = sorted(s)
  s = [0] + [0] + s + [10**10]
  query = s[-2]
  count = 1
  genkai = 2+2**n -1
  #print(s)
  for i in range(n):
    nextplace = bisect.bisect_left(s,query)-count
    genkai -= 2**i
    #print(s[nextplace],s[genkai])
    if s[nextplace] == query:
      print("No")
      exit()
    if s[nextplace] < s[genkai]:
      print("No")
      exit()
    count += 2**(i)

    query = s[-1*count]
  print("Yes")
solve()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
import bisect
def solve():
  n = int(input())
  s = list(int(i) for i in input().split())
  s = sorted(s)
  s = [0] + [0] + s + [10**10]
  query = s[-2]
  count = 1
  genkai = 2+2**n -1
  #print(s)
  for i in range(n):
    nextplace = bisect.bisect_left(s,query)-count
    genkai -= 2**i
    #print(s[nextplace],s[genkai])
    if s[nextplace] == query:
      print("No")
      exit()
    if s[nextplace] < s[genkai]:
      print("No")
      exit()
    count += 2**(i)
    query = s[nextplace]
  print("Yes")
solve()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
import bisect
def solve():
  n = int(input())
  s = list(int(i) for i in input().split())
  s = sorted(s)
  s = [0] + [0] + s + [10**10]
  query = s[-2]
  count = 1
  genkai = 2+2**n -1
  #print(s)
  for i in range(n):
    nextplace = bisect.bisect_left(s,query)-count
    genkai -= 2**i
    #print(nextplace,genkai)
    if s[nextplace] == query:
      print("No")
      exit()
    if nextplace < genkai:
      print("No")
      exit()
    count += 2**(i)
    query = s[nextplace]
  print("Yes")
solve()

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
S = sorted(list(map(int, input().split())))
parent = [S[-1]]
rest = S[:-1]
for i in range(N):
    next_generation = []
    next_rest = []
    for p in parent[::-1]:
        while True:
            if len(rest) == 0:
                print('No')
                sys.exit()
            q = rest.pop()
            if p>q:
                next_generation.append(q)
                break
            else:
                next_rest.append(q)
    parent+=next_generation[::-1]
    rest += next_rest[::-1]
print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
S = sorted(list(map(int, input().split())))
parent = [S[-1]]
rest = S[:-1]
for i in range(N):
    next_generation = []
    next_rest = []
    for p in parent:
        while True:
            if len(rest) == 0:
                print('No')
                sys.exit()
            q = rest.pop()
            if p>q:
                next_generation.append(q)
                break
            else:
                next_rest.append(q)
    parent+=next_generation[::-1]
    rest += next_rest[::-1]
print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
S = sorted(list(map(int, input().split())))
parent = [S[-1]]
rest = S[:-1]
for i in range(N):
    next_generation = []
    next_rest = []
    for p in parent:
        while True:
            if len(rest) == 0:
                print('No')
                sys.exit()
            q = rest.pop()
            if p>q:
                break
            else:
                next_rest.append(q)
        next_generation.append(q)
        parent+=next_generation[::-1]
        rest += next_rest[::-1]
print('Yes')

Submission status: Wrong Answer

Solution code:
N = int(input())
S = sorted(list(map(int, input().split())), reverse = True)
def C(N, S):
    for i in range(N):
        for j in range(1<<i):
            if S[(1<<i)+j] == S[j]:
                return False
    return True
if C(N, S):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
S = sorted(list(map(int, input().split())), reverse = True)
def C(N, S):
    for i in range(N):
        for j in range(1<<i):
            print((1<<i)+j)
            if S[(1<<i)+j] == S[j]:
                return False
    return True
if C(N, S):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
S = sorted(list(map(int, input().split())), reverse = True)
def C(N, S):
    for i in range(N):
        if any(S[j] == S[(1<<i)-1+j] for j in range(1<<i)):
            return False
    return True
if C(N, S):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N = int(input())
S = sorted(list(map(int, input().split())), reverse = True)
def C(N, S):
    for i in range(0, N-1):
        if any(S[(1<<i)-1+j] == S[(1<<(i+1))-1+j] for j in range(1<<i)):
            return False
    return True
if C(N, S):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

a=[]*n
s.sort()
s.reverse()
ccnt=1
pcnt=0
for i in range(1,n):
  for j in range(i):
    for k in range (n-i):
      if s[pcnt]<=s[ccnt]:
        print("No")
        sys.exit()
      ccnt+=1
    pcnt+=1
print("Yes")

Submission status: Wrong Answer

Solution code:
N=int(input())
S=list(map(int, input().split()))
S.sort(reverse=True)
ans="Yes"
if S[0]<=S[1]:
  ans="No"
else:
  parent_id=[1]
  for n in range(2, N+1):
    start_id=parent_id[-1]+N+2-n
    child_id=[start_id+(N-n+1)*i for i in range(2**(n-2))]
    for i in range(len(parent_id)):
      if S[parent_id[i]]<=S[child_id[i]]:
        ans="No"
        break
    if ans=="No":
      break
    parent_id=[i+1 for i in parent_id]+child_id
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=list(map(int, input().split()))
S.sort(reverse=True)
ans="Yes"
if S[0]==S[1]:
  ans="No"
else:
  parent_id=[1]
  for n in range(2, N+1):
    start_id=parent_id[-1]+N+2-n
    child_id=[start_id+(N-n+1)*i for i in range(2**(n-2))]
    tmp=[]
    for i in range(len(parent_id)):
      if S[parent_id[i]]==S[child_id[i]]:
        ans="No"
        break
    if ans=="No":
      break
    parent_id=[i+1 for i in parent_id]+child_id
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    s = list(map(int, input().split()))
    s.sort(reverse=True)
    #    print(s)
    for e in range(n):
        w = 2 ** e
        for i in range(w):
            if s[i] <= s[i + w]:
                print("No")
                exit()
    print("Yes")

main()

Submission status: Wrong Answer

Solution code:
n=int(input())
c=input().split()
c=list(map(int,c))
c.sort(reverse=True)
nc=len(c)
#最初の親のセット
pk=c[0]
p=[]
p.append(pk)
flag=False
#親の数だけ親より小さい最大数をｓから探しPの後ろに接続、
#同時にsは親最大数に置換する
#親未満のものがなくなるか　ｐの長さがｓと同じになったら終了

for i in range(n) :   
  np=len(p)             #現在の親の数
  for ip in range(np):  #親の数だけ繁殖
    flag=False
    for ic in range(nc): #全個体リストから親未満のSを探索
      if p[ip]>c[ic]:    #繁殖可能
        flag=True        
        p.append(c[ic])  #ｐの後ろに子供を連けつ
        c[ic]=pk         #sにマーク
        break  #次の親判定に
    #for end---------------
    if flag==False:# 繁殖可能でない親が判明 終了する   
      break
  #for end-----------------
  print(i)
  print(c)
  print(p)
  if flag==False:# 繁殖可能でない親が判明 終了する
    break
#while end------------------
if nc==len(p) and flag==True:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
c=input().split()
c=list(map(int,c))
c.sort(reverse=True)
nc=len(c)
#最初の親のセット
pk=c[0]
p=[]
p.append(pk)
flag=False
#親の数だけ親より小さい最大数をｓから探しPの後ろに接続、
#同時にsは親最大数に置換する
#親未満のものがなくなるか　ｐの長さがｓと同じになったら終了
i=1
while len(p)*2<=nc :    #この施行での個体数が全個体数を超えない
  flag=False
  np=len(p)             #現在の親の数
  for ip in range(np):  #親の数だけ繁殖
    for ic in range(nc): #全個体リストから親未満のSを探索
      if p[ip]>c[ic]:    #繁殖可能
        flag=True        
        p.append(c[ic])  #ｐの後ろに子供を連けつ
        c[ic]=pk         #sにマーク
        break
    #for end---------------
    if flag==True:#繁殖可能でありこの親に関して探索終了　次の親探索   
      break
  #for end-----------------
  if flag==False:#繁殖可能な個体がない親があった
    break
#while end------------------
if nc==len(p) and flag==True:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
c=input().split()
c=list(map(int,c))
c.sort(reverse=True)
nc=len(c)
#print('個体数',nc)
#print(c)
p=[]
#最初の親のセット
p.append(max(c))
pk=p[0]
#print(p)
flag=False
#親の数だけ親より小さい最大数をｓから探しPの後ろに接続、
#同時にsは親最大数に置換する
#親未満のものがなくなるか　ｐの長さがｓと同じになったら終了
i=1
while len(p)!=len(c):
  i=i*2		#繁殖後の 個体数
  if i>nc:
    flag=False
    break	#個体数が集合要素を超えたらNG
  np=len(p)
  for ip in range(np): #親の数だけ繁殖
    for ic in range(nc): #親未満のSを探索
      if p[ip]>c[ic]:
        flag=True        #繁殖可能
        p.append(c[ic])  #ｐの後ろに連けつ
        c[ic]=pk         #sにマーク
        #print(ip,ic,p)
        break
    #for end---------------
    if flag==False:
      break
  #for end-----------------
#  print(len(p))
#  print(p)
#  print(c)
  if flag==False:
    break
#while end------------------
if nc==i:
  print("Yes")
else:
  print("No")