#TP0000046. Tổng của ba giá trị (Sum of Three Values)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Tổng của ba giá trị (Sum of Three Values)
Sum of Three Values
Source: CSES
Version: Phuoc Hung OJ Extended
Problem Statement
You are given positive integers and a positive integer . The array positions are numbered from to .
Find three pairwise distinct positions satisfying
You may print the positions in any order. If several valid triples exist, output any one of them. If no valid triple exists, print IMPOSSIBLE.
Input
- The first line contains two integers and , denoting the array length and the target sum.
- The second line contains exactly positive integers in positional order.
Output
If a solution exists, print three distinct indices from through , separated by spaces, whose corresponding values sum to . Otherwise, print exactly IMPOSSIBLE.
Subtasks
- Subtask 1 (20 points): ; ; for every .
- Subtask 2 (30 points): ; ; for every .
- Subtask 3 (50 points): ; ; for every .
Examples
Input
4 8
2 7 5 1
Output
4 1 3
Explanation
The four array values are , and the target is . Positions , , and contain , , and . Their sum is , so this triple is valid. Position need not be selected. Other orders of the same three positions are also accepted.