PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#TP0000030. Tổng của hai giá trị (Sum of Two Values)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Tổng của hai giá trị (Sum of Two Values)
Sum of Two Values
Source: CSES
Version: Phuoc Hung OJ Extended
Problem Statement
You are given an array of integers and a target . Find two distinct positions and satisfying . Positions are numbered from in the original array. You may output any valid pair. If none exists, report that a solution is impossible.
Input
- The first line contains integers and : the array length and required sum.
- The second line contains exactly integers in their original order.
Output
Print any two distinct indices in such that , in either order. If no such pair exists, print IMPOSSIBLE.
Subtasks
- Subtask 1 (20 points): ; ; for all .
- Subtask 2 (30 points): ; ; for all .
- Subtask 3 (50 points): ; ; for all .
Examples
Input
4 8
2 7 5 1
Output
4 2
Explanation
The array is and the target is . Positions and hold and , respectively. Their sum is , and the indices differ, so 4 2 is valid.