fork download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cmath>
  4. #include <algorithm>
  5. #include <bits/stdc++.h>
  6. #include <set>
  7. #include <ext/pb_ds/assoc_container.hpp>
  8. #include <ext/pb_ds/tree_policy.hpp>
  9. #include <map>
  10. #define ll long long
  11. using namespace __gnu_pbds;
  12. using namespace std;
  13. template <class T>
  14. using ordered_set = tree<T , null_type , less<T> , rb_tree_tag , tree_order_statistics_node_update>;
  15. template <class T>
  16. using ordered_set1 = tree<T , null_type , greater<T> , rb_tree_tag , tree_order_statistics_node_update>;
  17. // less<T>/greater<T> = ascending/descending.
  18. // less_equal<>/greater_equal<> for ordered multiset
  19. // ordered_multiset note : s.find(), s.erase() don't work + s.upper_bound() and s.lower_bound() swap jobs;
  20. void fastIO(void) {
  21. ios_base::sync_with_stdio(false);
  22. cin.tie(NULL);
  23. cout.tie(NULL);
  24. }
  25. int main() {
  26. fastIO();
  27. ll n,sum; cin>>n>>sum;
  28. vector<ll> v(n+1);
  29. for (ll i = 1; i<=n; i++){cin>>v[i];}
  30. ll l,r,flag=0;
  31.  
  32. for (l = 1; l<n; l++) {
  33. r=l+1;
  34. while (r<=n) {
  35. if (v[l]+v[r]==sum) {
  36. flag = 1;
  37. }
  38. if (flag){break;}
  39. r++;
  40. }
  41. if (flag){break;}
  42. }
  43. if (flag) {
  44. cout<<l<<' '<<r;
  45. }
  46. else {
  47. cout<<"IMPOSSIBLE";
  48. }
  49. }
Success #stdin #stdout 0s 5320KB
stdin
4 8
2 7 5 1
stdout
2 4