Problem:


Problem Statement

We have N pieces of ropes, numbered 1 through N. The length of piece i is a_i.

At first, for each i (1≤i≤N-1), piece i and piece i+1 are tied at the ends, forming one long rope with N-1 knots. Snuke will try to untie all of the knots by performing the following operation repeatedly:

Choose a (connected) rope with a total length of at least L, then untie one of its knots.

Is it possible to untie all of the N-1 knots by properly applying this operation? If the answer is positive, find one possible order to untie the knots.

Constraints

2≤N≤10^5

1≤L≤10^9

1≤a_i≤10^9

All input values are integers.

Input

The input is given from Standard Input in the following format:

N L
a_1 a_2 ... a_n

Output

If it is not possible to untie all of the N-1 knots, print Impossible.

If it is possible to untie all of the knots, print Possible, then print another N-1 lines that describe a possible order to untie the knots. The j-th of those N-1 lines should contain the index of the knot that is untied in the j-th operation. Here, the index of the knot connecting piece i and piece i+1 is i.

If there is more than one solution, output any.

Sample Input 1

3 50
30 20 10

Sample Output 1

Possible
2
1

If the knot 1 is untied first, the knot 2 will become impossible to untie.

Sample Input 2

2 21
10 10

Sample Output 2

Impossible

Sample Input 3

5 50
10 20 30 40 50

Sample Output 3

Possible
1
2
3
4

Another example of a possible solution is 3, 4, 1, 2.



Sample input:
3 50
30 20 10


Sample output:
Possible
2
1

Submission status: Wrong Answer

Solution code:
import os
import sys

import numpy as np

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

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


N, L = list(map(int, sys.stdin.buffer.readline().split()))
A = list(map(int, sys.stdin.buffer.readline().split()))

A = np.array(A, dtype=int)

s = A[1:] + A[:-1]

if s.max() >= L:
    print('Possible')
    last = s.argmax() + 1
    ans = list(range(1, N))
    ans.remove(last)
    if ans:
        print(*ans, sep='\n')
    print(last)
else:
    print('Impossible')

Submission status: Wrong Answer

Solution code:
import os
import sys

import numpy as np

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

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


N, L = list(map(int, sys.stdin.buffer.readline().split()))
A = list(map(int, sys.stdin.buffer.readline().split()))

A = np.array(A, dtype=int)

s = A[1:] + A[:-1]

if s.max() >= L:
    print('Possible')
    last = s.argmax() + 1
    ans = list(range(1, N))
    ans.remove(last)
    print(*ans, sep='\n')
    print(last)
else:
    print('Impossible')

Submission status: Wrong Answer

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

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

imp = 0
for i in range(N-1):
    if a[i]+a[i+1]>=L:
        break
else:
    print("Impossible")
    imp = 1

#possible
if imp==0:
    for j in range(i):
        print(j+1)
    for j in range(N-1,i+1,-1):
        print(j)
    print(i+1)

Submission status: Wrong Answer

Solution code:
import math

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

#a = list(map(int, input().split()))

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


#4:25
n,k = list(map(int, input().split()))
a = list(map(int, input().split()))
maxv=0
maxid=-1
for i in range(n-1):
    if(maxv<a[i]+a[i+1]):
        maxv=a[i]+a[i+1]
        maxid=i+1

if(maxv>k):
    print("Impossible")
else:
    print("Possible")
    for j in range(maxid-1):
        print(j+1)
        
    for j in range(n-maxid-1):
        print(n-1-j)
        
    print(maxid)

Submission status: Wrong Answer

Solution code:
import math

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

#a = list(map(int, input().split()))

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


#4:25
n,k = list(map(int, input().split()))
a = list(map(int, input().split()))
maxv=0
maxid=-1
for i in range(n-1):
    if(maxv<a[i]+a[i+1]):
        maxv=a[i]+a[i+1]
        maxid=i+1

if(maxv>k):
    print("Impossible")
    exit()
else:
    print("Possible")
    for j in range(maxid-1):
        print(j+1)
        
    for j in range(n-maxid-1):
        print(n-1-j)
        
    print(maxid)

Submission status: Wrong Answer

Solution code:
import math

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

#a = list(map(int, input().split()))

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


