Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- int main() {
- int n, k;
- cin >> n >> k;
- int a[n];
- int b[n];
- for(int i=0;i<n;i++) {
- cin >> a[i];
- b[i]=a[i];
- }
- sort(b,b+n);
- bool ans=false;
- int x, p, i;
- for(i=0;i<n;i++) {
- p=k-b[i];
- if(binary_search(b,b+n,p)) {
- x=b[i];
- ans=true;
- break;
- }
- }
- int q, w;
- if(!ans) {
- cout << "IMPOSSIBLE";
- }
- else{
- for(int i=0;i<n;i++) {
- if(a[i]==x||a[i]==p) {
- q=i+1;
- }
- }
- for(int i=n-1;i>=0;i--) {
- if(a[i]==x||a[i]==p) {
- w=i+1;
- }
- }
- if(q==w) {
- cout << "IMPOSSIBLE";
- }
- else{
- cout << min(q,w) << ' ' << max(q,w);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement