Saleh127

CSES 1642

Apr 17th, 2021
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 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. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);
  9. cout.tie(0);
  10.  
  11.  
  12. ll n,m,i,j;
  13.  
  14. map<ll,pair<ll,ll>>x;
  15.  
  16. cin>>n>>m;
  17.  
  18. ll a[n+4];
  19. for(i=1; i<=n; i++)
  20. {
  21. cin>>a[i];
  22. }
  23.  
  24. for(i=1; i<=n; i++)
  25. {
  26. for(j=i+1; j<=n; j++)
  27. {
  28. if(x.find(m-a[i]-a[j])!=x.end())
  29. {
  30. cout<<i<<" "<<j<<" "<<x[m-a[i]-a[j]].first<<" "<<x[m-a[i]-a[j]].second<<endl;
  31. return 0;
  32. }
  33. }
  34. for(j=1; j<i; j++)
  35. {
  36. x[a[i]+a[j]]= {i,j};
  37. }
  38. }
  39.  
  40.  
  41. cout<<"IMPOSSIBLE"<<endl;
  42.  
  43. return 0;
  44. }
  45.  
Advertisement
Add Comment
Please, Sign In to add comment