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: Accepted

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,L=MI()
    A=LI()
    pos = False
    idx = 0
    for i in range(N-1):
        if A[i]+A[i+1] >= L:
            pos = True
            idx = i
    if pos:
        print("Possible")
        for i in range(N-1):
            if i!=idx:
                print(i+1)
            else:
                break
        for i in range(N-1)[::-1]:
            if i!=idx:
                print(i+1)
            else:
                break
        print(idx+1)
    else:
        print("Impossible")

if __name__ == '__main__':
    main()

Submission status: Accepted

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

last = -1
for i,(a,b) in enumerate(zip(A,A[1:])):
    if a+b >= L:
        last = i
        break
if last < 0:
    print('Impossible')
    exit()
print('Possible')

ans = list(range(1,i+1)) + list(range(N-1,i,-1))
print(*ans, sep='\n')

Submission status: Accepted

Solution code:
#gcdは3.4.3だとfractionsにある
from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

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

yes = "Yes"
no = "No"




def main():
    a,b,c = mi()
    if c-a-b<=0:
        print(no)
        exit()
    else:
        if (c-a-b)**2 > 4*a*b:
            print(yes)#gcdは3.4.3だとfractionsにある
from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

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

yes = "YES"
no = "NO"


def main():
    n,l = mi()
    a = li()

    flag = False
    lp = 0
    for i in range(n-1):
        if a[i]+a[i+1] >= l:
            print("Possible")
            flag = True
            lp = i+1
            break
    
    if not flag:
        print("Impossible")
        exit()

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

    


main()

Submission status: Accepted

Solution code:
n, L, *a = map(int, open(0).read().split())

cant = 0
for i in range(n-1):
    if a[i]+a[i+1]>=L:
        l, r = i, i+1
        break
else: cant = 1

if cant: print("Impossible")
else:
    print("Possible")
    for i in range(l): print(i+1)
    for i in range(n-2, l-1, -1): print(i+1)

Submission status: Accepted

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

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

MAX = 0
index = -1

for i in range(N-1):
    if A[i] + A[i+1] > MAX:
        MAX = A[i] + A[i+1]
        index = i+1

if MAX < L:
    print("Impossible")
else:
    print("Possible")
    for i in range(1,index):
        print(i)
    for i in range(N-1,index,-1):
        print(i)
    print(index)

Submission status: Accepted

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

# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np


def main():
	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:
			break
	else:
		print("Impossible")
		exit(0)
	i+=1
	print("Possible")
	for j in range(1,i):
		print(j)

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




if __name__ == "__main__":
	main()

Submission status: Accepted

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

flag = -1
for i in range(n - 1):
    if l <= a[i] + a[i + 1]:
        flag = i + 1
if flag == -1:
    print("Impossible")
    exit()

print("Possible")
for i in range(1, flag):
    print(i)
for i in range(flag + 1, n)[::-1]:
    print(i)
print(flag)

Submission status: Accepted

Solution code:
def examA():
    a, b = LI()
    if b<a:
        a,b = b,a
    if a<=0 and 0<=b:
        print("Zero")
    elif 0<a:
        print("Positive")
    else:
        judge = b-a+1
        if judge%2==0:
            print("Positive")
        else:
            print("Negative")
    return

def examB():
    N, M = LI()
    flag_R = [False]*N
    cnt = [1]*N
    flag_R[0] = True
    for _ in range(M):
        x, y = LI()
        x -= 1; y -= 1
        if flag_R[x]:
            flag_R[y] = True
        cnt[y] += 1
        cnt[x] -= 1
        if cnt[x]==0:
            flag_R[x] = False
    ans = sum(flag_R)
    print(ans)
    return

