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/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
s = LI()

h = []
for i in range(2**n):
    heappush(h,-s[i])
x = heappop(h)
use = [-x]
for i in range(n):
    rest = []
    for j in range(2**i):
        x = heappop(h)
        rest.append(-x)
    for j in range(2**i):
        if use[j] > rest[j]:
            continue
        else:
            print('No')
            quit()
    for j in range(2**i):
        use.append(rest[j])
print('Yes')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
s = LI()
s.sort(reverse=True)
C = list(Counter(s).items())
cnt = list(Counter(s).values())
cnt = [0] + list(accumulate(cnt))
m = len(cnt)
for i,j in enumerate(cnt[:-1]):
    if 2**j >= C[i][1]:
        continue
    print('No')
    quit()
print('Yes')

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())

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

dic = {}
lis = []

rem = 1
pl = 0
loop = N
flag = True

for i in range(2 ** N):

    if S[i] not in dic:
        dic[S[i]] = 1
        lis.append(S[i])

    else:
        dic[S[i]] += 1

lis.sort()
lis.reverse()

for i in lis:

    pl = 0
    for j in range(dic[i]):
        rem -= 1
        pl += loop
        loop -= 1

    if rem < 0:
        print ("No")
        sys.exit()

    rem += pl

print ("Yes")

Submission status: Wrong Answer

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

dp = [[0 for _ in range(2 ** n)] for _ in range(19)]
dp[0] = [] + s

#for x in dp: print(x)

m = (n-1) ** 2
for a in range(n):
    #print(dp[a])
    for i in range(1 << (n-a-1)):
        #print(a, i)
        if dp[a][i*2] == dp[a][i*2+1]:
            print('No')
            exit()
        else:
            dp[a+1][i] = max(dp[a][i*2], dp[a][i*2+1])
    #m //= 2
    #print(dp[a+1])

print('Yes')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

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

#B
def B():
    n = II()
    a = LI()
    b = LI()
    c = LI()
    ans = 0
    for i in range(n):
        ans += b[a[i] - 1] + (c[a[i] - 1] if i != n - 1 and a[i] + 1 == a[i + 1] else 0)
    print(ans)
    return

#C
def C():
    n = II()
    b = LI()
    ans = b[0]
    for i in range(n-2):
        if b[i] >= b[i + 1]:
            ans += b[i + 1]
        else:
            ans += b[i]
    print(ans+b[-1])
    return

#D
def D():
    n, k = LI()
    s = S()
    a = []
    for i in range(n):
        if i == n - 1:
            a.append(s[i])
        elif s[i] != s[i + 1]:
            a.append(s[i])
    print(min(n - 1, n - len(a) + 2 * k))
    return

# E
# 解説AC
# Piが何個使えるかというとこまでは良くて
# そのPiよりも大きい数字が左に2個右に2個必要というところまではいけた
# 問題の本質を解決できてはいない
# ここから解説
# 大きい順からみて見たものに対してインデックスを保持
# ここからbisectを使えばlogNでi付近のすでに追加したインデックスを持ってこれる
# あと少しだけどその少しが遠い
# ↑
# これは嘘
# BITを使え
class BinaryIndexedTree:
    # http://hos.ac/slides/20140319_bit.pdf
    def __init__(self, size):
        """
        :param int size:
        """
        self.bit = [0 for _ in range(size)]
        self.size = size

    def add(self, i, w):
        """
        i番目にwを加える
        :param int i:
        :param int w:
        :return:
        """
        x = i
        while x < self.size:
            self.bit[x] += w
            x += x & -x
        return

    def sum(self, i):
        """
        [0,i]の合計
        :param int i:
        :return:
        """
        res = 0
        x = i
        while x > 0:
            res += self.bit[x]
            x -= x & -x
        return res

    def search(self, x):
        """
        二分探索。和がx以上となる最小のインデックス(>= 1)を返す
        :param int x:
        :return :
        """
        ok = self.size
        ng = 0
        while abs(ok - ng) != 1:
            mid = (ok + ng)//2
            if self.sum(mid) >= x:
                ok = mid
            else:
                ng = mid
        return ok

    def __len__(self):
        return self.size

def E():
    n = II()
    a = LI()
    dic = defaultdict(int)
    for i, ai in enumerate(a):
        dic[ai] = i+1
    bit = BinaryIndexedTree(n+1)
    num = [i + 1 for i in range(n)][::-1]
    ans = 0
    for i in num:
        c = dic[i]
        L = bit.sum(c)
        bit.add(c,1)
        R = n-i-L 
        a = bit.search(L-1) if L >= 2 else 0
        b = bit.search(L) if L >= 1 else 0
        d = bit.search(L+2) if R >= 1 else n+1
        e = bit.search(L+3) if R >= 2 else n+1
        tmp = 0
        if b != 0:
            tmp += (b-a) * (d-c)
        if d != 0:
            tmp += (e-d) * (c-b)
        ans += i * tmp

    print(ans)
    return

#F
def F():
    n = II()
    s = LI()
    s.sort(reverse=True)
    s = deque(s)
    r = deque([s.popleft()])
    l = deque()
    for i in range(n):
        for _ in range(1 << i):
            x = r.popleft()
            y = s.popleft()
            if x > y:
                r.append(x)
                l.append(y)
            else:
                print("No")
                return
        while l:
            r.append(l.popleft())
    print("Yes")
    return

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

Submission status: Wrong Answer

Solution code:
from collections import Counter


def main():
    N = int(input())
    S = list(map(int, input().split()))
    C = Counter(S)
    X = sorted([(x, C[x]) for x in C], reverse=True)
    capacity = 1
    ncapacity = 0
    M = N
    for _, c in X:
        if c > capacity:
            tmp = capacity
            capacity = ncapacity
            ncapacity = tmp * M
            M -= 1
            c -= tmp
            if c > capacity:
                print("No")
                return
        capacity -= c
        ncapacity += c * M
        if c == 0:
            capacity = ncapacity
            ncapacity = 0
            M -= 1
    print("Yes")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from collections import Counter


def main():
    N = int(input())
    S = list(map(int, input().split()))
    C = Counter(S)
    X = sorted([(x, C[x]) for x in C], reverse=True)
    if X[0][1] != 1:
        print("No")
        return
    capacity = 1
    ncapacity = 0
    M = N
    for _, c in X:
        if c > capacity:
            c -= capacity
            tmp = capacity
            capacity = ncapacity
            M -= 1
            ncapacity = tmp * M
            if c > capacity:
                print("No")
                return
        capacity -= c
        ncapacity += c * M
        if c == 0:
            capacity = ncapacity
            ncapacity = 0
            M -= 1
    print("Yes")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from collections import Counter


def main():
    N = int(input())
    S = list(map(int, input().split()))
    C = Counter(S)
    X = sorted([(x, C[x]) for x in C], reverse=True)
    if X[0][1] != 1:
        print("No")
        return
    capacity = N
    ncapacity = 0
    M = N - 1
    for _, c in X[1:]:
        if c > capacity:
            c -= capacity
            capacity = ncapacity
            ncapacity = 0
            M -= 1
            if c > capacity:
                print("No")
                return
        capacity -= c
        ncapacity += c * M
        if c == 0:
            capacity = ncapacity
            ncapacity = 0
            M -= 1
    print("Yes")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

D = {}
L = 0
for n in nums:
    if n not in D:
        D[n] = L
        L += 1


for i, x in enumerate(sorted(D, reverse=True)):
    D[x] = i

arr = [0 for i in range(L)]
for n in nums:
    arr[D[n]] += 1

cumsum = [0 for i in range(L+1)]
for i in range(L):
    cumsum[i] = arr[i] + cumsum[i - 1]

# Deal with first
if arr[0] != 1:
    print("No")
    quit()

willSpawn = 1
cur = 1

onLeft = 1
temp = 0
while cur < L:
    if onLeft < min(willSpawn, arr[cur]):
        print("No")
        quit()
    else:
        for i in range(willSpawn):
            arr[cur] -= 1
            temp += 1
            while (cur < L) and arr[cur] == 0:
                onLeft += temp
                temp = 0
                cur += 1
    willSpawn *= 2

print("Yes")

Submission status: Wrong Answer

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

D = {}
L = 0
for n in nums:
    if n not in D:
        D[n] = L
        L += 1


for i, x in enumerate(sorted(D, reverse=True)):
    D[x] = i

arr = [0 for i in range(L)]
for n in nums:
    arr[D[n]] += 1

cumsum = [0 for i in range(L+1)]
for i in range(L):
    cumsum[i] = arr[i] + cumsum[i - 1]

# Deal with first
if arr[0] != 1:
    print("No")
    quit()

willSpawn = 1
cur = 1

while cur < L:
    if cumsum[cur - 1] < min(willSpawn, arr[cur]):
        print("No")
        quit()
    else:
        for i in range(willSpawn):
            arr[cur] -= 1
            while (cur < L) and arr[cur] == 0:
                cur += 1
    willSpawn *= 2

print("Yes")

Submission status: Wrong Answer

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

D = {}
L = 0
for n in nums:
    if n not in D:
        D[n] = L
        L += 1


for i, x in enumerate(sorted(D, reverse=True)):
    D[x] = i

arr = [0 for i in range(L)]
for n in nums:
    arr[D[n]] += 1

cumsum = [0 for i in range(L+1)]
for i in range(L):
    cumsum[i] = arr[i] + cumsum[i - 1]
cumsum[-1] = 1

# Deal with first
if arr[0] != 1:
    print("No")
    quit()

willSpawn = 1
cur = 1

while cur < L:
    if cumsum[cur - 1] < min(willSpawn, arr[cur]):
        print("No")
        quit()
    else:
        for i in range(willSpawn):
            arr[cur] -= 1
            if arr[cur] == 0:
                cur += 1
    willSpawn *= 2
print("Yes")

Submission status: Wrong Answer

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

D = {}
L = 0
for n in nums:
    if n not in D:
        D[n] = L
        L += 1


for i, x in enumerate(sorted(D, reverse=True)):
    D[x] = i

arr = [0 for i in range(L)]
for n in nums:
    arr[D[n]] += 1

cumsum = [0 for i in range(L+1)]
for i in range(L):
    cumsum[i] = arr[i] + cumsum[i - 1]
cumsum[-1] = 1

canSpawn = 1
cur = 0
while cur < L:
    if cumsum[cur - 1] < min(canSpawn, arr[cur]):
        print("No")
        quit()
    else:
        for i in range(canSpawn):
            arr[cur] -= 1
            if arr[cur] == 0:
                cur += 1
print("Yes")

Submission status: Wrong Answer

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

D = {}
L = 0
for n in nums:
    if n not in D:
        D[n] = L
        L += 1


for i, x in enumerate(sorted(D, reverse=True)):
    D[x] = i

arr = [0 for i in range(L)]
for n in nums:
    arr[D[n]] += 1

cumsum = [0 for i in range(L+1)]
for i in range(L):
    cumsum[i] = arr[i] + cumsum[i - 1]
cumsum[-1] = 1

canSpawn = 1
cur = 0
while cur < L:
    if cumsum[cur - 1] < arr[cur]:
        print("No")
        quit()
    else:
        for i in range(canSpawn):
            arr[cur] -= 1
            if arr[cur] == 0:
                cur += 1
print("Yes")

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
L = sorted(LI(), reverse=True)
for i in range(n):
    for j in range(1, 2 ** i + 1):
        if L[2 * j - 1] >= L[j - 1]:
            print('No')
            exit(0)
print('Yes')
exit(0)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
L = sorted(LI(), reverse=True)
for i in range(n):
    for j in range(1, 2 ** i + 1):
        if L[2 * j - 1] >= L[j - 1]:
            print('No')
            exit(0)
print('Yes')

Submission status: Wrong Answer

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

S.sort()

parents = [S[-1]]
S[-1] = INF

for _ in range(N):
    checking = 2
    for i in parents[:]:
        while True:
            if S[-checking] < i:
                parents.append(S[-checking])
                S[-checking] = INF
                break
            else:
                checking += 1
            if checking == 2 ** N + 1:
                print('No')
                exit()
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
import numpy as np

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

S.sort()

