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:
from sys import stdin

N = int(stdin.readline())
S = list((int(wd) for wd in stdin.readline().split()))

slime = {}
for s in S:
    if s in slime:
        slime[s] += 1
    else:
        slime[s] = 1
        pass
    pass

key = list(slime.keys())
key.sort()
key.reverse()

#for k in key: print(slime[k])
parent = 0
for k in key:
    n = slime[k]
    if parent == 0:
        if n != 1:
            print('No')
            exit(0)
            pass
        pass
    else:
        n_max = (N*2-parent+1) * parent / 2
        if n_max + 1 < parent + n:
            #print('check:', slime[k])
            print('No')
            exit(0)
            pass
        pass
    parent += n
    pass

print('Yes')

Submission status: Wrong Answer

Solution code:
N = int(input())
S = sorted(list(map(int, input().split())), reverse = True)
L = [S[0] > S[2**i] and S[2**i-1] > S[2**(i+1)-1] for i in range(N)]
print ("Yes" if all(L) else "No")

Submission status: Wrong Answer

Solution code:
import bisect

n = int(input())
s = list(map(int, input().split(" ")))
# n = 18
# s = list(reversed(range(1, 2 ** n + 1)))

s = sorted(s)
from collections import deque

def solve():
    global s

    parents = [s[-1]]
    s.pop()

    for i in range(n):
        newparents = list(parents)
        k = -1
        dropped = set()
        # print(parents)
        for p in parents:
            oldK = k
            k = k + bisect.bisect(s[k + 1:], p - 1)
            # print("Old", oldK, k, s[k])
            if k - oldK + 1 == -1:
                print("No")
                exit(0)

            newparents.append(s[k])
            dropped.add(k)
        s = [x for i, x in enumerate(s) if i not in dropped]

        parents = sorted(newparents, reverse=True)

    # print(parents)
    # print(k)
    if k == len(s):
        print("Yes")
    else:
        print("No")
solve()

Submission status: Wrong Answer

Solution code:
import bisect

n = int(input())
s = list(map(int, input().split(" ")))
# n = 18
# s = list(reversed(range(1, 2 ** n + 1)))

s = sorted(s)
from collections import deque

def solve():
    global s

    parents = [s[-1]]
    s.pop()

    for i in range(n):
        newparents = list(parents)
        k = 0
        dropped = set()
        for p in parents:
            oldK = k
            k = k + bisect.bisect(s[k:], p - 1) - 1
            if k - oldK == -1:
                print("No")
                exit(0)

            newparents.append(s[k])
            dropped.add(k)
        s = [x for i, x in enumerate(s) if i not in dropped]

        parents = sorted(newparents, reverse=True)

    # print(parents)
    # print(k)
    if k == len(s):
        print("Yes")
    else:
        print("No")
solve()

Submission status: Wrong Answer

Solution code:
import bisect

n = int(input())
s = list(map(int, input().split(" ")))
# n = 18
# s = list(reversed(range(1, 2 ** n + 1)))

s = sorted(s)
from collections import deque

def solve():
    global s

    parents = [s[-1]]
    s.pop()

    for i in range(n):
        newparents = list(parents)
        k = 0
        dropped = set()
        for p in parents:
            k = k + bisect.bisect(s[k:], p - 1) - 1
            if k == -1 or p <= s[k]:
                print("No")
                exit(0)

            newparents.append(s[k])
            dropped.add(k)
        s = [x for i, x in enumerate(s) if i not in dropped]

        parents = sorted(newparents, reverse=True)

    # print(parents)
    # print(k)
    if k == len(s):
        print("Yes")
    else:
        print("No")
solve()

Submission status: Wrong Answer

Solution code:
import bisect

n = int(input())
s = list(map(int, input().split(" ")))
# n = 18
# s = list(reversed(range(1, 2 ** n + 1)))

s = sorted(s)
from collections import deque

def solve():
    global s

    parents = [s[-1]]
    s.pop()

    for i in range(n):
        newparents = list(parents)
        k = 0
        dropped = set()
        # print(parents)
        for p in parents:
            k = k + bisect.bisect(s[k:], p - 1) - 1
            if k == -1:
                print("No")
                exit(0)

            newparents.append(s[k])
            dropped.add(k)
        s = [x for i, x in enumerate(s) if i not in dropped]

        parents = sorted(newparents, reverse=True)

    # print(parents)
    # print(k)
    if k == len(s):
        print("Yes")
    else:
        print("No")
