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 sys

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

for i in range(len(A)-1):
    if A[i] + A[i+1] >= L:
        print("Possible")
        for j in range(i):
            print(j+1)
        if i+2 < len(A):
            for j in range(i+2, len(A)):
                print(j)
        print(i+1)
        sys.exit()

print("Impossible")

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque

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

q = deque(A)
length = sum(A)

ans = []
l = 1
r = N-1
while len(q) > 1 and length >= L:
    if q[0] < q[-1]:
        cut = q.popleft()
        ans.append(l)
        l += 1
    else:
        cut = q.pop()
        ans.append(r)
        r -= 1
    # print(cut)

    length -= cut
    if length < L:
        break

if len(q) == 1:
    print("Possible")
    for a in ans:
        print(a)
else:
    print("Impossible")

Submission status: Wrong Answer

Solution code:
n,l=map(int,input().split())
a=list(map(int,input().split()))
tmp=[]
for i in range(n):
    tmp.append([a[i],i])
tmp.sort()
ans=[]

a_sum=sum(a)
for i in range(0,n-1):
    if a_sum>=l:
        ans.append(tmp[i][1])
        a_sum-=tmp[i][0]
    else:
        print("Impossible")
        exit()

print("Possible")
for i in range(len(ans)):
    if  ans[0]==0:
        print(ans[i]+1)
    else:
        print(ans[i])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

x=-1
for i in range(0,N-1):
    if a[i]+a[i+1]>=L:
        x=i
        break
if x==-1:
    print("Impossible")
