Advertisement
Saleh127

CSES 1641

Apr 17th, 2021
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. vector<pair<ll,ll>>x;
  6. bool check(ll ind,ll ans)
  7. {
  8. ll i=ind+1;
  9. ll j=x.size()-1;
  10.  
  11. while(i<j)
  12. {
  13. ll xx=x[i].first+x[j].first;
  14.  
  15. if(xx==ans)
  16. {
  17. cout<<x[i].second<<" "<<x[j].second<<" "<<x[ind].second<<endl;
  18. return 1;
  19. }
  20. if(xx<ans) i++;
  21. if(xx>ans) j--;
  22. }
  23. return 0;
  24. }
  25.  
  26. int main()
  27. {
  28. ios_base::sync_with_stdio(0);
  29. cin.tie(0);cout.tie(0);
  30.  
  31.  
  32. ll n,m,i,j,k,l;
  33.  
  34. cin>>n>>m;
  35.  
  36. for(i=1;i<=n;i++)
  37. {
  38. cin>>k;
  39. x.push_back({k,i});
  40. }
  41.  
  42. sort(x.begin(),x.end());
  43.  
  44. for(i=0;i<n;i++)
  45. {
  46. k=m-x[i].first;
  47. if(check(i,k))
  48. {
  49. return 0;
  50. }
  51. }
  52.  
  53. cout<<"IMPOSSIBLE"<<endl;
  54.  
  55. return 0;
  56. }
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement