Submission details
Task:3SUM
Sender:aalto26gm_019
Submission time:2026-10-19 16:36:07 +0300
Language:C++ (C++23)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:24:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   24 |     sort(arr.begin(), arr.end(), compare);
      |     ^~~~
      |     short

Code

#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

bool compare(const pair<int, int> &i, const pair<int, int> &j) {
    return i.first < j.first;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll n, x;
    cin >> n >> x;
    vector<pair<ll, int>> arr(n);
    for (int i = 0; i < n; i++) {
        ll val;
        cin >> val;
        arr[i] = {val, i};
    }

    sort(arr.begin(), arr.end(), compare);

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            for (int k = j + 1; k < n; k++) {

                ll sum = arr[i].first + arr[j].first + arr[k].first;

                if (sum > x) {
                    cout << "IMPOSSIBLE\n";
                    return 0;
                }

                if (sum == x) {
                    cout << arr[i].second + 1 << " " << arr[j].second + 1 << " "
                         << arr[k].second + 1 << "\n";
                    return 0;
                }
            }
        }
    }

    cout << "IMPOSSIBLE\n";
    return 0;
}