solve()

Submission status: Wrong Answer

Solution code:
import bisect

n = int(input())
s = list(map(int, input().split(" ")))
# n = 18
# s = list(reversed(range(1, 2 ** n + 1)))

s = sorted(s)
from collections import deque

def solve():
    parents = [s[-1]]
    s.pop()

    for i in range(n):
        newparents = list(parents)

        k = 0
        for p in reversed(parents):
            k = k + bisect.bisect(s[k:], p - 1) - 1
            if k == -1:
                print("No")
                exit(0)

            newparents.append(s[k])
            s.pop(k)

        parents = sorted(newparents)

    # print(parents)
    # print(k)
    if k == len(s):
        print("Yes")
    else:
        print("No")
solve()

Submission status: Wrong Answer

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

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

def solve():
    parents = [s[0]]
    k = 1

    while k < len(s):
        newparents = list(parents)
        for p in parents:
            if p > s[k]:
                newparents.append(s[k])
                k += 1
            else:
                print("No")
                exit(0)
        parents = sorted(newparents, reverse=True)
    print("Yes")
solve()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    s = sorted(list(map(int, input().strip().split())), reverse=True)
    check = [False] * (2**N)
    now = []
    now.append([s[0], 1])
    check[0] = True
    ok = True
    for i in range(N):
        next_ = []
        tmp = 0
        for j in range(len(now)):
            hp, start = now[j]
            start = max(start, tmp)
            ok = False
            for k in range(start, 2**N):
                if s[k] < hp and not check[k]:
                    tmp = k+1
                    now[j][1] = k+1
                    check[k] = True
                    next_.append([s[k], k+1])
                    ok = True
                    break
            if not ok:
                break
        now += next_
        if not ok:
            break
    
    if ok:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

# N = int('1')
# S = list(map(int, '1 1'.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] <= S[0]:
            print('No')
            quit()
        else:
            slimes.append(S.pop(0))
print('Yes')

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(map(int,input().split()))
if 2 ** N == len(S):
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    s = sorted(list(map(int, input().strip().split())), reverse=True)
    time = [0] * (2**N)

    ok = True

    time[0] = N
    next_ = 1
    for i in range(2**N):
        if time[i] == 0:
            break
        for j in range(time[i]-1):
            if s[i] <= s[next_]:
                print("No")
                ok = False
                break
            else:
                # print(s[i], ">", s[next_])
                time[next_] = time[i] - 1 - j
                next_ += 1
        if not ok:
            break
    
    if s[next_-1] <= s[next_]:
        print("No")
        ok = False

    if ok:
        print("Yes")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

a = [s[-1]]
s[-1] = -1;

for i in range(n):
    ai = a
    ai.sort()

    for j in range(len(s)-1, -1, -1):
        if s[j] != -1:
            p = s[j]
            break
    ni = 1 << i
    for k in range(ni-1, -1, -1):
        if ai[k] > s[j]:
            a.append(s[j])
            s[j] = -1
            j -= 1
        else:
            print('No')
            exit(0)

print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    s = sorted(list(map(int, input().strip().split())), reverse=True)
    time = [0] * (2**N)

    ok = True

    time[0] = N
    next_ = 1
    for i in range(2**N):
        for j in range(time[i]):
            if s[i] <= s[next_]:
                print("No")
                ok = False
                break
            else:
                # print(s[i], ">", s[next_])
                time[next_] = time[i] - 1 - j
                next_ += 1
        if not ok:
            break
    
    if ok:
        print("Yes")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    s = sorted(list(map(int, input().split())), reverse=True)
    time = [0] * (2**N)

    ok = True

    time[0] = N
    next_ = 1
    for i in range(2**N):
        for j in range(time[i]):
            if s[i] <= s[next_]:
                print("No")
                ok = False
                break
            else:
                time[next_] = time[i] - 1 - j
                next_ += 1
        if not ok:
            break
    
    if ok:
        print("Yes")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

