Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- .@@@@@@@@ @@@ @@ @@
- ,@@@@@@ @@ .@@@ @@ @@@ @@@%@@@@. @@@ @@ @@ @@@@/ @@@
- /& @@@@ @@@ *@@@ @@@# @@@&@@@ @@@@@@@#&@@ @@@%&, @@ @@@@ @@@@ @@@&
- @@@ .@@@ /@%@ @@@ @@@@ @@& .@@@ @@&&&@ @@ @@@@ (@@@@ @@@@
- %@@@@@@& /&&& %@& @&@ @& @&@& &&@#%@%. &@@ &@&# %@@@@@@
- @@@@@ /@&%(%&@@@&@ @&& ,@@ @@&&@@&@@@ &@@ /@@&/ @@, @@@/ %@@@(
- @@@. *@@@@#, @@@ @@@ ,@@ @@@. @@@ @@@@@@@ %@@/ @@@@@@%
- @@@ *@@% @@@ @@@@@@# @@@@@@@@@@ @@@ ,@@@@ @@& .@@@ @@@@
- &@@, @@% @@ @@@ @@ @@@
- &*
- */
- #include <bits/stdc++.h>
- // #include "phoenix.h"
- #define ceil(n, m) (((n) / (m)) + ((n)%(m) ? 1 : 0))
- #define endl "\n"
- #define NumOfDig(n) log10(n) + 1
- #define MOD 1000000007
- #define INF 2000000000
- #define Time cerr << "Time Taken: " << (float)clock() / CLOCKS_PER_SEC << " Secs" << "\n";
- #define EPS 1e-9
- #define PI1 acos(-1)
- #define PI2 3.141592653
- #define all(s) s.begin(), s.end()
- #define rall(s) s.rbegin(), s.rend()
- #define getline(s) getline(cin >> ws, s)
- using namespace std;
- typedef long long ll;
- typedef unsigned long long ull;
- /**
- * @author MiinaMagdy 😌🙋♂️
- * @remark Time limit - memory limit (efficiency)
- * @remark (OVERFLOW) long long
- * @remark (CORNER) test case
- * @remark division by (ZERO) || Out of array's (RANGE)
- * @remark use logarithm if you want to compare two products
- */
- void phoenix()
- {
- ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
- #endif
- Time
- }
- struct Number
- {
- ll value, index;
- };
- int main(void)
- {
- phoenix();
- int testcases = 1;
- // cin >> testcases;
- while (testcases--)
- {
- ll n, x;
- cin >> n >> x;
- vector<Number> nums(n);
- for (int i = 0; i < n; i++)
- {
- cin >> nums[i].value;
- nums[i].index = i + 1;
- }
- sort(nums.begin(), nums.end(), [](Number a, Number b) -> bool
- {
- if (a.value == b.value) return a.index < b.index;
- return a.value < b.value;
- });
- // for (auto & i : nums) cout << i.value << " ";
- for (ll i = 0; i < n - 2; i++)
- {
- ll sum = nums[i].value;
- ll l = i + 1, r = n - 1;
- while (l < r)
- {
- if (sum + nums[l].value + nums[r].value == x) return cout << nums[i].index << " " << nums[l].index << " " << nums[r].index, 0;
- if (sum + nums[l].value + nums[r].value > x) r--;
- else if (nums[l].value + nums[r].value + sum < x) l++;
- }
- }
- return cout << "IMPOSSIBLE", 0;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment