Submission details
Task:3SUM
Sender:aalto26gm_029
Submission time:2026-10-19 17:16:17 +0300
Language:Python3 (PyPy3)
Status:READY
Result:
Test results
testverdicttime
#10.06 sdetails
#20.06 sdetails
#30.06 sdetails
#40.06 sdetails
#50.06 sdetails
#60.06 sdetails
#70.06 sdetails
#80.06 sdetails
#90.06 sdetails
#100.06 sdetails
#110.07 sdetails
#120.07 sdetails
#130.07 sdetails
#140.06 sdetails
#150.07 sdetails
#160.07 sdetails
#170.07 sdetails
#180.06 sdetails
#190.06 sdetails
#200.07 sdetails
#210.07 sdetails
#220.06 sdetails
#230.06 sdetails

Code

import sys
from collections import deque

def solve():
    n, x = map(int, input().split())
    array = list(map(int, input().split()))
    array.sort()
    
    for i in range(len(array)):
        left = 0
        right = len(array)
        sum_value = 0
        
        while left != right:
            sum_value = array[left] + array[right] + array[i]
            
            if sum_value == x: # Value found
                #Check that there is not overlapping
                if left == i:
                    left += 1
                elif right == i:
                    right -= 1
                # Else correct solution
                else: 
                    print(f"{array[left]} {array[right]} {array[i]}")
                    return
                    
            else: 
                
                if sum_value > x:
                    right -= 1
                else:
                    left += 1
                
    print("IMPOSSIBLE")
    
    return
        
                

            
        
        
        
        
        
    
    

    


if __name__ == '__main__':
    solve()

Test details

Test 1

Verdict:

input
1 3
1

correct output
IMPOSSIBLE

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 54, in <module>
    solve()
  File "/box/input/code.py", line 15, in solve
    sum_value = array[left] + array[right] + array[i]
IndexError: list index out of range

Test 2

Verdict:

input
3 5
1 3 2

correct output
IMPOSSIBLE

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 54, in <module>
    solve()
  File "/box/input/code.py", line 15, in solve
    sum_value = array[left] + array[right] + array[i]
IndexError: list index out of range

Test 3

Verdict:

input
3 6
1 3 2

correct output
1 3 2

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 54, in <module>
    solve()
  File "/box/input/code.py", line 15, in solve
    sum_value = array[left] + array[right] + array[i]
IndexError: list index out of range

Test 4

Verdict:

input
3 7
3 2 1

correct output
IMPOSSIBLE

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 54, in <module>
    solve()
  File "/box/input/code.py", line 15, in solve
    sum_value = array[left] + array[right] + array[i]
IndexError: list index out of range

Test 5

Verdict:

input
7 3
2 1 1 2 2 1 1

correct output
2 3 7

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 54, in <module>
    solve()
  File "/box/input/code.py", line 15, in solve
    sum_value = array[left] + array[right] + array[i]
IndexError: list index out of range

Test 6

Verdict:

input
7 4
1 1 2 2 1 2 1

correct output
1 2 6

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 54, in <module>
    solve()
  File "/box/input/code.py", line 15, in solve
    sum_value = array[left] + array[right] + array[i]
IndexError: list index out of range

Test 7

Verdict:

input
7 5
1 2 1 2 2 1 1

correct output
1 2 5

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 54, in <module>
    solve()
  File "/box/input/code.py", line 15, in solve
    sum_value = array[left] + array[right] + array[i]
IndexError: list index out of range

Test 8

Verdict:

input
7 6
2 1 1 1 1 2 2

correct output
1 6 7

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 54, in <module>
    solve()
  File "/box/input/code.py", line 15, in solve
    sum_value = array[left] + array[right] + array[i]
IndexError: list index out of range

Test 9

Verdict:

input
5000 3
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

correct output
1 2 5000

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 54, in <module>
    solve()
  File "/box/input/code.py", line 15, in solve
    sum_value = array[left] + array[right] + array[i]
IndexError: list index out of range

Test 10

Verdict:

input
5000 4
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

correct output
IMPOSSIBLE

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 54, in <module>
    solve()
  File "/box/input/code.py", line 15, in solve
    sum_value = array[left] + array[right] + array[i]
IndexError: list index out of range

Test 11

Verdict:

input
5000 6
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

correct output
714 3518 4240

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 54, in <module>
    solve()
  File "/box/input/code.py", line 15, in solve
    sum_value = array[left] + array[right] + array[i]
IndexError: list index out of range

Test 12

Verdict:

input
5000 919900245
663612758 9075403 585385629 98...

correct output
2787 465 2266

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 54, in <module>
    solve()
  File "/box/input/code.py", line 15, in solve
    sum_value = array[left] + array[right] + array[i]
IndexError: list index out of range

Test 13

Verdict:

input
5000 999989608
12983 25966 38949 51932 64915 ...

correct output
IMPOSSIBLE

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 54, in <module>
    solve()
  File "/box/input/code.py", line 15, in solve
    sum_value = array[left] + array[right] + array[i]
IndexError: list index out of range

Test 14

Verdict:

input
5000 1000000000
65536 131072 196608 262144 327...

correct output
IMPOSSIBLE

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 54, in <module>
    solve()
  File "/box/input/code.py", line 15, in solve
    sum_value = array[left] + array[right] + array[i]
IndexError: list index out of range

Test 15

Verdict:

input
5000 642700000
6427 12854 19281 25708 32135 3...

correct output
IMPOSSIBLE

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 54, in <module>
    solve()
  File "/box/input/code.py", line 15, in solve
    sum_value = array[left] + array[right] + array[i]
IndexError: list index out of range

Test 16

Verdict:

input
5000 919900246
663612758 9075403 585385629 98...

correct output
193 1698 4019

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 54, in <module>
    solve()
  File "/box/input/code.py", line 15, in solve
    sum_value = array[left] + array[right] + array[i]
IndexError: list index out of range

Test 17

Verdict:

input
5000 919900247
663612758 9075403 585385629 98...

correct output
4258 470 1911

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 54, in <module>
    solve()
  File "/box/input/code.py", line 15, in solve
    sum_value = array[left] + array[right] + array[i]
IndexError: list index out of range

Test 18

Verdict:

input
5000 6
6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 ...

correct output
4998 4999 5000

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 54, in <module>
    solve()
  File "/box/input/code.py", line 15, in solve
    sum_value = array[left] + array[right] + array[i]
IndexError: list index out of range

Test 19

Verdict:

input
5000 919900247
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

correct output
IMPOSSIBLE

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 54, in <module>
    solve()
  File "/box/input/code.py", line 15, in solve
    sum_value = array[left] + array[right] + array[i]
IndexError: list index out of range

Test 20

Verdict:

input
4999 919900245
9075403 585385629 987230075 83...

correct output
2786 464 2265

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 54, in <module>
    solve()
  File "/box/input/code.py", line 15, in solve
    sum_value = array[left] + array[right] + array[i]
IndexError: list index out of range

Test 21

Verdict:

input
5000 1000000000
261323261 25262018 237798562 3...

correct output
IMPOSSIBLE

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 54, in <module>
    solve()
  File "/box/input/code.py", line 15, in solve
    sum_value = array[left] + array[right] + array[i]
IndexError: list index out of range

Test 22

Verdict:

input
5000 76305003
1 5088 10175 15262 20349 25436...

correct output
IMPOSSIBLE

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 54, in <module>
    solve()
  File "/box/input/code.py", line 15, in solve
    sum_value = array[left] + array[right] + array[i]
IndexError: list index out of range

Test 23

Verdict:

input
2 6
2 2

correct output
IMPOSSIBLE

user output
(empty)

Error:
Traceback (most recent call last):
  File "/box/input/code.py", line 54, in <module>
    solve()
  File "/box/input/code.py", line 15, in solve
    sum_value = array[left] + array[right] + array[i]
IndexError: list index out of range