Account
GitHubFeedback
Drafts and results saved on this device
Submit on CSES.fi
CSES Problemset/Sorting and Searching

Sum of Three Values

#1641
Ask AI

Open a hint-first prompt in a new AI chat. Grok may ask you to confirm before sending.

Open Claude Desktop

Time limit:1.00 s
Memory limit:512 MB
Unsolved
Download Tests (.zip)

You are given an array of nn integers, and your task is to find three values (at distinct positions) whose sum is xx.

Input

The first input line has two integers nn and xx: the array size and the target sum.

The second line has nn integers a1,a2,…,ana_1,a_2,\dots,a_n: the array values.

Output

Print three integers: the positions of the values. If there are several solutions, you may print any of them. If there are no solutions, print IMPOSSIBLE.

Constraints
  • 1≤n≤50001 \le n \le 5000
  • 1≤x,ai≤1091 \le x,a_i \le 10^9
Sample Test Cases (1)
Example 1ID: sample-1
Input
4 8
2 7 5 1
Expected Output
1 3 4
Tools
1
2
3
4
5
6
7
8
9
10
11
12
Draft saved locally
|1 line, 0 chars
Test Bench
Download .zip
Input (stdin)
4 8
2 7 5 1
Expected Output
1 3 4