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:
#!/usr/bin/python3

import math
import os
import sys


DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


def solve(N, S):
    S.sort(reverse=True)
    if S[0] == S[1]:
        return False

    i = 1
    rest = 1
    while i < len(S):
        j = i
        while j < len(S) and S[i] == S[j]:
            j += 1
        c = j - i
        if rest <= c:
            return False
        rest += c
        i = j

    return True


def main():
    N = int(inp())
    S = [int(e) for e in inp().split()]
    print('Yes' if solve(N, S) else 'No')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3

import math
import os
import sys


DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


def solve(N, S):
    S.sort(reverse=True)
    if S[0] == S[1]:
        return False

    i = 1
    rest = 1
    while i < len(S):
        j = i
        while j < len(S) and S[i] == S[j]:
            j += 1
        c = j - i
        if rest < c:
            return False
        rest += c
        i = j

    return True


def main():
    N = int(inp())
    S = [int(e) for e in inp().split()]
    print('Yes' if solve(N, S) else 'No')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
from io import StringIO
import unittest
import bisect
class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """2
4 2 3 1"""
        output = """Yes"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """2
1 2 3 1"""
        output = """Yes"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """1
1 1"""
        output = """No"""
        self.assertIO(input, output)
    def test_入力例_4(self):
        input = """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"""
        output = """No"""
        self.assertIO(input, output)

def resolve():
    n=int(input())
    A=[int(i) for i in input().split()]
    A.sort()
    x=[A[-1]]
    A.remove(x[0])
    for i in range(n):
#        print(x,A)
        for j in range(2**i):
            ind=bisect.bisect_left(A,x[2**i-1])
            if ind==0:
                print('No')
                break
            x.append(A.pop(ind-1))
        else:
            continue
        break
    else:
        print('Yes')


if __name__ == "__main__":
#    unittest.main()
    resolve()

Submission status: Wrong Answer

Solution code:
import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """2
4 2 3 1"""
        output = """Yes"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """2
1 2 3 1"""
        output = """Yes"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """1
1 1"""
        output = """No"""
        self.assertIO(input, output)
    def test_入力例_4(self):
        input = """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"""
        output = """No"""
        self.assertIO(input, output)

def resolve():
    n=int(input())
    A=[int(i) for i in input().split()]
    A.sort(reverse=True)
    for i in range(n):
        for j in range(2**i):
            if A[j]<=A[j+2**i]:
                print("No")
                break
        else:
            continue
        break
    else:
        print('Yes')

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

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

S.sort(reverse=True)
ans = [S[0]]
tmp = []
tmpnum = 0
for i in range(n):
  for j in range(2**(i)):
    tmpnum = S[i+j+1]
    if tmpnum < ans[j]:
      tmp.append(tmpnum)
    else:
      print('No')
      sys.exit()
  for k in tmp:
    ans.append(k)
print('Yes')

Submission status: Wrong Answer

Solution code:
from math import log2
import sys
n = int(input())
s =list(map(int, input().split()))
s.sort()
s.reverse()
flag = 0
if s[0] ==s[1]:
    print("No")
    sys.exit()
for i in range(2,2**n):
    ind = int(log2(i))
    if s[i-2**ind]==s[i]:
        flag =1
        break
if flag == 0:
    print("Yes")
else:
    print("No")

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()
m=10**9+1
import heapq
import bisect
s.sort()
heapq.heapify(s)
x=[s[-1]]
s[-1]=m
a="Yes"
for i in range(n):
 y=[]
 for j in range(1<<i):
   z=bisect.bisect_left(s,x[j])-1
   if z<0:
     a="No"
   y.append(s[z])
   s[z]=m
 x+=y
 x.sort(reverse=True)
print(a)

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()
s.sort(reverse=True)
i=0
x=[s[0]]
k=1
a="Yes"
while i<n:
 y=[]

 for j in range(1<<i):
   z=s[k]
   k+=1
   if z<x[j]:
      y.append(z)
 i+=1
 x+=y
 if len(x)!=1<<i:
    a="No"
    break
 x.sort(reverse=True)
print(a)

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()
s.sort(reverse=True)
i=0
x=[s[0]]
k=1
a="Yes"
while i<n:
 y=[]
 for j in range(1<<i):
   z=s[k]
   k+=1
   if z>=x[j]:
      a="No"
   y.append(z)
 i+=1
 x+=y
 x.sort(reverse=True)
print(a)

Submission status: Wrong Answer

Solution code:
import math

N = int(input())
S = [ int(n) for n in input().split() ]
#S = list(range(2**N))


Sr = sorted(S, reverse=True)
T = []
s = Sr[0]
t = 1
for i in range(1,2**N):
    if Sr[i] == s:
        t += 1
    else:
        s = Sr[i]
        T.append(t)
        t = 1
T.append(t)
#print(T)

can = True
c = 1
#  c  is the number of connected component.
done = 0
#  done  is the number of slimes which have treated.

for m in T:
    if m > c:
        can = False
        break
    for _ in range(m):
        done += 1
        c += N-1 - math.ceil( math.log(done, 2) )
        #print(m,done,c)
        
if can:
    print("Yes")
else:
    print("No")

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()
import heapq
s.sort(reverse=True)
i=0
x=[s.pop(0)]
a="Yes"
while i<n:
 y=[]
 for j in range(1<<i):
   z=s.pop(0)
   if z>=x[j]:
      a="No"
   y.append(z)
 i+=1
 x+=y
 x.sort(reverse=True)
print(a)

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()
import heapq
ss=[-u for u in s]
heapq.heapify(ss)
i=0
x=[heapq.heappop(ss)]
a="Yes"
while i<n:
 y=[]
 for j in range(1<<i):
   z=heapq.heappop(ss)
   if z<=x[j]:
      a="No"
   y.append(z)
 i+=1
 x+=y
print(a)

Submission status: Wrong Answer

Solution code:
n = int(input())
P = list([int(x) for x in input().split()])
P_sort = sorted(P, reverse=True)
ans = 'Yes'

for i in range(n):
    if min(P_sort[0:2**i]) == max(P_sort[2**i:(2**i)*2]):
        if P_sort[0:2**i].count(min(P_sort[0:2**i])) > 2**i - P_sort[2**i:(2**i)*2].count(min(P_sort[0:2**i])):
            ans = 'No'
            break
    elif sum(P_sort[0:2**i]) - 2**i < sum(P_sort[2**i:(2**i)*2]):
        ans = 'No'
        break
    else:
        continue

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import deque

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

S.sort()

def solve() :
    T = deque([(S.pop(), N)])
    
    while S :
        tv, tn = T.popleft()
        for i in range(tn-1, -1, -1) :
            if S[-1] == tv :
                return 'No'
            T.append((S.pop(), i))
            # print(T)
    
    return 'Yes'
    
print(solve())

Submission status: Wrong Answer

Solution code:
N = int(input())
S = [int(i) for i in input().split()]

S.sort()

def solve() :
    T = [(S.pop(), N)]
    
    while S :
        tv, tn = T.pop()
        for i in range(tn-1, -1, -1) :
            if S[-1] == tv :
                return 'No'
            T.append((S.pop(), i))
            # print(T)
    
    return 'Yes'
    
print(solve())

Submission status: Wrong Answer

Solution code:
import numpy as np

def f(array):
  return np.array(list(array) + list(array - 1))

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

p = np.max(S)
a = np.array([p])

for i in range(N):
  a = f(a)

r = 'Yes'
for i in range(N):
  if np.count_nonzero(a >= p-i) < np.count_nonzero(S >= p-i):
    r = 'No'
    break

print(r)

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

class Bit:
    def __init__(self,n):
        self.size=n
        self.m=len(bin(self.size))-2
        self.arr=[0]*(2**self.m+1)
        
    def __str__(self):
        return str(self.arr)
        
    def add(self,i,x):
        k=0
        while i<=self.size:
            k+=1
            self.arr[i]+=x
            i+=i&(-i)
        return
    
    def sum(self,i):
        rt=0
        while i>0:
            rt+=self.arr[i]
            i-=i&(-i)
        return rt
    
    def l_bound(self,w):
        if w<=0:
            return 0
        x=0
        k=2**self.m
        while k>0:
            if x+k<self.size and self.arr[x+k]<w:
                w-=self.arr[x+k]
                x+=k
            k//=2
        return x+1

        
class Bit0(Bit):
    def add(self,j,x):
        super().add(j+1,x)
    def l_bound(self,w):
        return max(super().l_bound(w)-1,0)

n=I()
m=2**n
C=sorted(Counter(LI()).items(),key=lambda x:x[0])
a=[]
for i,(j,k) in enumerate(C):
    a+=[i+1]*k
pr=Bit0(m+1)
yet=Bit0(m+1)
show(a,C)

p=a.pop()
pr.add(p,1)

for i in a:
    yet.add(i,1)
    
for i in range(n):
    for j in range(2**i-1,-1,-1):
        psz=pr.l_bound(j+1)
        tg=yet.sum(psz)
        csz=yet.l_bound(tg)
        show('i,j=',i,j,', size p,c=',psz,csz,', num pr,yet=',pr.sum(m),yet.sum(m))
        if csz==0:
            print('No')
            exit()
        yet.add(csz,-1)
        pr.add(csz,1)
        
print('Yes')

Submission status: Wrong Answer

Solution code:
import numpy as np

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

p = np.max(S)

r = 'Yes'
for i in range(N):
  c = np.count_nonzero(S >= p-i)
  if c > 2 ** i:
    r = 'No'
    break

print(r)

Submission status: Wrong Answer

Solution code:
n = int(input())
P = list([int(x) for x in input().split()])
P_sort = sorted(P, reverse=True)
ans = 'Yes'

for i in range(n):
    if min(P_sort[0:2**i]) == max(P_sort[2**i:(2**i)*2]):
        if P_sort[0:2**i].count(min(P_sort[0:2**i])) > 2**i - P_sort[2**i:(2**i)*2].count(min(P_sort[0:2**i])):
            ans = 'No'
            break
    if sum(P_sort[0:2**i]) - 2**i >= sum(P_sort[2**i:(2**i)*2]):
        continue
    else:
        ans = 'No'
        break

print(ans)

Submission status: Wrong Answer

Solution code:
import heapq
from collections import deque

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


h = []
for s in S:
    heapq.heappush(h, -s)

# 力、生まれた時刻
rest = []
rest = deque([(-heapq.heappop(h), 0)])

while len(rest) > 0:
    curr, t0 = rest.popleft()
    # print("CURR: {}, t={}".format(curr, t0))
    for i in range(t0+1, N+1):
        p = -heapq.heappop(h)
        if curr <= p:
            print("No")
            exit(0)
        else:
            rest.append((p, i))
            # print("   -> {}, t={}".format(p, i))
print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())
P = list([int(x) for x in input().split()])
P_sort = sorted(P, reverse=True)
ans = 'Yes'

for i in range(n):
    if sum(P_sort[0:2**i]) - 2**i >= sum(P_sort[2**i:(2**i)*2]):
        continue
    else:
        ans = 'No'
        break

print(ans)

Submission status: Wrong Answer

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

    s = sorted(s)[::-1]

    slimes = [s[0]]
    s = s[1:]
    for i in range(n):
        tmp_slimes = []
        for j in range(2 ** i):
            if slimes[j] > s[j]:
                tmp_slimes.append(s[j])
            else:
                print("No")
                return
        slimes += tmp_slimes
        s = s[2 ** i:]
        slimes = sorted(slimes)[::-1]
        s = sorted(s)[::-1]
    print("Yes")


main()

Submission status: Wrong Answer

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

    s = sorted(s)[::-1]

    slimes = [s[0]]
    s = s[1:]
    for i in range(n):
        tmp_slimes = []
        for j in range(2 ** i):
            if slimes[j] > s[j]:
                tmp_slimes.append(s[j])
            else:
                print("No")
                return
        slimes += tmp_slimes
        s = s[2 ** i:]
    print("Yes")


main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

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

S.sort(reverse=True)

used = [S[0]]
unused = S[1:]
num_of_generation = 1
while len(used) < 2 ** N:
    # print("::used:", used)
    # print("::unused:", unused)

    for i in range(num_of_generation):
        if unused[i] >= used[i]:
            print("No")
            sys.exit(0)
        else:
            used.append(unused[i])

    used.sort(reverse=True)
    unused = unused[num_of_generation:]
    num_of_generation *= 2

print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())
s = [int(i) for i in input().split()]
s.sort(reverse=True)
#print(s)
ss = set(s)
lenS = len(ss)
#print(lenS)
#print(ss)
s_hplist = [ss.pop() for i in range(lenS)]
s_hplist.sort(reverse=True)
#print(s_hplist)
s_hp = [0] * lenS
temp1 = temp2 = count = 0
for i in s_hplist[1:]:
	temp1 = s.index(i)
	s_hp[count] = temp1 - temp2
	temp2 = temp1
	count += 1
	#print(temp1,count)
s_hp[-1] = 2**n - temp1
#print(s_hp)

flag = 0
if (s_hp[0] != 1):
	flag = -2

hp = [0] * (lenS)
hp[0] = 1
extra = 0
tempList = [0] * lenS
for t in range(1,n+1):
	for i in range(lenS):
		tempList[i] = hp[i]
	for i in range(1, lenS):#reversedを使わないでforを作ればうまくいく。追加でListを加えたらいい。
		if (hp[i] + tempList[i-1] + extra > s_hp[i]):
			extra = hp[i] + tempList[i-1] + extra - s_hp[i]
			hp[i] = s_hp[i]
		else:
			hp[i] += tempList[i-1] + extra
			extra = 0
	if (extra != 0):
		flag = -1
	#print(extra)
	#print(hp)
#print(s_hp)

if (flag != 0):
	print("No")	
else:
	print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())
s = [int(i) for i in input().split()]
s.sort(reverse=True)
#print(s)
ss = set(s)
lenS = len(ss)
#print(lenS)
#print(ss)
s_hplist = [ss.pop() for i in range(lenS)]
s_hplist.sort(reverse=True)
#print(s_hplist)
s_hp = [0] * lenS
temp1 = temp2 = count = 0
for i in s_hplist[1:]:
	temp1 = s.index(i)
	s_hp[count] = temp1 - temp2
	temp2 = temp1
	count += 1
	#print(temp1,count)
s_hp[-1] = 2**n - temp1
#print(s_hp)

#count = s_hp[0]
#cycle = 0
#for i in s_hp[1:]:
	#temp1 = i
	#for j in 
	#if (count * n < tempi):
		#flag = -2
		#break
	#count += temp1

#if (count * n < tempi): あくまでs_hp[1]で成り立つ式

#ここから下はいらないかも
hp = [0] * (lenS+1)
hp[0] = 1
flag = 0
extra = 0
for t in range(1,n+1):
	for i in reversed(range(1, lenS)):	
		if (hp[i] + hp[i-1] + extra > s_hp[i]):
			extra = hp[i] + hp[i-1] + extra - s_hp[i]
			hp[i] = s_hp[i]
		else:
			hp[i] += hp[i-1] + extra
			extra = 0
	if (extra != 0):
		flag = -1


#count = 0
#for i in range(0, n):
	#if (hp[i] > count):
		#flag = -1
		#break
	#count += hp[i]
	#if (s[count] > s[0] - (i+1)):
		#flag = -1
		#break
	#print(i, s[count], s[0]-(i+1), count)
	#print(count)
#print(hp)
#if (flag == 0):
	#for i in :

if (flag == 0):
	print("Yes")	
else:
	print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
s = [int(i) for i in input().split()]
s.sort(reverse=True)
#print(s)
hp = [0] * (n+1)
hp[0] = 1
flag = 0
for t in range(1,n+1):
	for i in reversed(range(1, t+1)):
		hp[i] += hp[i-1]
count = 0
for i in range(0, n):
	count += hp[i]
	if (s[count] > s[0] - (i+1)):
		flag = -1
		break
	#print(i, s[count], s[0]-(i+1), count)
	#print(count)
#print(hp)
if (flag == -1):
	print("No")	
else:
	print("Yes")

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

S.sort(reverse=True)

def solve() :
    if S[0] == S[1] :
        return 'No'
    
    now = 1
    for i in range(N-1, 0, -1) :
        for j in range(2 ** (i - 1)) :
            if S[now+j] == S[now+2**i+j] :
                return 'No'
        now += 2 ** i
    
    return 'Yes'
    
print(solve())

Submission status: Wrong Answer

Solution code:
n = int(input())
s = [int(i) for i in input().split()]
s.sort(reverse=True)
#print(s)
hp = [0] * (n+1)
hp[0] = 1
flag = 0

for t in range(1,n+1):
	for i in reversed(range(1, t+1)):
		hp[i] += hp[i-1]
count = 1
for i in range(1, n+1):
	#print(s[count], s[0]-i)
	if (s[count] > s[0] - i):
		flag = -1
		break
	count += hp[i]

if (flag == -1):
	print("No")	
else:
	print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())
s = [int(i) for i in input().split()]
s.sort(reverse=True)
print(s)
hp = [0] * (n+1)
hp[0] = 1
flag = 0

for t in range(1,n+1):
	for i in reversed(range(1, t+1)):
		hp[i] += hp[i-1]
count = 1
for i in range(1, n+1):
	#print(s[count], s[0]-i)
	if (s[count] > s[0] - i):
		flag = -1
		break
	count += hp[i]

if (flag == -1):
	print("No")	
else:
	print("Yes")

Submission status: Wrong Answer

Solution code:
N = int(input())
S = [int(i) for i in input().split()]

S.sort(reverse=True)

def solve() :
    for i in range(N) :
        for j in range(2**i) :
            if S[j] == S[2**i+j] :
                return 'No'
    
    return 'Yes'
    
print(solve())

Submission status: Wrong Answer

Solution code:
N = int(input())
S = [int(i) for i in input().split()]

S.sort(reverse=True)

def solve() :
    for i in range(1, N + 1) :
        for j in range(i) :
            if S[j] == S[i+j] :
                return 'No'
    
    return 'Yes'
    
print(solve())

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(map(int, input().split()))
s.sort()
 
parents = [s[-1]]
chirdren = s[:-1]
 
flag = True
 
for _ in range(n):
  for p in parents[::-1]:
    c = chirdren.pop()
    if p > c:
      parents.append(c)
    else:
      flag = False
      break

Submission status: Wrong Answer

Solution code:
import math

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

s.sort()
a, b = [], []

if math.log(n, 2).is_integer():
    for i in range(n//2):
        a.append(s.pop(0))
        b.append(s.pop(0))
else:
    print('No')
    exit()

for i in range(n//2-1):
    if a[i] < a[i+1]:
        continue
    else:
        if b[i] < b[i+1]:
            continue
        else:
            print('No')
            exit()

print('Yes')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n = int(input())
a = list(map(int, input().split()))
a.sort()
parent = [a[-1]]
rest = a[:-1]

for _ in range(n):
    next_parent = []
    next_rest = []
    for i in parent:
        while(rest):
            x = rest.pop()
            if x < i:
                next_parent.append(x)
                break
            else:
                next_rest.append(x)
                continue
    next_parent.reverse()
    parent = next_parent + parent
    next_rest.reverse()
    rest += next_rest

if len(parent) == 2**n:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n = int(input())
a = list(map(int, input().split()))
a.sort()
parent = [a[-1]]
rest = a[:-1]

for _ in range(n):
    next_parent = []
    next_rest = []
    for i in parent:
        while(rest):
            x = rest.pop()
            if x < i:
                next_parent.append(x)
                break
            else:
                next_rest.append(x)
                continue
    parent = next_parent + parent
    next_rest.reverse()
    rest += next_rest

if len(parent) == 2**n:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n = int(input())
a = list(map(int, input().split()))
a.sort()
parent = [a[-1]]
rest = a[:-1]

for _ in range(n):
    next_parent = []
    next_rest = []
    print(parent)
    for i in parent:
        while(rest):
            x = rest.pop()
            if x < i:
                next_parent.append(x)
                break
            else:
                next_rest.append(x)
                continue
    parent = next_parent + parent
    next_rest.reverse()
    rest += next_rest

if len(parent) == 2**n:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

S.sort(reverse=True)
slimes = []
# 全てはこの１匹から始まる
slimes.append(S.pop(0))

for i in range(N):
    for j in range(2 ** i):
        if slimes[j - 1] <= S[0]:
            print('No')
            quit()
        else:
            slimes.append(S.pop(0))
print('Yes')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n=int(input())
p=list(map(int,input().split()))
p.sort(reverse=True)
a=[p[0]]
now=1
for i in range(n):
    b=p[now:now+2**i]
    b.sort()
    for j in range(len(b)):
        if b[j]<a[j]:pass
        else:
            print('No')
            exit()
    a+=b
    a.sort()
print('Yes')

Submission status: Wrong Answer

Solution code:
n=int(input())
p=list(map(int,input().split()))
s=0
for i in  range(0,n-1):
  for j in range(i+2,n+1):
    x=sorted(p[i:j],reverse=True)
    s=s+x[1]
print(s)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N=int(input())
S=list(map(int,input().split()))
list=Counter(S)
tuples=sorted(list.items(),reverse=True)
i=0
j=1
buf=0
for k,v in tuples:
    if i==0 and tuples[0][1]!=1:
        print("No")
        j=-1
        break
    elif i==1 and tuples[1][1]>N:
        print("No")
        j=-1
        break
    elif i>1 and v>(N+1-j)*(N-j)/2 + buf :
        print("No")
        j=-1
        break

    if i==1:
        buf += N - tuples[1][1]
    if i>1:
        if v>(N+1-j)*(N-j)/2:
            buf -= v-(N+1-j)*(N-j)/2
        else:
            buf+=(N+1-j)*(N-j)/2-v
    if i>1:
        j+=1
    i+=1
if j!=-1:
    print("Yes")

Submission status: Wrong Answer

Solution code:
from collections import Counter
N=int(input())
S=list(map(int,input().split()))
list=Counter(S)
tuples=sorted(list.items(),reverse=True)
i=0
j=1
buf=0
for k,v in tuples:
    if i==0 and tuples[0][1]!=1:
        print("No")
        j=-1
        break
    elif i==1 and tuples[1][1]>N:
        print("No")
        j=-1
        break
    elif i>1 and v>(N+1-j)*(N-j)/2 + buf :
        print("No")
        j=-1
        break

    if i==1:
        buf += N - tuples[1][1]
    if i>1:
        if v>(N+1-j)*(N-j)/2:
            buf -= v
        else:
            buf+=(N+1-j)*(N-j)/2-v
    if i>1:
        j+=1
    i+=1
if j!=-1:
    print("Yes")

Submission status: Wrong Answer

Solution code:
from collections import Counter
N=int(input())
S=list(map(int,input().split()))
list=Counter(S)
tuples=sorted(list.items(),reverse=True)
i=0
j=1
for k,v in tuples:
    if i==0 and tuples[0][1]!=1:
        print("No")
        j=-1
        break
    elif i==1 and tuples[1][1]>N:
        print("No")
        j=-1
        break
    elif i>1 and list[i]>(N+1-j)*(N-j)/2:
        print("No")
        j=-1
        break

    if i!=0 and i!=1:
        j+=1
    i+=1
if j!=-1:
    print("Yes")

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
SList = S.split(" ")
initial = []
temp = []
for i in SList:
    initial.append(int(i))
desired = [max(initial)]
initial.remove(max(initial))
x = 1
output = "Yes"

for i in range(N):
    x = x * 2

if x == len(SList):
    for i in range(N):
        for j in desired:
            if max(initial) < j:
                temp.append(max(initial))
                initial.remove(max(initial))
            else:
                output = "No"
        for i in temp:
            desired.append(i)
        temp = []
        print(desired)
else:
    output = "No"
print(output)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
SList = S.split(" ")
initial = []
temp = []
for i in SList:
    initial.append(int(i))
desired = [max(initial)]
initial.remove(max(initial))
x = 1
output = "Yes"

for i in range(N):
    x = x * 2

if x == len(SList):
    for i in range(N):
        for j in desired:
            if max(initial) < j:
                temp.append(max(initial))
                initial.remove(max(initial))
            else:
                output = "No"
        for i in temp:
            desired.append(i)
        temp = []
print(output)

Submission status: Wrong Answer

Solution code:
def f_f():
    n = int(input())
    *s, = map(int, input().split())
    s.sort()
    p1, p2 = [s[-1]], []
    s[-1] = -1
    o = "Yes"
    for _ in range(n):
        j = len(s)
        while j>-1 and p1:
            j -= 1
            if s[j]<0:
                pass
            elif p1[-1]>s[j]:
                p2 += [s[j], p1.pop()]
                s[j] = -1
                j = len(s)
        print(s)        
        if p1:
            o="No"
            break
        p1, p2 = sorted(p2), []
    print(o)

if __name__ == "__main__":
    f_f()

Submission status: Wrong Answer

Solution code:
def f_f():
    n = int(input())
    *s, = map(int, input().split())
    s.sort()
    p1, p2 = [s[-1]], []
    s[-1] = -1
    o = "Yes"
    for i in range(n):
        j = len(s)-1
        while j>-1 and p1:
            if p1[-1]>s[j]:
                p2.append(p1.pop())
                j = len(s)-1
            else:
                pass
            j -= 1
        if p1:
            o="No"
            break
        p1, p2 = p2, []
    print(o)

if __name__ == "__main__":
    f_f()

Submission status: Wrong Answer

Solution code:
from sys import exit, stderr, stdin
input = stdin.readline
from collections import defaultdict
from sys import stderr
def debug(var, name="hoge"):
    print(name +":" + str(type(var)) + " = " + repr(var), file=stderr)
    return
def main():
    N = int(input())
    S = [int(a) for a in input().split()]
    S = sorted(S)
    exist = [S.pop()]
    for i in range(N):
        next_exist = []
        next_s = []
        for p in exist[::-1]:
            while S:
                x = S.pop()
                if x < p:
                    next_exist.append(x)
                    break
                else:
                    next_s.append(x)
        exist += next_exist
        exist.sort()
        S += next_s[::-1]

    if len(exist) == N**2:
        print("Yes")
        exit()
    else:
        print("No")
        exit()

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def f_f():
    n, *s = map(int, open(0).read().split())
    s.sort()
    p1, p2 = [s.pop()], []
    o = "Yes"
    for i in range(n):
        p1.sort()
        while p1:
            if p1[-1]>s[-1]:
                p2.append(s.pop())
            else:
                pass
            p2.append(p1.pop())
        p1, p2 = p2, []
        if len(p1)!=2**(i+1):
            o="No"
            break
    print(o)

if __name__ == "__main__":
    f_f()

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.pop(0)))
while True:
  if flg == 1:
    print('No')
    break
  if n >= N:
    print('Yes')
    break
  itr = 2 ** n
  for i in range(itr):
    for j in range(len(S)):
      if slime[i] > int(S[j]):
        flg = 0
        break
        
      flg = 1
      if i == 0:
        break

    slime.append(int(S.pop(j)))  
  n = n + 1

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.pop(0)))
while True:
  if flg == 1:
    print('No')
    break
  if n >= N:
    print('Yes')
    break
  itr = 2 ** n
  for i in range(itr):
    for j in range(len(S)):
      if slime[i] > int(S[j]):
        flg = 0
        break
      flg = 1

    slime.append(int(S.pop(j)))  
  n = n + 1