else:
    print("Possible")
    for i in range(x+1, N-1):
        print(i+1)
    for i in range(0,x+1):
        print(i+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
ans=[]
fin=False
while not fin:
    if a[l]<=a[r]:
        s-=a[l]
        ans.append(l+1)
        l+=1
    elif a[l]>a[r]:
        s-=a[r]
        ans.append(r)
        r-=1
    if r-l==1:
        if s>=L:
            print("Possible")
            for a in ans:
                print(a)
            print(l+1)
        fin=True
    if s<L or fin:
        if not fin:
            print("Impossible")
        fin=True

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n, l = LI()
    a = LI()
    for i in range(n - 1):
        if a[i] + a[i + 1] >= l:
            x = i
    try:
        ans = []
        for j in range(x - 1):
            ans.append(j + 1)
        for j in range(n - 1, x - 1, -1):
            ans.append(j + 1)
        print("Possible")
        print("\n".join(map(str, ans)))
    except:
        print("Impossible")
    return


#main
if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
#002_C
from collections import deque

n, L = map(int, input().split())
a = list(map(int, input().split()))
sum_a = sum(a)
que = deque(a)

flg = True
ans = []
l, r = 1, n-1
for _ in range(n-1):
    if sum_a < L:
        flg = False
        break
    
    if que[0] < que[-1]:
        x = que.popleft()
        ans.append(l)
        l += 1
    else:
        x = que.pop()
        ans.append(r)
        r -= 1
    sum_a -= x

if flg:
    print('Possible')
    print(*ans, sep='\n')
else:
    print('Impossible')

Submission status: Wrong Answer

Solution code:
#002_C
from collections import deque

n, l = map(int, input().split())
a = list(map(int, input().split()))
sum_a = sum(a)
que = deque(a)

flg = True
ans = []
l, r = 1, n-1
for _ in range(n-1):
    if sum_a < l:
        flg = False
        break
    
    s = list(que)
    if s < s[::-1]:
        x = que.popleft()
        ans.append(l)
        l += 1
    else:
        x = que.pop()
        ans.append(r)
        r -= 1
    sum_a -= x

if flg:
    print('Possible')
    print(*ans, sep='\n')
else:
    print('Impossible')

Submission status: Wrong Answer

Solution code:
#002_C
from collections import deque

n, l = map(int, input().split())
a = list(map(int, input().split()))
sum_a = sum(a)
a = [(a[i], i) for i in range(n)]
que = deque(a)

flg = True
ans = []
for _ in range(n-1):
    if sum_a < l:
        flg = False
        break
        
    if que[0] < que[-1]:
        x, idx = que.popleft()
        idx += 1
    else:
        x, idx = que.pop()
    ans.append(idx)
    sum_a -= x

if flg:
    print('Possible')
    print(*ans, sep='\n')
else:
    print('Impossible')

Submission status: Wrong Answer

Solution code:
from collections import deque
n, l = map(int, input().split())
a = list(map(int, input().split()))
que = deque(a)
n -= 1
left_count = 1
right_count = n
ans = []
sum_length = sum(a)
while sum_length >= l and n > 0:
    left = que.popleft()
    right = que.pop()
    if left < right:
        que.append(right)
        sum_length -= left
        ans.append(left_count)
        left_count += 1
    else:
        que.appendleft(left)
        sum_length -= right
        ans.append(right_count)
        right_count -= 1
    n -= 1
if n == 0:
    print("Possible")
    for i in range(len(ans)):
        print(ans[i])
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(0,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):
            print(j)
        print(i+1)
        break
else:
    print('Impossible')

Submission status: Wrong Answer

Solution code:
N,L=map(int,input().split())
A=list(map(int,input().split()))
if N==2:
  if sum(A)>=L:
    print('Possible')
    print(1)
  else:
    print('Impossible')
  exit(0)

length=sum(A)
l=1
r=N-1
ans=''
for i in range(N-2):
  if A[0]<A[-1]:
    ans+='{0}\n'.format(l)
    l+=1
    length-=A.pop(0)
  else:
    ans+='{0}\n'.format(r)
    r-=1
    length-=A.pop(-1)
  if length<L:
    print('Impossible')
    exit(0)
ans+='{0}\n'.format(r)
print('Possible')
print(ans)

Submission status: Wrong Answer

Solution code:
N,L=map(int,input().split())
A=list(map(int,input().split()))
if N==2:
  if sum(A)>=L:
    print('Possible')
    print(1)
  else:
    print('Impossible')
  exit(0)
tmp=sum(A[:3])
if tmp<L:
  print('Impossible')
  exit(0)
elif tmp-A[2]<L and tmp-A[0]<L:
  print('Impossible')
  exit(0)
for i in range(N-3):
  tmp+=A[i+3]
  tmp-=A[i]
  if tmp<L:
    print('Impossible')
    exit(0)
  elif tmp-A[i+2]<L and tmp-A[i]<L:
    print('Impossible')
    exit(0)
print('Possible')
length=sum(A)
l=1
r=N-1
for i in range(N-1):
  if A[0]<A[-1]:
    print(l)
    l+=1
    A.pop(0)
  else:
    print(r)
    r-=1
    A.pop(-1)

Submission status: Wrong Answer

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)
        print(idx+1)
    else:
        print("Impossible")

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n, L, *a = map(int, open(0).read().split())
wa = [0] + a
a = [0] + a
for i in range(n): wa[i+1] += wa[i]

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

if cant: print("Impossible")
else:
    print("Possible")
    for i in ls: print(i)

Submission status: Wrong Answer

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

from collections import deque

def main():
	n,ll=map(int,input().split())
	a=list(map(int,input().split()))
	Q=deque(a)

	l=1
	r=n-1

	cnt=sum(a)

	ans=[]

	while l<r+1:
		if cnt<ll:
			print("Impossible")
			exit(0)
		if Q[0]<=Q[-1]:
			cnt-=Q.popleft()
			ans.append(l)
			l+=1
		else:
			cnt -= Q.pop()
			ans.append(r)
			r -= 1

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


























if __name__ == "__main__":
	main()

Submission status: Wrong Answer

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):
    print(i)
print(flag)

Submission status: Wrong Answer

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, n):
    if flag != i:
        print(i)
print(flag)

