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:
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

N=int(input())
S=list(map(int,input().split()))
S.sort()
sl=[S.pop()]
for _ in range(N):
    stack=[]
    for i in range(len(sl)):
        x=sl[i]
        while S:
            y=S.pop()
            if y<x:
                sl.append(y)
                break
            else:
                stack.append(y)
        else:
            print('No')
            exit()
    S.extend(stack[::-1])
    sl.sort()
print('Yes')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

N=int(input())
S=list(map(int,input().split()))
S.sort()
sl=[S.pop()]
for _ in range(N):
    stack=[]
    for i in range(len(sl)):
        x=sl[i]
        while S:
            y=S.pop()
            if y<x:
                sl.append(y)
                break
            else:
                stack.append(y)
        else:
            print('No')
            exit()
    S.extend(stack[::-1])
print('Yes')

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    S = list(map(int, input().split(' ')))
    # 体力大きい順に調べる
    S.sort(reverse=True)
    # スライム生成の完全二分木を構成できるか否かで判定
    tree = [0 for _ in range(2**(N + 1) - 1)]
    tree[0] = S[0]

    def update(s, node=0):
        # 最下層まで探索が進んだ場合
        if 2**N - 1 <= node:
            return False
        left, right = 2*node + 1, 2*node + 2
        # 子の値が定義済の場合
        if tree[left] != 0 and tree[right] != 0:
            if s < tree[right]:
                if update(s, right):
                    return True
                else:
                    return update(s, left)
            else:
                return update(s, left)            
        # 子の値が未定義の場合
        else:
            if s >= tree[node]:
                return False
            else:
                tree[left] = tree[node]
                tree[right] = s
                return True

    for s in S[1:]:
        if not update(s):
            print('No')
            return

    # 最後まで処理が進めばOK
    print('Yes')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys


sys.setrecursionlimit(10**6)


def main():
    N = int(input())
    S = list(map(int, input().split(' ')))
    # 体力大きい順に調べる
    S.sort(reverse=True)
    # スライム生成の完全二分木を構成できるか否かで判定
    tree = [0 for _ in range(2**(N + 1) - 1)]
    tree[0] = S[0]

    def update(s, node=0):
        # 最下層まで探索が進んだ場合
        if 2**N - 1 <= node:
            return False
        left, right = 2*node + 1, 2*node + 2
        # 子の値が定義済の場合
        if tree[left] != 0 and tree[right] != 0:
            if s < tree[right]:
                if update(s, right):
                    return True
                else:
                    return update(s, left)
            else:
                return update(s, left)            
        # 子の値が未定義の場合
        else:
            if s >= tree[node]:
                return False
            else:
                tree[left] = tree[node]
                tree[right] = s
                return True

    for s in S[1:]:
        if not update(s):
            print('No')
            return

    # 最後まで処理が進めばOK
    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)

can = 1
last = -1
cnt = 0
for s in S:
    if s == last:
        cnt += 1
        if can < cnt:
            print("No")
            exit()
    else:
        can += cnt
        cnt = 1
        last = s
print("Yes")

Submission status: Wrong Answer

Solution code:
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    s = [int(i) for i in ipt().split()]
    s.sort(reverse=True)
    hq = [1]
    num = [0]*(2**(n+1)+1)
    num[0] = 10**10
    for i in s:
#        print(hq)
        while hq:
            qi = hpq.heappop(hq)
            if num[qi//2] == i:
                if not hq:
                    print("No")
                    exit()
                continue
            ndi = qi*(2**(n-len(str(format(qi,"b")))+1))
            while ndi > qi:
                num[ndi] = i
                hpq.heappush(hq,(ndi//2)*2+1)
                ndi //= 2
            num[qi] = i
            break
    print("Yes")



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    s = [int(i) for i in ipt().split()]
    s.sort(reverse=True)
    hq = [1]
    num = [0]*(2**(n+1)+1)
    num[0] = 10**10
    for i in s:
#        print(hq)
        while hq:
            qi = hpq.heappop(hq)
            if num[qi>>1] == i:
                if not hq:
                    print("No")
                    exit()
                continue
            ndi = qi*2**(n-len(str(format(qi,"b")))+1)
            while ndi > qi:
                num[ndi] = i
                hpq.heappush(hq,(ndi//2)*2+1)
                ndi >>= 1
            num[qi] = i
            break
    print("Yes")



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    s = [int(i) for i in ipt().split()]+[10**10]
    s.sort(reverse=True)
    q = [1]
    n2 = 1
    for i in range(1,2**(n-1)+1):
        if s[i] == s[i+n2]:
            print("No")
            exit()
        if i==n2:
            n2*=2
    print("Yes")
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    s = [int(i) for i in ipt().split()]+[10**10]
    s.sort(reverse=True)
    for i in range(1,2**(n-1)+1):
        if s[i] == s[i*2]:
            print("No")
            exit()
    print("Yes")
    return None

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    s = [int(i) for i in ipt().split()]+[10**10]
#    n = 2**18
#    s = [int(i)+1 for i in range(n)]+[10**10]
    s.sort(reverse=True)
    for i,si in enumerate(s):
        if i == 0:
            continue
        if si == s[i>>1]:
            print("No")
            exit()
    print("Yes")

    return None

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

n = int(input())
S = sorted(map(int, input().split()), reverse=True)
for i in range(n):
  if len(set(S[2**i-1:2**(i+1)])) == 1:
    print("No")
    exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
A.sort()
first = A[-1]
A = A[:-1]
kouho = [first]
while A:
    nagasa = len(kouho)
    for _ in range(nagasa):
        A_mushi = []
        kouho_used = []
        kouho_nxt = []
        k = kouho.pop()
        while True:
            if A:
                v = A.pop()
                if k <= v:
                    A_mushi.append(v)
                else:
                    kouho_nxt.append(v)
                    break
            else:
                print("No")
                exit()
        kouho_used.append(k)

    kouho += kouho_used
    kouho += kouho_nxt
    kouho.sort()
    A += A_mushi[::-1]

print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
A.sort()
first = A[-1]
A = A[:-1]
kouho = [first]
while A:
    nagasa = len(kouho)
    for _ in range(nagasa):
        A_mushi = []
        kouho_mushi = []
        kouho_nxt = []
        while True:
            if A:
                v = A.pop()
                if kouho:
                    k = kouho.pop()
                else:
                    print("No")
                    exit()

                if k <= v:
                    A_mushi.append(v)
                else:
                    kouho_nxt.append(v)
                    break
            else:
                print("No")
                exit()
        kouho_mushi.append(k)

    kouho += kouho_mushi
    kouho += kouho_nxt
    kouho.sort()
    A += A_mushi[::-1]

print("Yes")

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
A.sort()
first = A[-1]
A = A[:-1]
kouho = [first]
while A:
    nagasa = len(kouho)
    for _ in range(nagasa):
        A_mushi = []
        kouho_mushi = []
        kouho_nxt = []
        while True:
            if A:
                v = A.pop()
                if kouho:
                    k = kouho.pop()
                else:
                    print("No")
                    exit()

                if k <= v:
                    A_mushi.append(v)
                    kouho_mushi.append(k)
                else:
                    kouho_nxt.append(v)
                    kouho_mushi.append(k)
                    break
            else:
                print("No")
                exit()

    kouho += kouho_mushi
    kouho += kouho_nxt
    kouho.sort()
    A += A_mushi[::-1]


print("Yes")

Submission status: Wrong Answer

Solution code:
from collections import deque

n = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
A = deque(A)
first = A.popleft()
kouho = []
kouho.append(first)
while A:
    nagasa = len(kouho)
    for i in range(nagasa):
        v = A.popleft()
        if kouho[i] <= v:
            print("No")
            exit()
        kouho.append(v)
    kouho.sort(reverse=True)

print("Yes")

Submission status: Wrong Answer

Solution code:
from collections import deque

n = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
A = deque(A)
first = A.popleft()
kouho = []
kouho.append(first)
while A:
    nagasa = len(kouho)
    for i in range(nagasa):
        v = A.popleft()
        if kouho[i] <= v:
            print("No")
            exit()
        kouho.append(v)
print("Yes")

Submission status: Wrong Answer

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

N = int(input())
S = list(map(int, input().split()))
S.sort(reverse=True)
i = 0
while i < 2**N:
    lb, ub = -1, i
    while ub - lb > 1:
        m = (lb + ub) // 2
        if S[m] > S[i]:
            lb = m
        else:
            ub = m
    a = ub
    lb, ub = i, 2**N
    while ub - lb > 1:
        m = (lb + ub) // 2
        if S[i] > S[m]:
            ub = m
        else:
            lb = m
    b = lb
    if a < b - i:
        print('No')
        exit(0)
    i = i * 2 + 1
print('Yes')

Submission status: Wrong Answer

Solution code:
from collections import Counter
def main():
    N = int(input())
    S = list(map(int, input().split()))
    S.sort(reverse=True)
    p = Counter([S[0]])
    t = 1
    small = S[0]
    for i in range(1, N+1):
        c = Counter(S[t:t+i])
        m = max(S[t:t+i])
        if small == m and c[m] > i - p[m]:
            return False
        small = min(S[t:t+i])
        p = p + c
        t += i
    return True
if main():
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
from collections import Counter

def solve():
    n = int(input())
    c = list(Counter(int(si) for si in input().split()).values())
    if c[-1] != 1:
        print('No')
        return
    c.pop()
    dp = [0] * (n + 1)
    dp[0] = 1
    for cnt in reversed(c):
        dp_next = [0] * (n + 1)
        for j in range(n):
            consume = dp[j] if dp[j] < cnt else cnt
            cnt -= consume
            dp_next[j] += dp[j] - consume
            dp_next[j + 1] += consume
            dp[j + 1] += consume
        if cnt != 0:
            print('No')
            return
        dp = dp_next
    print('Yes')
    return

if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
from collections import Counter

def solve():
    n = int(input())
    c = list(Counter(int(si) for si in input().split()).values())
    if c[-1] != 1:
        print('No')
        return
    c.pop()
    dp = [0] * (n + 1)
    dp[0] = 1
    for cnt in reversed(c):
        dp_next = [0] * (n + 1)
        for j in range(n):
            consume = dp[j] if dp[j] < cnt else cnt
            cnt -= consume
            dp_next[j] += dp[j] - consume
            dp_next[j + 1] += consume
            dp[j] += consume
        if cnt != 0:
            print('No')
            return
        dp = dp_next
    print('Yes')
    return

if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
from collections import Counter

def solve():
    n = int(input())
    c = list(Counter(int(si) for si in input().split()).values())
    if c[-1] != 1:
        print('No')
        return
    c.pop()
    dp = [0] * (n + 1)
    dp[0] = 1
    for cnt in reversed(c):
        for j in range(n):
            consume = dp[j] if dp[j] < cnt else cnt
            cnt -= consume
            dp[j] += dp[j] - consume
            dp[j + 1] += consume * 2
        if cnt != 0:
            print('No')
            return
    print('Yes')
    return

if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
from collections import Counter

def solve():
    n = int(input())
    c = list(Counter(int(si) for si in input().split()).values())
    if c[-1] != 1:
        print('No')
        return
    c.pop()
    dp = [0] * (n + 1)
    dp[0] = 1
    for cnt in reversed(c):
        dp_next = [0] * (n + 1)
        for j in range(n):
            consume = dp[j] if dp[j] < cnt else cnt
            cnt -= consume
            dp_next[j] += dp[j] - consume
            dp_next[j + 1] += consume * 2
        if cnt != 0:
            print('No')
            return
        dp = dp_next
    print('Yes')
    return

if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
from collections import Counter

def main():
  n = int(input())
  a = sorted(Counter(list(map(int, input().split()))).items())
  g = [0]*(n+1)
  g[n] = 1
  while a:
    _, x = a.pop()
    sg = sum(g)
    if sg < x:
      print('No')
      break
    while a and a[-1][1] + x <= sg:
      _, y = a.pop()
      x += y
    t = [0]*(n+1)
    for i in range(n, -1, -1):
      if g[i] <= x:
        t[i-1] = t[i] + g[i]
        x -= g[i]
        g[i] = 0
      else:
        t[i-1] = t[i] + x
        g[i] -= x
        x = 0
      t[i] += g[i]
    t[n] = 0
    g = t
  else:
    print('Yes')
  return

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n = ii()
s = li()
s.sort(reverse=True)

ima = [s[0]]
cou = 1
for i in range(n):
    for k in range(len(ima)):
        if ima[k] > s[cou]:
            ima.append(s[cou]) 
            cou += 1
        else:
            print("No")
            exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
from random import random


class TreapNode:
    """Treapのノード定義
    メンバ変数: 値、優先度、親へのポインタ、左右の子へのポインタ"""
    def __init__(self, val):
        self.val = val
        self.priority = random()
        self.parent, self.right, self.left = None, None, None


class Treap:
    """平衡二分探索木: 値の検索、挿入、削除などクエリ処理をO(logN)で実行する"""
    def __init__(self, is_multiset=False):
        self.is_multiset = is_multiset
        self.root = None

    def search(self, val: int) -> bool:
        """値の検索: 集合に値valを持つノードが存在するか"""
        ptr = self.root
        while ptr is not None:
            if val < ptr.val:
                ptr = ptr.left
            elif val > ptr.val:
                ptr = ptr.right
            else:
                return True
        return False

    def insert(self, val: int) -> bool:
        """値の削除: 集合に値valを持つノードを挿入する"""
        if self.root is None:
            self.root = TreapNode(val)
            return True

        # ノードの挿入
        ptr = self.root 
        while True:
            if val < ptr.val:
                if ptr.left is None:
                    ptr.left = TreapNode(val)
                    ptr.left.parent = ptr
                    ptr = ptr.left
                    break
                ptr = ptr.left
            else:
                if val == ptr.val and not self.is_multiset:
                    return False
                elif ptr.right is None:
                    ptr.right = TreapNode(val)
                    ptr.right.parent = ptr
                    ptr = ptr.right
                    break
                ptr = ptr.right

        # 木の回転によってヒープ性を保つ
        while (ptr.parent is not None) and (ptr.parent.priority > ptr.priority):
            if ptr.parent.right == ptr:
                self._rotate_left(ptr.parent)
            else:
                self._rotate_right(ptr.parent)
        if ptr.parent is None:
            self.root = ptr 
        return True

    def delete(self, val: int) -> True:
        """値の削除: 集合から値valを持つノードを削除する"""
        if self.root is None:
            return False

        ptr = self.root         
        while True: 
            if ptr is None:
                return False
            elif val < ptr.val:
                ptr = ptr.left
            elif val > ptr.val:
                ptr = ptr.right
            else:
                break

        # 木の回転によって削除したいノードを葉に持っていく
        while (ptr.left is not None) or (ptr.right is not None):
            if ptr.left is None:
                self._rotate_left(ptr)
            elif ptr.right is None:
                self._rotate_right(ptr)
            elif ptr.left.priority < ptr.right.priority:
                self._rotate_right(ptr)
            else:
                self._rotate_left(ptr)
            if self.root == ptr:
                self.root = ptr.parent

        # ノードの削除
        if ptr.left is None and ptr.right is None:
            if ptr == self.root:
                self.root = None
            elif ptr.parent.left == ptr:
                ptr.parent.left = None
            else:
                ptr.parent.right = None      
        return True

    def _rotate_left(self, ptr):
        """木の左回転を行う"""
        w = ptr.right
        w.parent = ptr.parent
        if w.parent is not None:
            if w.parent.left == ptr:
                w.parent.left = w
            else:
                w.parent.right = w
        ptr.right = w.left
        if ptr.right is not None:
            ptr.right.parent = ptr
        ptr.parent = w
        w.left = ptr
        if ptr == self.root:
            self.root = w
            self.root.parent = None

    def _rotate_right(self, ptr):
        """木の右回転を行う"""
        w = ptr.left
        w.parent = ptr.parent
        if w.parent is not None:
            if w.parent.right == ptr:
                w.parent.right = w
            else:
                w.parent.left = w
        ptr.left = w.right
        if ptr.left is not None:
            ptr.left.parent = ptr
        ptr.parent = w
        w.right = ptr
        if ptr == self.root:
            self.root = w
            self.root.parent = None

    def search_min(self):
        ptr = self.root
        ret = None
        while ptr is not None:
            ret = ptr.val
            ptr = ptr.left
        return ret

    def search_max(self):
        ptr = self.root
        ret = None
        while ptr is not None:
            ret = ptr.val
            ptr = ptr.right
        return ret

    def search_le(self, val: int):
        """val以下の最大の値を探す"""
        ptr = self.root
        ret = None
        while ptr is not None:
            if ptr.val <= val:
                ret = ptr.val
                ptr = ptr.right
            else:
                ptr = ptr.left
        return ret

    def search_lt(self, val: int):
        """valよりも小さいの最大の値を探す"""
        ptr = self.root
        ret = None
        while ptr is not None:
            if ptr.val < val:
                ret = ptr.val
                ptr = ptr.right
            else:
                ptr = ptr.left
        return ret

    def search_ge(self, val: int):
        """val以上の最小の値を探す"""
        ptr = self.root
        ret = None
        while ptr is not None:
            if ptr.val >= val:
                ret = ptr.val
                ptr = ptr.left
            else:
                ptr = ptr.right
        return ret
      
    def search_gt(self, val: int):
        """valよりも大きい最小の値を探す"""
        ptr = self.root
        ret = None
        while ptr is not None:
            if ptr.val > val:
                ret = ptr.val
                ptr = ptr.left
            else:
                ptr = ptr.right
        return ret
      
      
n = int(input())
s = list(map(int, input().split()))
s = sorted(s, reverse=True)

tp = Treap()
used = [False] * (1 << n)
tp.insert(s[0])
used[0] = True

cnt = 0
res = []
for step in range(n):
    cnt = 1 << step
    for i in range(1 << n):
        if used[i]:
            continue
        val = tp.search_gt(s[i])
        if val is not None:
            cnt -= 1
            res.append(val)
            res.append(s[i])
            tp.delete(val)
            used[i] = True
        if cnt == 0:
            for val in res:
                tp.insert(val)
            break
    else:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

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

a = sorted(a, reverse=True)
ans = [a[0]]
for _ in range(n):
    length = len(ans)
    for j in range(length):
        if a[j + length] < ans[j]:
              ans.append(a[j + length])
        else:
            print("No")
            exit()
print("Yes")

Submission status: Wrong Answer

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

slimes = [S[0]]
S[0] = float('inf')
num = 1
min_idx = 1
for i in range(N):
  slimes.sort()
  n = num
  idx = min_idx
  is_continuous = True
  while n and idx<=N2-1:
    if S[idx] < slimes[n-1]:
      slimes.append(S[idx])
      S[idx] = float('inf')
      idx += 1
      n -= 1
      if is_continuous:
        min_idx += 1
    else:
      if S[idx] < float('inf'):
        is_continuous = False
      else:
        min_idx += 1
      idx += 1
  
  if n:
    print('No')
    quit()
  
  num *= 2

print('Yes')

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(map(int, input().split()))
S.sort()
check = []
acc = 0

for i in range(N, 0, -1):
    if i==1:
        check.append((acc, acc+1))
    else:
        for j in range(2**(i-2)):
            check.append((acc+j, acc+j+2**(i-1)))
    
        acc += 2**(i-1)

flag = True

for i, j in check:
    flag &= S[i]<S[j]

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

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

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

d = defaultdict(int)
for e in s:
    d[e] += 1

for _ in range(n):
    keys = sorted(d.keys())

    l = 0
    r = 1

    d_nxt = defaultdict(int)
    ln = len(d)
    while r < ln:
        kl = keys[l]
        kr = keys[r]

        if d[kl] <= d[kr]:
            d_nxt[kr] += d[kl]
            d[kr] -= d[kl]
            d[kl] = 0

        else:
            d_nxt[kr] += d[kr]
            d[kl] -= d[kr]
            d[kr] = 0

        while l < ln and d[keys[l]] == 0:
            l += 1

        r = max(l + 1, r)
        while r < ln and d[keys[r]] == 0:
            r += 1

    if sum(d.values()) != 0:
        print("No")
        exit()

    d = d_nxt

print("Yes")

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

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

d = defaultdict(int)
for e in s:
    d[e] += 1

for _ in range(n):
    keys = sorted(d.keys())

    l = 0
    r = 1

    d_nxt = defaultdict(int)
    ln = len(d)
    while r < ln:
        kl = keys[l]
        kr = keys[r]

        if d[kl] <= d[kr]:
            d_nxt[kr] += d[kl]
            d[kr] -= d[kl]
            d[kl] = 0

        else:
            d_nxt[kr] += d[kr]
            d[kl] -= d[kr]
            d[kr] = 0

        while l < ln and d[keys[l]] == 0:
            l += 1

        r = l + 1
        while r < ln and d[keys[r]] == 0:
            r += 1

    if sum(d.values()) != 0:
        print("No")
        exit()

    d = d_nxt

print("Yes")

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

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

d = defaultdict(int)
for e in s:
    d[e] += 1

for _ in range(n):
    keys = sorted(d.keys())

    l = 0
    r = 1

    d_nxt = defaultdict(int)
    ln = len(d)
    while r < ln:
        kl = keys[l]
        kr = keys[r]

        if d[kl] <= d[kr]:
            d_nxt[kr] += d[kl]
            d[kr] -= d[kl]
            d[kl] = 0
            l += 1
            r += 1

        else:
            d_nxt[kr] += d[kr]
            d[kl] -= d[kr]
            d[kr] = 0
            r += 1

    if sum(d.values()) != 0:
        print("No")
        exit()

    d = d_nxt


print("Yes")

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

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

d = defaultdict(int)
for e in s:
    d[e] += 1

for _ in range(n):
    keys = sorted(d.keys())

    l = 0
    r = 1

    d_nxt = defaultdict(int)
    ln = len(d)
    while r < ln:
        kl = keys[l]
        kr = keys[r]

        if d[kl] < d[kr]:
            d_nxt[kr] += d[kl]
            d[kr] -= d[kl]
            d[kl] = 0
            l += 1
            r += 1

        else:
            d_nxt[kr] += d[kr]
            d[kl] -= d[kr]
            d[kr] = 0
            r += 1

    if sum(d.values()) != 0:
        print("No")
        exit()

    d = d_nxt

print("Yes")

Submission status: Wrong Answer

Solution code:
n,a,p,f=int(input()),sorted(list(map(int,input().split())))[::-1],1,0
while p<2**n:
 for j, k in zip(a[:p], a[p:2*p]):
  if j <= k:f = 1
 p*=2
print("YNeos"[f::2])

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    a.sort(reverse=True)
    b = [a[0]]
    for i in range(n):
        c = a[2**i:2**(i+1)]
        d = []
        for j in b:
            d += [j, j]
        for j, k in zip(c, d):
            if j >= k:
                print("No")
                return
        b = c
    print("Yes")


main()

Submission status: Wrong Answer

Solution code:
import random
s = ["Yes", "No"]
print(random.choice(s))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
n = int(input())
S = sorted(map(int, input().split()))
for i in range(n):
  if S[-(1<<i)] == S[-((1<<i) + 1)] == S[-(1<<(i+1))]:
    print("No")
    break
else:
  print("Yes")

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
S = np.array(list(map(int,input().split())))
S.sort()
ans = "Yes"

while S.size > 1:
    #print(S)
    n = S.size
    hn = n//2
    S1 = S[:hn]
    S = S[hn:]
    #print(S1,S,S1>=S)
    if np.count_nonzero(S1 >= S) > 0:
        ans = 'No'
        break

print(ans)