Problem p02920 (python)

Fixed submission:
import sys

def I(): return(int(sys.stdin.readline()))
def LI(): return([int(x) for x in sys.stdin.readline().split()])


def main():
    N = I()
    S = sorted(LI(),reverse=True)

    flag = [True]*len(S)

    cur = []
    cur.append(S[0])
    flag[0] = False

    for i in range(N):
        nxt = [x for x in cur]
        j = 0

        for k in range(len(S)):
            if j >= len(cur):
                break
            elif flag[k] and S[k]<cur[j]:
                nxt.append(S[k])
                j+=1
                flag[k] = False
        if len(cur) != j:
            return("No")
        cur = sorted(nxt,reverse=True)
    return("Yes")

if __name__ == "__main__":
    print(main())

Buggy submission (verdict: Runtime Error):
import sys

def I(): return(int(sys.stdin.readline()))
def LI(): return([int(x) for x in sys.stdin.readline().split()])

def main():
    N = I()
    S = sorted(LI(),reverse=True)

    flag = [True]*len(S)
    cur = []
    cur.append(S[0])
    flag[0] = False

    for i in range(N):
        j = 0
        jM = len(cur)
        for k in range(len(S)):
            if flag[k] and S[k]<cur[j]:
                nxt.append(S[k])
                j+=1
                flag[k] = False
                if j==jM:
                  break
        else:
            return("No")
        cur.sort(reverse=True)
    return("Yes")

if __name__ == "__main__":
    print(main())

Buggy submission (verdict: Runtime Error):
import sys

def I(): return(int(sys.stdin.readline()))
def LI(): return([int(x) for x in sys.stdin.readline().split()])


def main():
    N = I()
    S = sorted(LI(),reverse=True)

    flag = [True]*len(S)

    cur = []
    cur.append(S[0])
    flag[0] = False

    for i in range(N):
        nxt = [x for x in cur]
        j = 0

        for k in range(len(S)):
            if j >= len(cur):
                break
            elif flag[k] and S[k]<cur[j]:
                nxt.append(S[k])
                j+=1
                flag[k] = False
        if len(cur) != j:
            return("No")
        cur = sorted(nxt,reverse=True)
                                                                                                 return("Yes")

if __name__ == "__main__":
    print(main())

Buggy submission (verdict: Runtime Error):
import sys
import bisect
input = sys.stdin.readline

def main():
    N = int(input())
    S = [int(s) for s in input().split()]
    S.sort()

    cur = []
    cur.append(S.pop(-1))

    for i in range(N):
        nxt = [j for j in cur]
        bl = len(S)
        for x in cur:
            bl = bisect.bisect_left(S,x,lo=0,hi=bl)
            if bl==0:
                return("No")
            else:
                nxt.append(S.pop(bl-1))
        nxt.sort(reverse=True)
        cur = [j for j in nxt]
    return("Yes")

if __name__ == "__main__":
    print(main())

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    S = [int(s) for s in input().split()]
    S.sort(reverse = True)

    result = []
    result.append(S[0])

    left = 1
    que = []
    que.append([])

    for i in range(N):
        for j in range(2**i):
            que.append([])
            for k in len(que[-2]):
                if result[j]<=que[-2][k]:
                    que[-1].append(que[-2][k])
                else:
                    result.append(que[-2][k])
                    que[-1].extend(que[-2][k+1:])
                    break
            else:
                for k in range(left,len(S)):
                    if result[j]<=S[k]:
                        que[-1].append(S[k])
                    else:
                        result.append(S[k])
                        left = k+1
                        break
                else:
                    print("No")
                    break
        else:
            continue
        break
    else:
        print("Yes")

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    S = [int(s) for s in input().split()]
    S.sort(reverse = True)

    result = []
    result.append(S[0])
    que = [True]*len(S)
    que[0] = False

    for i in range(N):
        for j in range(2**i):
            for k in range(len(S)):
                if que[k] and result[j]>S[k]:
                    result.append[S[k]]
                    que[k] = False
                    break
            else:
                print("No")
                break
        else:
            continue
        break
    else:
        print("Yes")

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    S = [int(s) for s in input().split()]
    S.sort()

    result = []
    result.append(S.pop(-1))



    for i in range(N):
        x = 1
        for j in range(2**i):
            while(True):
                if x>2**i:
                    break
                if result[j]>S[-1*x]:
                    result.append(S.pop(-1*x))
                    break
                else:
                    x += 1
            if x>2**i:
                print("No")
                break
        else:
            continue
        break
    else:
        print("Yes")

if __name__ == "__main__":
    main()