#4:25
n,k = list(map(int, input().split()))
a = list(map(int, input().split()))
maxv=0
maxid=-1
for i in range(n-1):
    if(maxv<a[i]+a[i+1]):
        maxv=a[i]+a[i+1]
        maxid=i+1

if(maxv>k):
    print("Impossible")
    exit()

print("Possible")
for j in range(maxid-1):
    print(j+1)
    
for j in range(n-maxid-1):
    print(n-1-j)
    
print(maxid)

Submission status: Wrong Answer

Solution code:
import numpy as np
n,l=map(int,input().split())
a=list(map(int,input().split()))
flag=False;idx=0
for i in range(n-1):
  if a[i]+a[i+1]>=l:
    flag=True
    idx=i
if not flag:
  print("Impossible")
  exit(0)
print("Possible")
for x in range(idx):
  print(x+1)
for x in reversed(range(idx+1)):
  print(x+1)

Submission status: Wrong Answer

Solution code:
import numpy as np
n,l=map(int,input().split())
a=list(map(int,input().split()))
b=[i for i in range(n)]
s=sum(a)
pair=sorted(list(zip(a,b)))
for cnt,x in enumerate(pair):
  if cnt>=n-1:
    break
  elif s>=l:
    s-=x[0]
  else:
    print("Impossible")
    exit(0)
print("Possible")
for x in pair:
  if x[1]>0:print(x[1])

Submission status: Wrong Answer

Solution code:
import numpy as np
n,l=map(int,input().split())
a=list(map(int,input().split()))
b=[i+1 for i in range(n)]
s=sum(a)
pair=sorted(list(zip(a,b)))
for cnt,x in enumerate(pair):
  if cnt>=n-1:
    break
  elif s>=l:
    s-=x[0]
  else:
    print("Impossible")
    exit(0)
print("Possible")
for x in pair:
  print(x[1])

Submission status: Wrong Answer

Solution code:
import numpy as np
n,l=map(int,input().split())
a=list(map(int,input().split()))
index=np.argsort(a)
s=sum(a)
for x in index:
  if s-a[x]>=l:
    s-=a[x]
  else:
    print("Impossible")
    exit(0)
print("Possible")
for x in index:
  print(x+1)

Submission status: Wrong Answer

Solution code:
def solve(N, L, a):
    from collections import deque

    sum_ = sum(a)

    b = tuple((length, knot_prev, knot_prev + 1) for knot_prev, length in enumerate(a))

    dq = deque(b)

    ans = []
    for _ in range(N - 1):
        if sum_ < L:
            return []
        if dq[0] < dq[-1]:
            length, knot_prev, knot_after = dq.popleft()
            sum_ -= length
            ans.append(knot_after)
        elif dq[0] > dq[-1]:
            length, knot_prev, knot_after = dq.pop()
            sum_ -= length
            ans.append(knot_prev)
        else:
            # dq[0] == dq[-1]
            ofs = 1
            while dq[ofs] == dq[N - 1 - len(ans) - ofs]:
                if ofs + 1 >= N - 1 - len(ans) - (ofs + 1):
                    break
                ofs += 1

            if dq[ofs] <= dq[N - 1 - len(ans) - ofs]:
                x = 0
                while x <= ofs:
                    if sum_ < L:
                        return []
                    length, knot_prev, knot_after = dq.popleft()
                    sum_ -= length
                    ans.append(knot_after)
                    x += 1
            else:
                x = 0
                while x <= ofs:
                    if sum_ < L:
                        return []
                    length, knot_prev, knot_after = dq.pop()
                    sum_ -= length
                    ans.append(knot_prev)
                    x += 1
    return ans


if __name__ == '__main__':
    N, L = map(int, input().split())
    a = tuple(map(int, input().split()))
    ans = solve(N, L, a)
    if ans:
        print('Possible')
        print(*ans, sep='\n')
    else:
        print('Impossible')

Submission status: Wrong Answer

Solution code:
n,l=map(int,input().split())
a=list(map(int, input().split()))
for i in range(n-1):
  if a[i]+a[i+1]>=l:
    print("Possible")
    for j in range(i):print(j+1)
    for j in range(n-1,i,-1):print(i)
    exit()