Submission status: Wrong Answer

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; r = -1
    for i in range(N-1):
        cur_R = A[i]+A[i+1]
        if cur_R>=L:
            r = i
            l = min(l,i)
            can.add(i)
    if not can:
        print("Impossible")
        return
    #print(l,r)
    print("Possible")
    ans = []

    for i in range(l):
        ans.append(i+1)
    for i in range(r+1,N-1):
        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: Wrong Answer

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()
    cant = set()
    if N==2:
        if sum(A)<L:
            print("Impossible")
            return
    for i in range(1,N-1):
        cur_L = A[i-1]+A[i]
        cur_R = A[i]+A[i+1]
        if cur_L<L and cur_R<L:
            print("Impossible")
            return
        if cur_L<L:
            cant.add(i-1)
        elif cur_R<L:
            cant.add(i)
    print("Possible")
    ans = []
    for i in cant:
        ans.append(i+1)
    for i in range(N-1):
        if i in cant:
            continue
        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: Wrong Answer

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")
    from collections import deque
    A = deque(A)
    idx = deque([i+1 for i in range(N-1)])
    sumA = sum(A)
    ans = []
    while len(A) > 1:
        if A[0] > A[-1]:
            sumA -= A.pop()
            ans.append(idx.pop())
        elif A[-1] < A[0]:
            sumA -= A.popleft()
            ans.append(idx.popleft())
        else:
            if last - 1 < len(A) - 1 - last:
                sumA -= A.pop()
                ans.append(idx.pop())
            else:
                sumA -= A.popleft()
                ans.append(idx.popleft())
    else:
        print("Possible")
        print(*ans, sep="\n")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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()]
    from collections import deque
    A = deque(A)
    idx = deque([i+1 for i in range(N-1)])
    sumA = sum(A)
    ans = []
    while len(A) > 1:
        if sumA >= L:
            if A[0] > A[-1]:
                sumA -= A.pop()
                ans.append(idx.pop())
            else:
                sumA -= A.popleft()
                ans.append(idx.popleft())
        else:
            print("Impossible")
            break
    else:
        print("Possible")
        print(*ans, sep="\n")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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 range(i + 1, N - 1): print(k + 1)
            print(i + 1)
            break
    else: print("Impossible")

    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

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:
  for i in range(1,ans):print(i)
  for i in range(n-1,ans,-1):print(i)
  print(ans)

Submission status: Wrong Answer

Solution code:
import sys

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

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

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

Submission status: Wrong Answer

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

N, L = map(int, input().split())
a = deque(map(int, input().split()))
a_rev = deque(reversed(a))
accum = list(accumulate(a))
l, r = 0, N-1
ans = []

while l < r:
    if accum[r] - (accum[l-1] if l > 0 else 0) < L:
        ans = []
        break
    if a < a_rev:
        a.popleft()
        a_rev.pop()
        l += 1
        ans.append(l)
    else:
        a.pop()
        a_rev.popleft()
        ans.append(r)
        r -= 1
if len(ans) == 0:
    print('Impossible')
else:
    print('Possible')
    for i in ans:
        print(i)

Submission status: Wrong Answer

Solution code:
#C greedy?
n,l = [int(i) for i in input().split()]
a   = [int(i) for i in input().split()]
total = sum(a)

ans = []
left = 0
right= n-1

for _ in range(n-1):
    if total<l:
        print("Impossible")
        break
        
    if a[left]<a[right]:        
        total -= a[left]
        left += 1
        ans.append(left)
    else:
        total -= a[right]
        ans.append(right)
        right -= 1  
else:
    print("Possible")
    for v in ans:
        print(v)

Submission status: Wrong Answer

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):
            print(j)
        print(i+1)
        exit()
    else:
        continue

print('Impossible')

Submission status: Wrong Answer

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 = [L[0]]+[i for i in range(1, N) if i != L[0]]
        print(*B[::-1], sep="\n")
    else:
        print("Impossible")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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 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: Wrong Answer

Solution code:
def main():
    N, L = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    s = sum(A)
    from collections import deque
    A = deque([(a, i) for i, a in enumerate(A)])
    ans = []
    while len(A) > 1:
        if s < L:
            return print("Impossible")
        if A[0][0] > A[-1][0]:
            c = A.pop()
            s -= c[0]
            ans.append(c[1])
        else:
            c = A.popleft()
            s -= c[0]
            ans.append(c[1]+1)
    print("Possible")
    print(*ans, sep="\n")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from collections import deque
N,L = map(int,input().split())
A = list(map(int,input().split()))
s = sum(A)
q = deque(A)

l,r = 1,N-1
ans = []
for _ in range(N-1):
    if s < L:
        print('Impossible')
        exit()
    if q[0] < q[-1]:
        s -= q[0]
        q.popleft()
        ans.append(l)
        l += 1
    else:
        s -= q[-1]
        q.pop()
        ans.append(r)
        r -= 1