def examC():
    N, L = LI()
    A = LI()
    can = set()

    if N==2:
        if sum(A)<L:
            print("Impossible")
            return

    l = inf
    for i in range(N-1):
        cur_R = A[i]+A[i+1]
        if cur_R>=L:
            l = min(l,i)
            can.add(i)
    if not can:
        print("Impossible")
        return
    print("Possible")
    ans = []

    for i in range(l):
        ans.append(i+1)
    for i in range(l,N-1)[::-1]:
        if i in can:
            continue
        ans.append(i+1)
    for i in can:
        ans.append(i+1)
    for v in ans:
        print(v)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    examC()

"""

"""

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.buffer.readline
    N, L = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    last = -1
    for i in range(N-1):
        if L <= A[i] + A[i+1]:
            last = i+1
    if last < 0:
        return print("Impossible")
    ans = [i for i in range(1, last)] + \
        [i for i in range(last+1, N)][::-1] + [last]
    print("Possible")
    print(*ans, sep="\n")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    N, L = map(int, input().split())
    A = [int(a) for a in input().split()]
    for i in range(N - 1):
        if A[i] + A[i+1] >= L:
            print("Possible")
            for k in range(i): print(k + 1)
            for k in reversed(range(i + 1, N - 1)): print(k + 1)
            print(i + 1)
            break
    else: print("Impossible")

    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

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

last = -1
for i,(a,b) in enumerate(zip(A,A[1:])):
    if a+b >= L:
        last = i+1
        break
else:
    print('Impossible')
    exit()

print('Possible')
ans = [n for n in range(1,last)] + [n for n in range(N-1,last,-1)]
ans.append(last)
print(*ans, sep='\n')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline

N, L, *a = map(int, read().split())
knot = -1
for idx, (i, j) in enumerate(zip(a, a[1:])):
    if i + j >= L:
        knot = idx + 1
        print('Possible')
        break
else:
    print('Impossible')
    exit()

answer = list(range(1, knot)) + list(range(knot + 1, N))[::-1] + [knot]
print('\n'.join(map(str, answer)))

Submission status: Accepted

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

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(1, i+1):
            print(j)
        for j in range(i+1, N)[::-1]:
            print(j)
        exit()
print('Impossible')

Submission status: Accepted

Solution code:
#C
#各ペアについてみていき、一つでもｌ以上⇔Possible

n,l = [int(i) for i in input().split()]
a   = [int(i) for i in input().split()]

maxsum=0
maxind = 0
for i in range(n-1):
    s = a[i]+a[i+1]
    if s > maxsum:
        maxsum = s
        maxind = i+1

if maxsum<l:
    print("Impossible")
else:
    print("Possible")
    for i in range(1,maxind):
        print(i)
    for i in range(n-1,maxind,-1):
        print(i)
    print(maxind)

Submission status: Accepted

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

untiable = False
lastknot = None

for i in range(N-1):
    if A[i]+A[i+1] >= L:
        untiable = True
        lastknot = i+1
        break

if untiable:
    ans = [i for i in range(1,lastknot)] + [i for i in range(lastknot+1,N)[::-1]] + [lastknot]
    print('Possible')
    print('\n'.join(map(str,ans)))
    
else:
    print('Impossible')

Submission status: Accepted

Solution code:
import sys
import math
from collections import defaultdict

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

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

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

N,L = LI()
a = LI()

for i in range(N-1):
    if a[i]+a[i+1] >= L:
        print('Possible')
        for j in range(1,i+1):
            print(j)
        for j in range(i+2,N)[::-1]:
            print(j)
        print(i+1)
        exit()
    else:
        continue

print('Impossible')

Submission status: Accepted

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

def main():
    N,M = map(int,input().split())
    a = list(map(int,input().split()))
    use = -1
    for i in range(N-1):
        if a[i]+a[i+1] >= M:
            use = i
            break
    
    if use == -1:
        print("Impossible")
    else:
        print("Possible")
        for j in range(i):
            print(j+1)
        for j in range(N-1,i,-1):
            print(j)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():
    N, L, *A = map(int, open(0).read().split())
    L = [i for i,(x,y) in enumerate(zip(A, A[1:]), 1) if x+y >= L]
    if L:
        print("Possible")
        B = [i for i in range(L[0], N)]+[i for i in range(1,L[0])][::-1]
        print(*B[::-1], sep="\n")
    else:
        print("Impossible")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n,l = inm()