print("Impossible")

Submission status: Wrong Answer

Solution code:
print('Impossible')

Submission status: Wrong Answer

Solution code:
N, L = map(int, input().split())
A = list(map(int, input().split()))
b = [0] * (N - 1)
c = N - 1
pos = 1
for i in range(N - 1):
    l = A[i] + A[i + 1]
    if l >= L:
        j = i
        b[j] = c
        c -= 1
        break
else:
    pos = 0
    print('Impossible')
if pos:
    for i in range(j - 1, -1, -1):
        b[i] = c
        c -= 1
    for i in range(N - 2, j, -1):
        b[i] = c
        c -= 1
    print('Possible')
    for ans in b:
        print(ans)

Submission status: Wrong Answer

Solution code:
N, L = map(int, input().split())
A = list(map(int, input().split()))
b = [0] * (N - 1)
c = N - 1
pos = 1
for i in range(N - 1):
    l = A[i] + A[i + 1]
    if l >= L:
        j = i
        b[j] = c
        c -= 1
        break
else:
    pos = 0
    print('Impossible')
if pos:
    for i in range(j - 1, -1, -1):
        b[i] = c
        c -= 1
    for i in range(j + 1, N - 1):
        b[i] = c
        c -= 1
    print('Possible')
    for ans in b:
        print(ans)

Submission status: Wrong Answer

Solution code:
N, L = map(int, input().split())
A = list(map(int, input().split()))
b = [0] * (N - 1)
c = [N - 1]
imp = 0
l, r = 0, N - 1


def func(x):
    if b[x] == 0:
        l = A[x] + A[x + 1]
        if l >= L:
            b[x] = c[0]
            c[0] -= 1
            A[x], A[x + 1] = l, l
            return 1
    return 0


while (c[0] > 0):
    cf = c[0]
    mid = (r + l) // 2
    if func(mid):
        r = mid
    else:
        l = mid
    if r - l < 1:
        if cf == c[0]:
            imp = 1
            break
        l, r = 0, N - 1


if imp:
    print('Impossible')
else:
    print('Possible')
    for ans in b:
        print(ans)

Submission status: Wrong Answer

Solution code:
N, L = map(int, input().split())
A = list(map(int, input().split()))
b = [0] * (N - 1)
bb = []
c = N - 1
imp = 0
while (c > 0):
    cf = c
    for i in range(c):
        if b[i] == 0:
            l = A[i] + A[i + 1]
            if l >= L:
                b[i] = c
                bb.append([i, b.pop(i)])
                c -= 1
                A[i] = l
                A.pop(i+1)
                break
    if cf == c:
        imp = 1
        break
if imp:
    print('Impossible')
else:
    print('Possible')
    bb.sort()
    for ans in bb:
        print(ans[1])

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.buffer.readline
N, L = map(int, input().split())
a = list(map(int, input().split()))
res = []
for i in range(N - 1):
  if a[i] + a[i + 1] >= L:
    res.append(i + 1)
    break
if len(res):
  i = 1
  while i < N:
    if i == res[0]:
      i += 1
    res.append(i)
    i += 1
  print("Possible")
  for i in range(N - 2, -1, -1):
    print(res[i])
else:
  print("Impossible")

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.buffer.readline
N, L = map(int, input().split())
a = list(map(int, input().split()))
res = []
for i in range(N - 1):
  if a[i] + a[i + 1] >= L:
    res.append(i + 1)
if len(res):
  i = 1
  while i < N:
    if i == res[0]:
      i += 1
    res.append(i)
    i += 1
  print("Possible")
  for i in range(N - 2, -1, -1):
    print(res[i])
else:
  print("Impossible")

Submission status: Wrong Answer

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

s = 0
for i in range(N-1):
    if A[i] + A[i+1] > s:
        s = A[i] + A[i+1]
        ind = i

if s < L:
    print('Impossible')
else:
    print('Possible')
    for i in range(N-1):
        if i != ind:
            print(i+1)
    print(ind+1)

Submission status: Wrong Answer

Solution code:
N,L=map(int,input().split())
A=list(map(int,input().split()))
ans=[]
for i in range(N-1):
    if A[i]+A[i+1]>=L:
        last=i
        for j in range(i):
            ans.append(j)
        for j in range(N-2,i,-1):
            ans.append(j)
        break