print('Possible')
print(*ans, sep='\n')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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()
ans = list(range(1,n))
ans[x:] = ans[n-1:x-1:-1]
print(*ans,sep="\n")

Submission status: Wrong Answer

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

left=1
right=N-1
junban=[]
flg=True

if sum_A<L:
    flg=False
    
while left!=right:
    if sum_A<L:
        flg=False
        break
    
    if A[0]==A[-1]:
        if A[1]>=A[-1]:
            junban.append(right)
            right-=1
            sum_A-=A[-1]
            A.pop(-1)
        else:
            junban.append(left)
            left+=1
            sum_A-=A[0]
            A.pop(0)
            
    elif A[0]>A[-1]:
        junban.append(right)
        right-=1
        sum_A-=A[-1]
        A.pop(-1)
        
    else:
        junban.append(left)
        left+=1
        sum_A-=A[0]
        A.pop(0)
        
junban.append(right)

if flg:
    print("Possible")
    for i in range(N-1):
        print(junban[i])
else:
    print("Impossible")

Submission status: Wrong Answer

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

left=1
right=N-1
junban=[]
flg=True

if sum_A<L:
    flg=False
    
while left!=right:
    if sum_A<L:
        flg=False
        break
    if A[0]>=A[-1]:
        junban.append(right)
        right-=1
        sum_A-=A[-1]
        A.pop(-1)
    else:
        junban.append(left)
        left+=1
        sum_A-=A[0]
        A.pop(0)
        
junban.append(right)

if flg:
    print("Possible")
    for i in range(N-1):
        print(junban[i])
else:
    print("Impossible")

Submission status: Wrong Answer

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")
for i in range(1, len(knot)+1):
    if i != l:
        print(i)
print(l)

Submission status: Wrong Answer

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(N - 1):
        if j != i:
            print (j + 1)
    print (i + 1)

Submission status: Wrong Answer

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(n-1):
        if i != memo:
            print(i+1)
    print(memo+1)

Submission status: Wrong Answer

Solution code:
N, L = map(int, input().split())
A = list(map(int, input().split()))
B = [[A[i] + A[i+1], i+1] for i in range(N-1)]
if max(B[i][0] for i in range(len(B))) < L:
  p = 'Impossible'
else:
  p = 'Possible'
if p == 'Possible':
  print(p)
  x, y = 1, N-1
  while B[x-1][0] < L:
    print(x)
    x += 1
  while B[y-1][0] < L:
    print(y)
    y -= 1
  B.sort()
  for i in range(len(B)):
    if B[i][1] >= x and B[i][1] <= y:
      print(B[i][1])
else:
  print(p)

Submission status: Wrong Answer

Solution code:
N, L = map(int, input().split())
A = list(map(int, input().split()))
B = [[A[i] + A[i+1], i+1] for i in range(N-1)]
if max(B[i][0] for i in range(len(B))) < L:
  p = 'Impossible'
else:
  p = 'Possible'
  B.sort()
if p == 'Possible':
  print(p)
  for i in range(len(B)):
    print(B[i][1])
else:
  print(p)

Submission status: Wrong Answer

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:
    if l < importance_i:
        ans.append(l+1)
        l += 1
    if r > importance_i:
        ans.append(r)
        r -= 1
ans.append(importance_i+1)
print(*ans, sep="\n")

Submission status: Wrong Answer

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:
        flag = True
if not flag:
    print("Impossible")
    exit()
l, r = 0, N-1
print("Possible")
# 短い方から消してく
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 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:
        continue
    print(i)

print(index)
# 43

Submission status: Wrong Answer

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

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:
        continue
    print(i)

print(index)
# 43

Submission status: Wrong Answer

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

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

if index==0:
    print("Impossible")
else:
    print("Possible")
    for i in range(1,n):
        if i==index:
            continue
        print(i)
    print(index)

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()
    ans = list(range(N - 1))
    for i in range(last):
        print(i + 1)
    for i in range(last + 1, N - 1):
        print(i + 1)
    print(last + 1)
else:
    print('Impossible')