n = onem()

p = l()

p.sort(reverse = True)

ms = p[0]
s = [p[0]]

for i in range(n):
    count = 0
    local = 0
    s.sort(reverse = True)
    while count < 2**i:
        if local >= 2**n:
            print("No")
            exit()
        if s[i] > p[local]:
            s.append(p[local])
            p[local] = ms
            count += 1
        local += 1
print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    s = sorted(list(map(int, input().split())), reverse=True)
    time = [0] * (2**N)

    ok = True

    time[0] = N
    next_ = 1
    for i in range(2**N):
        for j in range(time[i]):
            if s[i] <= s[next_]:
                ok = False
                break
            else:
                time[next_] = time[i] - 1 - j
                next_ += 1
        if not ok:
            break
    
    if ok:
        print("Yes")
    else:
        print("No")




if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
input = sys.stdin.readline

class Node:
    def __init__(self, num, parent=None):
        self.num = num
        self.parent = parent
        self.hp = 0

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

    root = Node(N)
    q = deque()
    count = 0
    ok = True
    q.append(root)
    while len(q) > 0:
        node = q.popleft()
        # 一番大きいhpの割り当て
        node.hp = a[count]
        count += 1
        # hpが親より小さいか確認
        if node.parent != None:
            if node.parent.hp <= node.hp:# 親のhpの方が小さかったら無理
                # print(node.parent.hp, "<=", node.hp)
                ok = False
                break
            else:
                # print(node.parent.hp, ">", node.hp)
                pass
        # 自身のnumだけ子ノードを生成
        for i in range(node.num):
            child = Node(node.num-1-i, parent=node)
            q.append(child)
    
    if ok:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

a = S.pop()
if a <= 2 ** (N-1):
  print ("No")
else:
  i = 1
  f = False
  while S:
    if f: break
    c = 2 ** (i-1)
    m = 2 ** (N-i)
    while c:
      if len(S) == 0: break
      b = S.pop()
      if b < m:
        f = True
        break
      c -= 1
      if c == 0:
        i += 1
  print ("No" if f else "Yes")

Submission status: Wrong Answer

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

S.sort(reverse=True)
ans = [S[0]]
for i in range(n):
  for j in range(2**(i)):
    ans.append(ans[j]-1)
  #print(ans,i)
ans.sort(reverse=True)
#print('ans:',ans,'S:',S)
for i in range(len(S)):
  if S[i] > ans[i]:
    print('No')
    sys.exit()
    
print('Yes')

Submission status: Wrong Answer

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

S.sort(reverse=True)
ans = [S[0]]
for i in range(n):
  for j in range(2**(i)):
    ans.append(ans[j]-1)
  #print(ans,i)
ans.sort(reverse=True)
print('ans:',ans,'S:',S)
for i in range(len(S)):
  if S[i] > ans[i]:
    print('No')
    sys.exit()
    