if len(ans)==0:
    print("Impossible")
    exit()

ans.append(last)

print("Possible")
for i in range(N-1):
    print(ans[i]+1)

Submission status: Wrong Answer

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

pos = -1

for i in range(n-1):
    if a[i] + a[i+1] >= l:
        pos = i
        break
if pos == -1:
    print('Impossible')
    exit()

print('Possible')
for i in range(pos):
    print(i+1)

for i in range(pos+1,n-1):
    print(i+1)

print(pos+1)

Submission status: Wrong Answer

Solution code:
n,l,*a=map(int,open(0).read().split())
ans=[]    
for i in range(1,n):
    if a[i]+a[i-1]<l:
        ans.append(i)
    else:
        for j in range(n-1,i-1,-1):
            ans.append(j)
        print("Possile")
        print(*ans,sep="\n")
        exit()
print("Impossible")

Submission status: Wrong Answer

Solution code:
from collections import deque
N, L = map(int, input().split())
c = list(map(int, input().split()))
for i in range(len(c)-1):
  if c[i] + c[i+1] >= L:
    pos = i + 1
    break
else:
  print("Impossible")
  exit()

print("Possible")
for i in range(1,pos):
  print(i)
for i in range(len(c) -1, pos, -1):
  print(i)

Submission status: Wrong Answer

Solution code:
from collections import deque
N, L = map(int, input().split())
c = list(map(int, input().split()))
li = [[i+1, v] for i, v in enumerate(c)]
lng = sum(c)
deli = deque(li)
ans = []
while len(deli) > 1:
  l = deli[0][1]
  r = deli[-1][1]
  if l <= r:
    dl = deli.popleft()
    cnt = dl[0] 
  else:
    dl = deli.pop()
    cnt = dl[0] - 1
#  print(deli, l, r, lng, cnt, L)
  if lng >= L:
    ans.append(cnt)
    lng -= dl[1]
  else:
    print("Impossible")
    exit()
print("Possible")
for i in ans:
  print(i)

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,l=LI()
  a=LI()

  sm=sum(a)
  
  ans=[]
  _i=0
  f=False
  for i,x in enumerate(a[:-2]):
    if sm-x<l:
      _i=i
      f=True
      break
    ans.append(i+1)
    sm-=x
  # print(sm,_i)
  # print(a[_i:][::-1])

  if f:
    for i,x in enumerate(a[_i:][::-1][:-2]):
      # print(sm,x,l)
      if sm-x<l:
        print('Impossible')
        exit()
      ans.append(n-(i+1))
      sm-=x

  if sm<l:
    print('Impossible')
    exit()

  if len(ans)==0:
    ans.append(1)
  else:
    if f:
      ans.append(ans[-1]-1)
    else:
      ans.append(ans[-1]+1)

  print('Possible')
  for x in ans:
    print(x)

main()
# print(main())

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,l=LI()
  a=LI()

  sm=sum(a)
  st=1
  ed=n-1
  ans=[]
  for i in range(n-2):
    x=a[0]
    y=a[-1]
    if sm-x<l and sm-y<l:
      print('Impossible')
      exit()
    if x<y:
      sm-=a[0]
      a=a[1:]
      ans.append(st)
      st+=1
    else:
      sm-=a.pop()
      ans.append(ed)
      ed-=1
  if sm<l:
    print('Impossible')
    exit()

  print('Possible')
  ans.append(st)

  for x in ans:
    print(x)

main()
# print(main())

Submission status: Wrong Answer

