-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsum_of_two_values.py
More file actions
53 lines (44 loc) · 1.09 KB
/
sum_of_two_values.py
File metadata and controls
53 lines (44 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# =======================
# Python CP Template
# (bits/stdc++.h equivalent)
# =======================
import sys
# Fast I/O
input = sys.stdin.readline
# Common imports
from collections import defaultdict, deque, Counter
from itertools import combinations, permutations, product, accumulate
from functools import lru_cache, reduce
import heapq
import bisect
# Constants
INF = float('inf')
MOD = 10**9 + 7
# =======================
# Main Logic
# =======================
def solve():
arr = list(map(int,input().split()))
n,x = arr[0],arr[1]
arr = list(map(int,input().split()))
arr2 = [(y,x) for x,y in enumerate(arr)]
arr = arr2
arr2.sort()
i,j = 0,n-1
key = True
while i < j:
if arr[i][0]+arr[j][0] == x:
sys.stdout.write(str(arr[i][1]+1)+" "+str(arr[j][1]+1))
key = False
break
elif arr[i][0]+arr[j][0] < x:
i +=1
else:
j -=1
if key:
sys.stdout.write("IMPOSSIBLE")
# =======================
# Entry Point
# =======================
if __name__ == "__main__":
solve()