a = inl()
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-2,i-1,-1):
            print(j+1)
        exit()
print('Impossible')

Submission status: Accepted

Solution code:
#KNOT PUZZLE
N,L=map(int,input().split())
lists=list(map(int,input().split()))
flag=False
J=0
for i in range(N-1):
    if lists[i]+lists[i+1]>=L:
        J=i+1
        flag=True
        break
if not flag:
    print("Impossible")
if flag:
    print("Possible")
    for i in range(100001,0,-1):
      if 1<=J-i<=N-1:
        print(J-i)
      if 1<=J+i<=N-1:
        print(J+i)
    print(J)

Submission status: Accepted

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

l = 0
r = N-1
s = sum(A)
ans = []
while l < r:
    if s < L:
        break
    if r-l > 1:
        if A[l]+A[l+1] < L:
            s -= A[l]
            ans.append(l+1)
            l += 1
            continue
        if A[r]+A[r-1] < L:
            s -= A[r]
            ans.append(r)
            r -= 1
            continue
    if A[l] < A[r]:
        ans.append(l+1)
        s -= A[l]
        l += 1
    else:
        ans.append(r)
        s -= A[r]
        r -= 1
        
if len(ans) == N-1:
    print("Possible")
    for a in ans:
        print(a)
else:
    print("Impossible")

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque, Counter
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math
INF = 10**10
def bfs(graph, visited, position, root):
    visited[root] = 1
    position[root] = 0
    deq = deque([root])
    while(deq):
        cur = deq.pop()
        # print(cur)
        for nxt, dist in graph[cur]:
            if position[cur] + dist != position[nxt]:
                if position[nxt] != INF:
                    return False
                else:
                    position[nxt] = position[cur] + dist
            if not visited[nxt]:
                deq.append(nxt)
                visited[nxt] = 1

    return True

def main():
    n, l = getList()
    nums = getList()
    flag = False
    for i in range(n - 1):
        if nums[i] + nums[i + 1] >= l:
            flag = True
            index = 1 + i
            break

    if not flag:
        print("Impossible")
        return

    else:
        print("Possible")
        for i in range(1, index):
            print(i)
        for i in range(n-1, index, -1):
            print(i)
            
        print(index)
if __name__ == "__main__":

    main()

Submission status: Accepted

Solution code:
def main():
    N, L = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]

    ma = 0
    idx = -1
    for i in range(N-1):
        if ma < A[i] + A[i+1]:
            ma = A[i] + A[i+1]
            idx = i+1
    if ma < L:
        return print("Impossible")
    print("Possible")
    for i in range(1, idx):
        print(i)
    for i in range(idx, N)[::-1]:
        print(i)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

for i,(a,b) in enumerate(zip(A,A[1:])):
    if a+b >= L:
        print('Possible')
        break
else:
    print('Impossible')
    exit()
ans = []
for j in range(1,i+1):
    ans.append(j)
for j in range(N-1,i+1,-1):
    ans.append(j)
ans.append(i+1)
print(*ans, sep='\n')

Submission status: Accepted

Solution code:

def knot(N, L, a):
    res = []
    for i in range(N - 1):
        if a[i] + a[i + 1] >= L:
            res.append(i + 1)
            start = i
            break
    else:
        return res

    for i in range(start + 1, N - 1):
        res.append(i + 1)
    for i in range(start - 1, -1, -1):
        res.append(i + 1)
    return res


if __name__ == "__main__":
    N, L = map(int, input().split())
    a = list(map(int, input().split()))
    knot = knot(N, L, a)
    if not knot:
        print("Impossible")
    else:
        print("Possible")
        print(*knot[::-1], sep="\n")

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N, L = map(int, input().split())
a = list(map(int, input().split()))
s = -1
for i in range(N - 1):
  if a[i] + a[i + 1] >= L:
    s = i
    break