Solution code:
def resolve():
    n, l = map(int, input().split())
    a = list(map(int, input().split()))
    for i in range(n - 1):
        if a[i] + a[i + 1] >= l:
            print("Possible")
            for j in range(i):
                print(j + 1)
            for j in range(n - 1, i, -1):
                print(j)
            print(i + 1)
            return 0
    print("Impossible")


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    n, l = map(int, input().split())
    a = list(map(int, input().split()))
    for i in range(n - 1):
        if a[i] + a[i + 1] >= l:
            print("Possible")
            for j in range(i - 1):
                print(j + 1)
            for j in range(n - 2, i, -1):
                print(j + 1)
            print(i + 1)
            return 0
    print("Impossible")


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    n, l = map(int, input().split())
    a = list(map(int, input().split()))
    for i in range(n - 1):
        if a[i] + a[i + 1] >= l:
            print("Possible")
            for j in range(i - 1):
                print(j + 1)
            print(i + 1)
            for j in range(n - 2, i, -1):
                print(j + 1)
            return 0
    print("Impossible")


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    n, l = map(int, input().split())
    a = list(map(int, input().split()))
    for i in range(n - 1):
        if a[i] + a[i + 1] >= l:
            print("Possible")
            for j in range(i - 1):
                print(j + 1)
            print(i + 1)
            for j in range(n - 1, i, -1):
                print(j + 1)
            return 0
    print("Impossible")


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    n, l = map(int, input().split())
    a = list(map(int, input().split()))
    for i in range(n - 1):
        if a[i] + a[i + 1] >= l:
            print("Possible")
            for j in range(i - 1):
                print(j + 1)
            print(i + 1)
            for j in range(n - 1, i + 1, -1):
                print(j + 1)
            return 0
    print("Impossible")


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    n, l = map(int, input().split())
    a = list(map(int, input().split()))
    for i in range(n - 1):
        if a[i] + a[i + 1] >= l:
            print("Possible")
            for j in range(i - 1):
                print(j + 1)
            print(i + 1)
            for j in range(i + 1, n - 1):
                print(j + 1)
            return 0
    print("Impossible")


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    n, l = map(int, input().split())
    a = list(map(int, input().split()))
    for i in range(n - 1):
        if a[i] + a[i + 1] >= l:
            print("Possible")
            for j in range(n):
                if j != i:
                    print(j + 1)
            print(i + 1)
            return 0
    print("Impossible")


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    n, l = map(int, input().split())
    a = list(map(int, input().split()))
    for i in range(n - 1):
        if a[i] + a[i + 1] >= l:
            print("Possible")
            for j in range(n - 1):
                if j != i:
                    print(j + 1)
            print(i + 1)
            return 0
    print("Impossible")


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

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

#(方針)ロープの和がある2か所でL以上ならPossible,それ以外ならImposible
#→Possibleな理由はその2か所以外から1つずつほどいていけば必ずL以上の部分ができるから
#→端からほどくとわかりやすい(?)

judge = 0
p1,p2 = -1,-1 #2か所で和がL以上になるところ
for i in range(N):
  if(i != N-1):
    if(A[i]+A[i+1] >= L):
      judge = 1
      p1,p2 = i,i+1
      break
point = p1+1 #p1とp2の結び目(index→問題文の数)

if(judge == 0): print('Impossible')
else:
 print('Possible')
 for i in range(1,N):
  if(i != point): print(i)
 print(point)

Submission status: Wrong Answer

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

B = [A[i-1] + A[i] for i in range(1,N)]

if max(B) < L :
    print("Impossible")
else :
    print("Possible")

    ind = B.index(max(B)) + 1
    for i in range(ind) :
        print(i+1)
    for i in range(N-1,ind,-1) :
        print(i+1)

Submission status: Wrong Answer

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

B = [A[i-1] + A[i] for i in range(1,N)]

if max(B) < L :
    print("Impossible")
else :
    print("Possible")

    l,r = 0,N-1

    for i in range(N-1) :
        X = A[l:r+1]
        Y = list(reversed(A))
        for j in range(len(X)//2) :
            if X[j] < Y[j] :
                print(l+1)
                l += 1
                break
            elif X[j] > Y[j] :
                print(r)
                r -= 1
                break
        else :
            print(r)
            r -= 1

Submission status: Wrong Answer

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

B = [A[i-1] + A[i] for i in range(1,N)]

if max(B) < L :
    print("Impossible")
else :
    print("Possible")

    l,r = 0,N-1

    for i in range(N-1) :
        if A[l] <= A[r] :
            print(l+1)
            l += 1
        else :
            print(r)
            r -= 1

Submission status: Wrong Answer

Solution code:
import sys
import os

N, L = map(int,input().split())
A = list(map(int,input().split()))
for i in range(N-1):
    if A[i] + A[i+1] >= L:
        print("possible")
        for j in range(i):
            print(j+1)
        for j in range(N-1,i,-1):
            print(j)
        sys.exit()
print("Impossible")

Submission status: Wrong Answer

Solution code:
import sys
import os
N, L = map(int,input().split())
A = list(map(int,input().split()))
for i in range(N-1):
    if A[i] + A[i+1] >= L:
        print("possible")
        for j in range(N-1):
            if j != i:
                print(j+1)
        print(i+1)
        sys.exit()
print("Impossible")

Submission status: Wrong Answer

Solution code:
import sys
import os

N, L = map(int,input().split())
A = list(map(int,input().split()))
ans = []
i = 0
while N - i >= 3:
    a,b,c = A[i],A[i+1],A[i+2]
    if N - i > 3:
        ans.append(i+3)
    if a + b + c >= L:
        if a + b >= L:
            ans.append(i+2)
            ans.append(i+1)
        elif b + c >= L:
            ans.append(i+1)
            ans.append(i+2)
        else:
            print("Impossible")
            sys.exit()
    else:
        print("Impossible")
        sys.exit()
    i += 3
if N - i == 2:
    if A[i] + A[i+1] >= L:
        ans.append(i+1)
    else:
        print("Impossible")
        sys.exit()


print("Possible")
for a in ans:
    print(a)

Submission status: Wrong Answer

Solution code:
import sys
import os
N, L = map(int,input().split())
A = list(map(int,input().split()))
ans = []
if N == 2:
    if A[0] + A[1] >= L:
        print("Possible")
        print(1)
    else:
        print("Impossible")
    sys.exit()
i = 0
while N - i >= 3:
    a,b,c = A[i],A[i+1],A[i+2]
    if N - i > 3:
        ans.append(i+3)
    if a + b + c >= L:
        if a + b >= L:
            ans.append(i+2)
            ans.append(i+1)
        elif b + c >= L:
            ans.append(i+1)
            ans.append(i+2)
        else:
            print("Impossible")
            sys.exit()
    else:
        print("Impossible")
        sys.exit()
    i += 3
if N - i == 2:
    if A[i] + A[i+1] >= L:
        ans.append(i+1)
    else:
        print("Impossible")
        sys.exit()


print("Possible")
for a in ans:
    print(a)

Submission status: Wrong Answer

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

flag = False
for i in range(n-1):
    if a[i] + a[i+1] >= l:
        flag = True
        pos = i
if flag:
    print('Possible')
    for i in range(n-1):
        if i < pos:
            print(i+1)
        elif i == pos :
            break
    for i in range(n-2, -1, -1):
        if i > pos :
            print(i+1)
        elif i == pos :
            break
    print(pos+1)
else:
    print('Imapossible')


#%%

Submission status: Wrong Answer

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

flag = False
for i in range(n-1):
    if a[i] + a[i+1] >= l:
        flag = True
        pos = i
if flag:
    print('Possible')
    for i in range(n-1):
        if i != pos:
            print(i+1)
    print(pos+1)
else:
    print('Imapossible')

Submission status: Wrong Answer

Solution code:
def resolve():
    n, l = map(int, input().split())
    a = list(map(int, input().split()))
    for i in range(n - 1):
        if a[i] + a[i + 1] > l:
            print("Possible")
            for j in range(n - 1):
                if j != i:
                    print(j + 1)
            print(i + 1)
            return 0
    print("Impossible")


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    n, l = map(int, input().split())
    a = list(map(int, input().split()))
    for i in range(n - 1):
        if a[i] + a[i + 1] > l:
            print("Possible")
            for j in range(n - 1):
                if j != i:
                    print(j)
            print(i)
            return 0
    print("Impossible")


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    n, l = map(int, input().split())
    a = list(map(int, input().split()))
    s = sum(a)
    a.sort()
    for i in range(n - 1):
        s -= a[i]
        if s < l:
            print("Impossible")
            return 0
    print("Possible")
    for i in range(n - 1):
        print(a[i])


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    n, l = map(int, input().split())
    a = list(map(int, input().split()))
    s = sum(a)
    a.sort()
    for i in range(n - 2):
        s -= a[i]
        if s < l:
            print("Impossible")
            return 0
    print("Possible")
    for i in range(n - 1):
        print(a[i])


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    n, l = map(int, input().split())
    a = list(map(int, input().split()))
    s = sum(a)
    a.sort()
    for ai in a:
        s -= ai
        if s < l:
            print("Impossible")
            return 0
    print("Possible")
    for i in range(n - 1):
        print(a[i])


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    n, l = map(int, input().split())
    a = list(map(int, input().split()))
    s = sum(a)
    a.sort()
    for ai in a:
        s -= ai
        if s < l:
            print("Impossible")
            return 0
    print("Possible")
    for ai in a:
        print(ai)


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-


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

    if sum(a[:2]) >= l:
        print('Possible')

        for i in range(n - 1, 0, -1):
            print(i)
    elif sum(a[n - 2:]) >= l:
        print('Possible')

        for i in range(1, n):
            print(i)
    else:
        print('Impossible')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def check():
    n, L = map(int, input().split())
    a = list(map(int, input().split()))
    pair = [a[i]+a[i+1] for i in range(n-1)]
    if n == 2:
        if pair[0] < L:
            print("Impossible")
        else:
            print("Possible\n1")
        return
    
    ans=[]
    for i in range(n - 1):
        if i != n - 2:
            if pair[i] < L and pair[i + 1] < L:
                print("Impossible")
                return
        if pair[i] < L:
            ans.append(i + 1)
    rest = set([i for i in range(1, n)]) - set(ans)
    ans.extend(list(rest))
    print("Possible")
    print(*ans, sep="\n")
    return
        
check()

Submission status: Wrong Answer

Solution code:
import sys
N, L = map(int, input().split())
A = [int(_) for _ in input().split()]


for n in range(N - 1):
    if A[n] + A[n + 1] >= L:
        print('Possible')
        tmp_ind = n + 1
        for m in range(1, N):
            if m != tmp_ind:
                print(m)
        print(tmp_ind)
        sys.exit()
print('Impossible')

Submission status: Wrong Answer

Solution code:
print("Impossible")

Submission status: Wrong Answer

Solution code:
print("impossible")

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N,L=map(int,input().split())
l=list(map(int,input().split()))
judge="Impossible"
index=0

for i in range(N-1):
    if (l[i]+l[i+1])>=L:
        judge="Possible"
        index=i
        break

print(judge)
if judge=="Impossible":
    exit()

for i in range(N-1):
    if (i)==(index):
        pass
    else:
        print(i+1)
    
print(index+1)

Submission status: Wrong Answer

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

S = sum(A)
l = 0
r = N-1
cut = []
while (len(cut) < N-1):
  #print(cut)
  if S < L:
    print('Impossible')
    exit()
  if A[l] < A[r]:
    cut.append(l+1)
    S -= A[l]
    l += 1
  else:
    cut.append(r)
    S -= A[r]
    r -= 1
print('Possible')
for c in cut:
  print(c)

Submission status: Wrong Answer

Solution code:
# 2019/09/18


n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=[]
sum_a=sum(a)
l,r=0,n-1

while l<r:
    if sum_a<k:
        print('Impossible')
        exit()
    if a[l]>a[r]:
        ans.append(r+1)
        sum_a-=a[r]
        r-=1
    else:
        sum_a-=a[l]
        ans.append(l+1)
        l+=1
    
print('Possible')
print(*ans,sep='\n')

Submission status: Wrong Answer

Solution code:
# 2019/09/18

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

sum_a=sum(a)

l=0
r=n-1
ans=[]
while l<r:
    if sum_a<k:
        print('Impossible')
        exit()
    if a[l]>a[r]:
        sum_a-=a[r]
        ans.append(r)
        r-=1
    else:
        sum_a-=a[l]
        ans.append(l+1)
        l+=1
print('Possible')
print(*ans,sep='\n')

Submission status: Wrong Answer

Solution code:
# 2019/09/18

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

sum_a=sum(a)

l=0
r=n-1
while l<r:
    if sum_a<k:
        print('Impossible')
        exit()
    if a[l]>a[r]:
        sum_a-=a[r]
        print(r)
        r-=1
    else:
        sum_a-=a[l]
        print(l+1)
        l+=1