for _ in range(N):
    n = len(S) // 2
    tmp = S[n:] - S[:n]
    if any(tmp <= 0):
        print('No')
        exit()
    else:
        S = S[n:]
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(map(int, input().split(' ')))
res = 'Yes'
s.sort(reverse=True)
c = s.copy()[1:]
id = 0
for i in range(n , 0 , -1):
    top = s[id]
    id += 1
    for j in range(i):
        p = c.pop(0)
        if top <= p:
            res = 'No'
            i = 0
            break
if c != []:
    res = 'No'
print(res)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(map(int, input().split(' ')))
res = 'Yes'
s.sort(reverse=True)
c = s.copy()[1:]
id = 0
for i in range(n , 0 , -1):
    top = s[id]
    id += 1
    for j in range(i):
        p = c.pop(0)
        if top <= p:
            res = 'No'
            i = 0
            break

print(res)

Submission status: Wrong Answer

Solution code:
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

import heapq
class Reverse:
    def __init__(self, val):
        self.val = val
        
    def __lt__(self, other):
        return self.val > other.val
        
    def __repr__(self):
        return repr(self.val)
    
class Heapq:
    def __init__(self, arr, desc = False):
        if desc:
            for i in range(len(arr)):
                arr[i] = Reverse(arr[i])
        self.desc = desc
        self.hq = arr
        heapq.heapify(self.hq)
 
    def pop(self):
        if self.desc: return heapq.heappop(self.hq).val
        else: return heapq.heappop(self.hq)
 
    def push(self, a):
        if self.desc: heapq.heappush(self.hq, Reverse(a))
        else: heapq.heappush(self.hq, a)
 
    def top(self):
        if self.desc: return self.hq[0].val
        else: return self.hq[0]

N = I()
S = III()

S.sort()
A = Heapq([[S.pop(),N]], True)
while S:
    temp = S.pop()
    a = A.pop()
    if a[0]<=temp:
        print('No')
        exit()
    else:
        if a[1]>=2:
            A.push([a[0],a[1]-1])
            A.push([temp,a[1]-1])
    
print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

from heapq import heapify, heappop, heappush, heappushpop,\
                  _heapify_max, _siftdown_max, _siftup_max

def _heappush_max(heap, item):
    heap.append(item)
    _siftdown_max(heap, 0, len(heap)-1)

def _heappop_max(heap):
    lastelt = heap.pop()
    if heap:
        returnitem = heap[0]
        heap[0] = lastelt
        _siftup_max(heap, 0)
        return returnitem
    return lastelt

N = I()
S = III()

S.sort()
A = [[S.pop(),N]]
_heapify_max(A)
while S:
    temp = S.pop()
    a = _heappop_max(A)
    if a[0]<=temp:
        print('No')
        exit()
    else:
        if a[1]>=2:
            _heappush_max(A,[a[0],a[1]-1])
            _heappush_max(A,[temp,a[1]-1])
    
print('Yes')

Submission status: Wrong Answer

Solution code:
N = int(input())
B = sorted(map(int, input().split()))
setB = list(set(B))
countB = [B.count(i) for i in setB] 
ans = "Yes"
for i in range(len(setB)):
  N -= 1
  if countB[i] > len(B) - countB[i]:
    ans = "No"
  if N < 0:
    ans = "No"
  
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(map(int, input().split(" ")))
s.sort(reverse=True)
suraimu = []
suraimu.append(s.pop(0))
for i in range(n):
    suraimuLen = len(suraimu)
    for j in range(suraimuLen):
        if (s == []):
            break
        if (suraimu[j] > s[0]):
            suraimu.append(s.pop(0))

if s == []:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    input = sys.stdin.readline

    n = int(input())
    a = list(map(int,input().split()))
    a.sort()

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

    for _ in [0]*n:
        next_par = []
        next_rest = []

        for e in par:
            while True:
                if len(rest) == 0:
                    print('No')
                    exit()
                k = rest.pop()
                if k < e:
                    next_par.append(k)
                    break
                else:
                    next_rest.append(k)
        
        par += next_par
        par.sort(reverse = True)
        rest += next_rest[:-1]
    
    print('Yes')