if s == -1:
  print("Impossible")
  exit(0)
res = [s]
for i in range(s - 1, -1, -1):
  res.append(i)
for i in range(s + 1, N - 1):
  res.append(i)
res.reverse()
print("Possible")
for r in res: print(r + 1)

Submission status: Accepted

Solution code:
N,L=map(int,input().split())
a=list(map(int,input().split()))
suma=sum(a)
flag=0
for i in range(1,N):
    if a[i]+a[i-1]>=L:
        flag=1
        idx=i
        break
if flag:
    print("Possible")
    for i in range(1,N):
        if idx==i:
            break
        else:
            print(i)
    for i in range(N-1,0,-1):
        if idx==i:
            break
        else:
            print(i)
    print(idx)
else:
    print("Impossible")

Submission status: Accepted

Solution code:
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input()) # n=1
def inpm(): return map(int,input().split()) # x=1,y=2
def inpl(): return list(map(int, input().split())) # a=[1,2,3,4,5,...,n]
def inpls(): return list(input().split())  # a=['1','2','3',...,'n']
def inplm(n): return list(int(input()) for _ in range(n)) # x=[] 複数行
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)] # [[2,2,2,2],[1,1,1,1],[3,3,3,3]] 
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)]) # [[1,1,1,1],[2,2,2,2],[3,3,3,3]] 
 
def main():
    n,l = inpm()
    a = inpl()
    ans = []
    for i in range(n-1):
        if a[i]+a[i+1] >= l:
            x = i+1
            ans.append(i+1)
            break
    if ans == []:
        print('Impossible')
    else:
        print('Possible')
        for i in range(x+1,n):
            ans.append(i)
        for i in range(x-1,0,-1):
            ans.append(i)
        ans.reverse()
        for i in range(len(ans)):
            print(ans[i])
    
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N, L = map(int, input().split())
A = list(map(int, input().split()))
d = [A[i] + A[i+1] for i in range(N-1)]
if max(d) < L:
  print("Impossible")
else:
  print("Possible")
  j = 0
  while d[j] < L:
    j += 1
  for i in range(j):
    print(i+1)
  for i in range(j, N-1):
    print(N-i+j-1)

Submission status: Accepted

Solution code:

def know(N, K, A):
    isOK = False
    for i in range(1, N):
        if A[i] + A[i - 1] >= K:
            isOK = True
            first = i

    if not isOK:
        return ["Impossible"]

    ans = [first]
    for i in range(first + 1, N):
        ans.append(i)
    for i in range(first - 1, 0, -1):
        ans.append(i)
    return ["Possible"] + ans[::-1]


if __name__ == "__main__":
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    ans = know(N, K, A)
    print(*ans, sep="\n")

Submission status: Accepted

Solution code:
import heapq
N, K = map(int, input().split())
A = list(map(int, input().split()))

knot = []
for i in range(N - 1):
    heapq.heappush(knot, (-A[i]-A[i+1], i))

ans = []
seen = [False]*N
while knot:
    L, i = heapq.heappop(knot)
    L = -L

    if seen[i]:
        continue
    if L < K:
        break

    seen[i] = True
    ans.append(i + 1)

    if i + 1 < N - 1:
        heapq.heappush(knot, (-L - A[i + 1], i + 1))
    if i - 1 >= 0:
        heapq.heappush(knot, (-L - A[i - 1], i - 1))

if len(ans) != N - 1:
    print("Impossible")
else:
    print("Possible")
    print(*ans[::-1], sep="\n")

Submission status: Accepted

Solution code:
def main():
    N,L = [int(n) for n in input().split()]
    A = [int(n) for n in input().split()]
    flg = False
    for i in range(N-1):
        if(A[i]+A[i+1] >= L):
            flg = True
            break
    if not flg:
        print("Impossible")
        return
    print("Possible")
    for j in range(1,i+1):
        print(j)
    for j in reversed(range(i+2,N)):
        print(j)
    print(i+1)