print('Yes')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 'Yes'
for i in range(2 ** n, 1, -1):
    if s[i - 1] < s[(i - 1) // 2]:
        continue
    else:
        ans = 'No'
        break

print(ans)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

ans = 'Yes'
while n > 0:
    i = n // 2
    if s[i] > s[i + 1]:
        n = i
        continue
    else:
        ans = 'No'
        break
print(ans)

Submission status: Wrong Answer

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

ans = 'Yes'
while n > 0:
    i = n // 2
    if s[i] == s[i + 1]:
        ans = 'No'
        break
    n = i
print(ans)

Submission status: Wrong Answer

Solution code:
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
S = list(map(int, sys.stdin.readline().split()))
S.sort(reverse=True)


def argsort(li, key=None, reverse=False):
    return [i for _, i in sorted([(a, i) for i, a in enumerate(li)], key=lambda t: key(t[0]), reverse=reverse)]


nodes = [(N, -1)]
for i in range(2 ** N):
    children, parent = nodes[i]
    for c in reversed(range(children)):
        nodes.append((c, i))

parents = [p for c, p in nodes]
# 子供の多い順、root に近い順
idx = argsort(nodes, key=lambda v: (-v[0], v[1]))
slimes = [- 1] * 2 ** N
slimes[0] = S[0]
ok = True
for s, i in zip(S[1:], idx[1:]):
    ok &= s < slimes[parents[i]]
    slimes[i] = s
if ok:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N=int(input())
S=list(map(int, input().split()))
S.sort(reverse=True)
S=[-1]+S
res="Yes"
if S[1]<=S[2]:
  res="No"
else:
  for i in range(1, N):
    S1=S[2**(i-1)+1:2**i+1]
    S2=S[2**(i-1)+1+2**i:2**i+1+2**i]
    for j in range(len(S1)):
      if S1[j]==S2[j]:
        res="No"
        break
    if res=="No":
      break
print(res)

Submission status: Wrong Answer

Solution code:
def solve_f(n, s_list):
    res = 'Yes'
    stage = 0
    s_list_s = sorted(s_list)
    length = len(s_list_s)
    resolved = [0] * length
    resolved[-1] = 1
    
    for i in range(n - 1):
        parents = [s_list_s[k] for k in range(length) if resolved[k]]
        for j in range(length - 1, -1, -1):
            if parents[-1] > s_list_s[j] and resolved[j] == 0:
                resolved[j] = 1
                _ = parents.pop()
            if len(parents) == 0:
                break
        if len(parents) > 0:
            res = "No"
            break
            
    return res


def main():
    n = int(input())
    s_list = list(map(int, input().split()))
    print(solve_f(n, s_list))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

judge = True
t = 0
while(t<n):
    size = 2**t
    for i in range(size):
        if a[i] > a[i+size]:
            continue
        judge = False
    t += 1
if judge:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

S.sort()
def compress(s):
    n = (len(s)-1).bit_length()
    j = 0
    comp = [0] * (2 ** n)
    comp[j] += 1
    for i in range(1,2**n):
        if s[i] > s[i-1]:
            j += 1
        comp[j] += 1
    return comp, j

comp, m = compress(S)

valid = True
for i in range(N):
    k = 0
    l = 1
    if l >= len(comp) or comp[l] == 0:
        valid = False
        break
    news = []
    for j in range(2**(N-i-1)):
        comp[k] -= 1
        comp[l] -= 1
        news.append(l)
        if not comp[l]:
            if not comp[k]:
                k = l + 1
                l += 2
            else:
                l += 1
        else:
            if not comp[k]:
                k = l
                l += 1
            else:
                pass
        if l > m:
            break
    if j < 2**(N-i-1) - 1:
        break
    comp, m = compress(news)
if i < N - 1:
    valid = False

print('Yes' if valid else 'No')

Submission status: Wrong Answer

Solution code:
import sys

def main():
    N,*S = map(int, open(0).read().split())
    S.sort()

    g = [S.pop(-1)]

    for gen in range(N):
        g.sort(reverse=True)
        tmp = []
        for p in g[:2**gen]:
            while S:
                s = S.pop(-1)
                if p > s:
                    g.append(s)
                    break
                else:
                    tmp.append(s)
            S = S + tmp
    print('Yes' if len(g) == 2**N else 'No')

if __name__=='__main__':
    main()

Submission status: Wrong Answer

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

S.sort()
def compress(s):
    n = (len(s)-1).bit_length()
    j = 0
    comp = [0] * (2 ** n)
    comp[j] += 1
    for i in range(1,2**n):
        if s[i] > s[i-1]:
            j += 1
        comp[j] += 1
    return comp, j

comp, m = compress(S)

valid = True
for i in range(N):
    k = 0
    l = 1
    if l >= len(comp) or comp[l] == 0:
        valid = False
        break
    news = []
    for j in range(2**(N-i-1)):
        comp[k] -= 1
        comp[l] -= 1
        news.append(l)
        if not comp[l]:
            if not comp[k]:
                k = l + 1
                l += 2
            else:
                l += 1
        else:
            if not comp[k]:
                l += 1
                k += 1
            else:
                pass
        if l > m:
            break
    if j < 2**(N-i-1) - 1:
        break
    comp, m = compress(news)
if i < N - 1:
    valid = False

print('Yes' if valid else 'No')

Submission status: Wrong Answer

Solution code:
import sys
import collections

def main():
    N,*S = map(int, open(0).read().split())
    S.sort()

    g = [S.pop(-1)]

    for gen in range(N):
        g.sort(reverse=True)
        tmp = []
        for p in g[:2**gen]:
            while S:
                s = S.pop(-1)
                if p > s:
                    g.append(s)
                    break
                tmp.append(s)
            else:
                print('No')
                sys.exit()
            S = S + tmp
    print('Yes')

if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
N=int(input())
S=list(map(int, input().split()))
S.sort(reverse=True)
S=[-1]+S
res="Yes"
if S[1]<=S[2]:
  res="No"
else:
  for i in range(1, N):
    S1=sorted(S[2**(i-1)+1:2**i+1])
    S2=sorted(S[2**i+1:2**i+1+len(S1)])
    for j in range(2**(i-1)):
      if S1[j]<=S2[j]:
        res="No"
        break
    if res=="No":
      break
print(res)

Submission status: Wrong Answer

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

if len(S) > pow(2, N):
    print("No")
    exit()

dict = defaultdict(int)
for s in S:
    dict[s] += 1

dict = sorted(dict.items(), reverse=True)

check_num = 1
check_flag = False
for i, d in enumerate(dict):
    n = d[1]
    if n > check_num:
        print("No")
        exit()
    if i >= 1:
        check_num *= 2

print("Yes")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if len(S) > pow(2, N):
    print("No")
    exit()

dict = defaultdict(int)
for s in S:
    dict[s] += 1

dict = sorted(dict.items(), reverse=True)

check_num = 1
for d in dict:
    n = d[1]
    if n > check_num:
        print("No")
        exit()
    check_num *= 2

print("Yes")

Submission status: Wrong Answer

Solution code:
N=int(input())
S=list(map(int, input().split()))
S.sort(reverse=True)
S=[-1]+S
res=""
if S[1]<=S[2]:
  res="No"
else:
  flag=True
  for i in range(1, N):
    flag=True
    for j in range(2**(i-1)+1, 2**i+1):
      if S[j]<=S[j+2**i]:
        flag=False
        res="No"
        break
    if not flag:
      break
  if flag:
    res="Yes"
print(res)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=list(map(int, input().split()))
S.sort(reverse=True)
S=[-1]+S
res=""
if S[1]<=S[2]:
  res="No"
else:
  flag=True
  for i in range(1, N):
    flag=True
    for j in range(2**(i-1)+1, 2**i+1):
      if S[i]<=S[i+2**i]:
        flag=False
        res="No"
        break
    if not flag:
      break
  if flag:
    res="Yes"
print(res)

Submission status: Wrong Answer

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

S =list( map(lambda x: math.ceil(math.log2(int(x))) + 1, input().split()))
D = Counter(S)
for i in range(1, N+1):
  c = 2 ** (N-i)
  n = i
  while n > 0:
    if D[n] > 0:
      if D[n] <= c:
        del D[n]
        c -= D[n]
      else:
        D[n] -= c
        break
    n -= 1

if len(D) != 1:
  print ("No")
elif D.most_common()[0][1] != 1:
  print ("No")
else:
  D = list(D)
  print ("Yes" if D[0] >= N+1 else "No")

Submission status: Wrong Answer

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

S =list( map(lambda x: math.ceil(math.log2(int(x))) + 1, input().split()))
D = Counter(S)
for i in range(1, N+1):
  c = 2 ** (N-i)
  n = i
  while n > 0:
    if D[n] > 0:
      if D[n] <= c:
        del D[n]
        c -= D[n]
      else:
        D[n] -= c
        break
    n -= 1

if len(D) != 1:
  print ("No1")
elif D.most_common()[0][1] != 1:
  print ("No2")
else:
  D = list(D)
  print ("Yes" if D[0] >= N+1 else "No3")

Submission status: Wrong Answer

Solution code:
import sys
import collections

def main():
    N,*S = map(int, open(0).read().split())

    S = sorted(S)

    g = [S.pop(-1)]

    for _ in range(N):
        g = sorted(g,reverse=True)
        parents = g[:]
        for p in parents:
            for si, s in enumerate(S[::-1]):
                if p > s:
                    g.append(s)
                    del S[-si]
                    break;
            else:
                print('No')
                sys.exit()
    print('Yes')

if __name__=='__main__':
    main()

Submission status: Wrong Answer

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

S =list( map(lambda x: math.ceil(math.log2(int(x))) + 1, input().split()))
D = Counter(S)

for i in range(1, N+1):
  c = 2 ** (N-i)
  n = i
  while n > 0:
    if D[n] > 0:
      if D[n] <= c:
        del D[n]
        c -= D[n]
      else:
        D[n] -= c
        break
    n -= 1

D = list(D)
print ("Yes" if len(D) == 1 and D[0] >= N+1 else "No")

Submission status: Wrong Answer

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

S =list( map(lambda x: math.ceil(math.log2(int(x))) + 1, input().split()))
D = Counter(S)

for i in range(1, N+1):
  c = 2 ** (N-i)
  n = i
  while n > 0:
    if D[n] > 0:
      if D[n] <= c:
        del D[n]
        c -= D[n]
      else:
        D[n] -= c
        break
    n -= 1

D = list(D)
print ("Yes" if len(D) == 1 and D[0] == N+1 else "No")

Submission status: Wrong Answer

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

S =list( map(lambda x: math.ceil(math.log2(int(x))) + 1, input().split()))
D = Counter(S)

for i in range(1, N+1):
  c = 2 ** (N-i)
  n = i
  while n > 0:
    if D[n] > 0:
      if D[n] <= c:
        del D[n]
        c -= D[n]
      else:
        D[n] -= c
        break
    n -= 1

D = list(D)
print ("Yes" if len(D) == 0 or len(D) == 1 and D[0] == N+1 else "No")

Submission status: Wrong Answer

Solution code:
#F問題
N = int(input())
S = list(map(int,input().split()))
S.sort(reverse=True)
visit = [0]*(2**N)
visit[0] = 1
used = [S[0]]

flag = 0
for i in range(N):
    add = used[::-1]
    k = 0
    for u in used:
        while k < 2**N:
            if visit[k] == 0 and S[k] < u:
                visit[k] = 1
                add.append(S[k])
                break
            k+=1
        if k >= 2**N:
            print("No")
            flag = 1
            break
    if flag == 1:
        break
    
    used = add[::-1]
    add.sort(reverse=True)
    
if flag == 0:
    print("Yes")

Submission status: Wrong Answer

Solution code:
#F問題
N = int(input())
S = list(map(int,input().split()))
S.sort(reverse=True)
visit = [0]*(2**N)
visit[0] = 1
used = [S[0]]

flag = 0
for i in range(N):
    add = used[::-1]
    k = 0
    for u in used:
        while k < 2**N:
            if visit[k] == 0 and S[k] < u:
                visit[k] = 1
                add.append(S[k])
                break
            k+=1
        if k == 2**N:
            print("No")
            flag = 1
            break
    if flag == 1:
        break
    
    used = add[::-1]
    add.sort(reverse=True)
    
if flag == 0:
    print("Yes")

Submission status: Wrong Answer

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

D = Counter(S)

for i in range(N+1):
  j = i
  c = 2 ** (N-j)
  n = 2 ** j
  while n > 0:
    if D[n] > 0:
      if D[n] <= c:
        del D[n]
        c -= D[n]
      else:
        D[n] -= c
    n -= 1

print ("Yes" if len(D) == 0 else "No")

Submission status: Wrong Answer

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

# input = sys.stdin.readline


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

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

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

    if n > 1 and len(s) != 2**n:
        print('No')
        sys.exit()

    if s[0] > s[1]:

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

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

            x = x * 2

        print('Yes')

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import os
import sys

from operator import itemgetter

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
S = list(map(int, sys.stdin.readline().split()))
S.sort(reverse=True)

nodes = [(None, N)]
for i in range(2 ** N):
    parent, children = nodes[i]
    for c in reversed(range(children)):
        nodes.append((i, c))
parents = [p for p, c in nodes]

slimes = [S[0]]
ok = True
for i, p in enumerate(parents[1:], start=1):
    # print(i, p, S[i], S[p])
    ok &= S[i] < S[p]
if ok:
    print('Yes')
else:
    print('No')