Algorithms and Data Structures

  • Profound Academy

    • Status
      • 1
        Implementation
      • 2
        Bitwise operations
      • 3
        Prefix Sums
      • 4
        Sliding window / Two pointers
      • 5
        Modular Arithmetic
      • 6
        Number Theory
      • 7
        Binary Search
      • 8
        Basic Sorting
      • 9
        Greedy Algorithms
      • 10
        Basic Dynamic Programming
      • 11
        Recursion
      • 12
        Linked LIst
      • 13
        Queue & Stack
      • 14
        Binary tree + BST
      • 15
        Divide & Conquer + Advanced Sorting
      • 16
        Heap
      • 17
        Hashing
      • 18
        Graph Representation
      • 19
        BFS

  • Sum of three values

    Given n integers and a target value T, you are asked if there are 3 values that sum up to the target value T.

    Input

    The input contains two integers n (2 ≤ n ≤ 1000) and T (1 ≤ T ≤ ).
    The next line contains n space-separated integers.

    Output

    The program should print the positions of those 3 values (indexing starts from 0) and Impossible in case it’s not possible to find such 3 values. In case of several solutions, the program may print any of those.

    Examples

    Input
    Output
    5 2 4 1 0 2 -1
    1 3 4

    Explanation

    2 = 1 + 2 - 1 ⇒ position of 1 is 1, position of2 is 3, and the position of -1 is 4
     

    Constraints

    Time limit: 4 seconds

    Memory limit: 512 MB

    Output limit: 1 MB

    To check your solution you need to sign in
    Sign in to continue