main()

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n-1):
  if a[i]+a[i+1] >= k:
    print("Possible")
    x = i
    break
else:
  print("Impossible")
  exit()
if x == 0:
  print(*list(range(1,n))[::-1],sep="\n")
else:
  ans = list(range(1,n))
  ans[x:] = ans[n-1:x-1:-1]
  print(*ans,sep="\n")

Submission status: Accepted

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

for i in range(1, N):
    if A[i-1] + A[i] >= L:
        print("Possible")
        for j in range(1, i):
            print(j)
        for j in range(N-1, i, -1):
            print(j)
        print(i)
        break
else:
    print("Impossible")

Submission status: Accepted

Solution code:
N,L = map(int,input().split())
A = list(map(int,input().split()))
A.insert(0,0)
flag = 0
for i in range(1,N):
    if A[i]+A[i+1]>=L:
        flag = i
        break
if flag == 0:
    print("Impossible")
else:
    print("Possible")
    if flag==1:
        for i in range(N-1,0,-1):
            print(i)
    else:
        for i in range(1,flag):
            print(i)
        for i in range(N-1,flag-1,-1):
            print(i)

Submission status: Accepted

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:
    f = i+1
    break
else:
  print("Impossible")
  exit()
print("Possible")
for i in range(1, f):
  print(i)
for i in range(n-1, f, -1):
  print(i)
print(f)

Submission status: Accepted

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

junban=[]
flg=False

for i in range(N-1):
    if A[i]+A[i+1]>=L:
        tmp=i
        flg=True


if flg:
    print("Possible")
    for i in range(N-1):
        if tmp>i:
            print(i+1)
        else:
            print(N+tmp-i-1)
else:
    print("Impossible")

Submission status: Accepted

Solution code:
# coding: utf-8
N, L = map(int, input().split())
A = list(map(int, input().split()))
flag = True
l = -1
for i in range(N-1):
    if A[i] + A[i+1] >= L:
        l = i+1
if l < 0:
    print("Impossible")
    exit()
knot = list(range(1, N))
print("Possible")
idx = 1
while idx < l:
    print(idx)
    idx += 1
idx = N-1
while idx > l:
    print(idx)
    idx -= 1
print(l)

Submission status: Accepted

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

last = -1
for i in range(n-1):
    if A[i] + A[i+1] >= l:
        last = i
        break

if last == -1:
    print("Impossible")
else:
    print("Possible")
    for i in range(last):
        print(i+1)
    for i in range(n-2, last-1, -1):
        print(i+1)

Submission status: Accepted

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')
        
        ans = []
        
        for j in range(1, i+1):
            ans.append(j)
        
        for j in range(N-1, i+1, -1):
            ans.append(j)
        
        ans.append(i+1)
        
        for ans_i in ans:
            print(ans_i)
        
        break
else:
    print('Impossible')

Submission status: Accepted

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

#最後に切るものを決める
i = 0
flag = False
while i < N - 1:
    if a[i] + a[i + 1] >= L:
        flag = True
        break
    i += 1

if not flag:
    print ('Impossible')
else:
    print ('Possible')
    for j in range(i):
      print (j + 1)
    for j in range(N - 1, i, -1):
      print (j)

Submission status: Accepted

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

#最後に切るものを決める
i = 0
flag = False
while i < N - 1:
    if a[i] + a[i + 1] >= L:
        flag = True
        break
    i += 1

if not flag:
    print ('Impossible')
else:
    print ('Possible')
    if i > 0:
        for j in range(i):
            print (j + 1)
    for j in range(N - 1, i, -1):
        print (j)

Submission status: Accepted

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

memo = -1
for i in range(n-1):
    if a[i]+a[i+1] >= l:
        memo = i

if memo == -1:
    print("Impossible")
else:
    print("Possible")
    for i in range(memo):
        print(i+1)
    for i in range(n-2,memo-1,-1):
        print(i+1)

Submission status: Accepted