if __name__ =='__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    input = sys.stdin.readline

    n = int(input())
    a = list(map(int,input().split()))
    a.sort()

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

    for _ in [0]*n:
        next_par = []
        next_rest = []

        for e in par:
            while True:
                if len(rest) == 0:
                    print('No')
                    exit()
                k = rest.pop()
                if k < e:
                    next_par.append(k)
                    break
                else:
                    next_rest.append(k)
        
        par += next_par
        par.sort(reverse = True)
        rest += next_rest
    
    print('Yes')

if __name__ =='__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse = True)

judge = True

chi = [0]*pow(2,n)
chi[0] = n
new = [0]
tank = []
ind = 1

while len(new) > 0:
    tank = []

    for e in new:
        while chi[e] > 0:
            if a[e] <= a[ind]:
                judge = False
            tank.append(ind)
            chi[ind] = chi[e]-1
            chi[e] -= 1
            ind += 1

    new = tank

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

Submission status: Wrong Answer

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

s.sort(reverse = True)
#print(s)
P = [0 for _ in range(2**n)]
C = [0 for _ in range(2**n)]
for i in range(n,0,-1):
    cnt = 0
    j = 2**i-1
    while cnt < 2**(i-1):
        try:
            c = s[j]
            C[j] = 1
            k = j - 1
            while s[k]<=c or P[k] == 1:
                k-=1
            P[k] = 1
            #print(s[j],s[k])
            cnt += 1
            j -= 1
            while P[j] == 1:
                j -= 1
            #print(s[j],s[k])
        except:
            print("No")
            sys.exit()
    s2 = []
    #print(P)
    #print(C)
    for l in range(2**i):
        if C[l] ==0:
            s2.append(s[l])
    #print("s2",s2)
    s = s2
    C = [0 for _ in range(2**(i-1))]
    P = [0 for _ in range(2**(i-1))]

print("Yes")

Submission status: Wrong Answer

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

s.sort(reverse = True)
#print(s)
P = [0 for _ in range(2**n)]
C = [0 for _ in range(2**n)]
for i in range(n,0,-1):
    cnt = 0
    j = 2**i-1
    while cnt < 2**(i-1):
        try:
            c = s[j]
            C[j] = 1
            k = j - 1
            while s[k]<=c or P[k] == 1:
                k-=1
            P[k] = 1
            #print(s[j],s[k])
            cnt += 1
            j -= 1
            while P[j] == 1:
                j -= 1
            #print(s[j],s[k])
        except:
            print("NO")
            sys.exit()
    s2 = []
    #print(P)
    #print(C)
    for l in range(2**i):
        if C[l] ==0:
            s2.append(s[l])
    #print("s2",s2)
    s = s2
    C = [0 for _ in range(2**(i-1))]
    P = [0 for _ in range(2**(i-1))]

print("YES")

Submission status: Wrong Answer

Solution code:
print("Yes")

Submission status: Wrong Answer

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

S.sort(reverse=True)
S = deque(S)
S.append(0)
#print(S)
ans = deque([S.popleft()])

tmp = deque([])

for i in range(n):
  for j in ans:
    #parent = j
    for k in S:
      #child = k
      if k == 0 or k == j:
        print('No')
        sys.exit()
      elif k < j:
        S.remove(k)
        tmp.append(k)
        break
  for j in tmp:
    ans.append(j)
  tmp = []
print('Yes')

Submission status: Wrong Answer

Solution code:
import sys

def bsearch(target, min_i, max_i, func):
    # func(index) < target <= func(index+1) となるindexを返す
    if func(max_i) < target:
        return max_i
    if target <= func(min_i):
        return None
    index = (max_i + min_i)//2
    while True:
        if func(index) < target:
            if target <= func(index+1):
                return index
            index, min_i = (index+1 + max_i)//2, index+1
            continue
        index, max_i = (index-1 + min_i)//2, index-1

def bb(bs, cs):
    for bi in range(len(bs)):
        ci = bsearch(bs[bi], 0, len(cs)-1, lambda x : cs[x])
        if ci == None:
            sys.exit()
        bs.append(cs[ci])
        del cs[ci]
    return bs, cs

def b(bs, cs):
    #print(bs, xs[len(bs):])
    d = set()
    bl, cl = len(bs), len(cs)
    bi, ci = 0, 0
    while True:
      if bs[bi] > cs[ci]:
        bi += 1
        bs.append(cs[ci])
        del cs[ci]
      else:
        ci += 1
      if bi == bl or ci == len(cs):
        break
    if len(bs) != 2 * bl:
      print("No")
      sys.exit()
    return bs, cs

n=int(input())
xs = sorted(list(map(int,input().split())))
bs = [xs.pop()]
cs = xs
for _ in range(n):
    print(bs, cs)
    x = bb(bs, cs)
    if x:
        bs, cs = x
print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
def b(bs, cs):
    #print(bs, xs[len(bs):])
    d = set()
    bl, cl = len(bs), len(cs)
    bi, ci = 0, 0
    while True:
      if bs[bi] > cs[ci]:
        bi += 1
        bs.append(cs[ci])
        del cs[ci]
      else:
        ci += 1
      if bi == bl or ci == len(cs):
        break
    if len(bs) != 2 * bl:
      print("No")
      sys.exit()
    return bs, cs

n=int(input())
xs = sorted(list(map(int,input().split())))[::-1]
bs, cs = xs[:1], xs[1:]
for _ in range(n):
    bs, cs = b(sorted(bs)[::-1], cs[::-1])

print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
def b(bs, cs):
    #print(bs, xs[len(bs):])
    d = set()
    bl, cl = len(bs), len(cs)
    bi, ci = 0, 0
    while True:
      if bs[bi] > cs[ci]:
        bi += 1
        bs.append(cs[ci])
        del cs[ci]
      else:
        ci += 1
      if bi == bl or ci == len(cs):
        break
    if len(bs) != 2 * bl:
      print("No")
      sys.exit()
    return bs, cs

n=int(input())
xs = sorted(list(map(int,input().split())))[::-1]
bs, cs = xs[:1], xs[1:]
for _ in range(n):
    bs, cs = b(bs, cs)

print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
def b(bs, cs):
    #print(bs, xs[len(bs):])
    d = set()
    nbs = []
    for b in bs:
      for i, c in enumerate(cs):
        if b > c:
            nbs.append(c)
            d.add(i)
            break
      else:
        print("No")
        sys.exit()
    return bs+nbs, d
n=int(input())
xs = sorted(list(map(int,input().split())))[::-1]
bs, cs = xs[:1], xs[1:]
for _ in range(n):
    #print(bs, cs)
    bs, d = b(bs, cs)
    ncs = []
    for i, c in enumerate(cs):
    	if i not in d:
          ncs.append(c)
    cs = ncs
print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
def b(bs):
    #print(bs, xs[len(bs):])
    for b, c in zip(bs,xs[len(bs):len(bs)*2]):
        if b > c:
            bs.append(c)
        else:
            print("No")
            sys.exit()
    return bs
n=int(input())
xs = sorted(list(map(int,input().split())))[::-1]
bs = [xs[0]]
for _ in range(n):
    bs = b(bs)
print("Yes")

Submission status: Wrong Answer

Solution code:
N = int(input())
Sn = list(map(int, input().split()))
isFail = False
for i in range(N):
    tSn = []
    for sc in range(0, int(len(Sn)/2)):
        x1 = 2 * sc
        x2 = 2 * sc + 1
        if(Sn[x1] == Sn[x2]):
            isFail = True
            break
        else:
            if(Sn[x1] > Sn[x2]):
                tSn.append(Sn[x1])
            else:
                tSn.append(Sn[x2])
    if(isFail):
        break
    Sn = tSn.copy()
if(isFail):
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import sys

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()
a = na()
a.sort(reverse=True)

done = [False] * (1 << n)
b = [a[0]]
done[0] = True
for d in range(n):  # d: d-th trial is passed.
    j = 0  # j: skip num (already-generated or impossible-to-generate)
    for i in range(1 << d):  # Try split of i-th slim.
        while j < 1 << n and (done[j] or b[i] <= a[j]):
            j += 1
        if j == 1 << n:
            print("No")
            sys.exit(0)
        b.append(a[j])  # b[i] > a[j]
        done[j] = True
#    b.sort(reverse=True)
print("Yes")