Solution code:
import sys
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, l = list(map(int, readline().split()))
    a = collections.deque(list(map(int, readline().split())))
    for i in range(1, n):
        if a[i] + a[i-1] >= l:
            print("Possible")
            for j in range(1, i):
                print(j)
            for j in range(n - 1, i, -1):
                print(j)
            print(i)
            exit()
    print("Impossible")


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import itertools

# 和がL以上の2つをつなぐ
# 和がL以上のものが1つ作れたら、その周辺だけ処理していけばよい

N,L,*A = map(int,read().split())

S = [0] + [x+y for x,y in zip(A,A[1:])]
M = max(S)
i = S.index(M)

if M < L:
    print('Impossible')
    exit()

answer = list(itertools.chain(range(i,0,-1),range(i+1,N)))[::-1]
print('Possible')
print('\n'.join(map(str,answer)))

Submission status: Accepted

Solution code:
def s():
	n, l, *a = map(int, open(0).read().split())
	for i, (x, y) in enumerate(zip(a, a[1:])):
		if x + y >= l:
			print("Possible")
			r = list(range(n))
			print("\n".join(map(str, r[1:i + 1] + r[n:i:-1])))
			break
	else:
		print("Impossible")
if __name__=="__main__":
	s()

Submission status: Accepted

Solution code:
n,l,*a=map(int,open(0).read().split())
for i,(x,y) in enumerate(zip(a,a[1:])):
	if x+y>=l:
		print("Possible")
		r=list(range(n))
		print("\n".join(map(str,r[1:i+1]+r[n:i:-1])))
		exit()
print("Impossible")

Submission status: Accepted

Solution code:
def examA():
    a, b = LI()
    if a>0:
        ans = "Positive"
        print(ans)
        return
    if b>=0:
        ans = "Zero"
    else:
        judge = b-a
        if judge%2==1:
            ans = "Positive"
        else:
            ans = "Negative"
    print(ans)
    return

def examB():
    N, M = LI()
    boal = [1]*N
    d = defaultdict(bool)
    d[0] = True
    for _ in range(M):
        x,y = LI()
        boal[x-1] -=1
        boal[y-1] +=1
        if d[x-1]:
            d[y-1] = True
        if boal[x-1]==0:
            d[x-1] = False
    ans = sum(d.values())
    print(ans)
    return

def examC():
    N, L = LI()
    A = LI(); cur = -1
    ans = "Impossible"
    for i in range(N-1):
        if A[i]+A[i+1]>=L:
            ans = "Possible"
            cur = i
            break
    print(ans)
    if cur==-1:
        return
    ansC = []
    for i in range(cur):
        ansC.append(i)
    for i in range(N-2,cur,-1):
        ansC.append(i)
    ansC.append(cur)
    for v in ansC:
        print(v+1)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examC()

Submission status: Accepted

Solution code:
# coding: utf-8
N, L = map(int, input().split())
A = list(map(int, input().split()))
# Lより小さい組み合わせしか無い場合おわり
flag = False
for i in range(N-1):
    if A[i] + A[i+1] >= L:
        importance_i = i
        flag = True
        break
if not flag:
    print("Impossible")
    exit()

l, r = 0, N-1
print("Possible")
ans = []
while r - l > 1:
    # print(l, r)
    if l < importance_i:
        ans.append(l+1)
        l += 1
    if r > importance_i+1:
        ans.append(r)
        r -= 1
# print("importance_i", importance_i)
ans.append(importance_i+1)
print(*ans, sep="\n")

Submission status: Accepted

Solution code:
import sys
import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # applies to only numbers
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces
sys.setrecursionlimit(10 ** 7)

N, L = rl()
A = np.array(rl())
couple = A[:-1] + A[1:]
if couple.max() < L:
    print('Impossible')
    exit()
print('Possible')
index = np.nonzero(couple>=L)[0][0] + 1
for i in range(1, N):
    if i == index:
        break
    print(i)
for i in range(N-1, 0, -1):
    if i == index:
        break
    print(i)

print(index)
# 43