Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <fstream>
- using namespace std;
- int main()
- {
- int a;
- int b;
- cin >> a >> b;
- vector<int>v;
- vector<int>v2;
- for(int i=0; i<a; i++){
- int h;
- cin>>h;
- v2.push_back(h);
- v.push_back(h);
- }
- int i=0;
- int j=v.size()-1;
- sort(v.begin(),v.end());
- int a1=v[i];
- int b1=v[j];
- while(i<j){
- a1=v[i];
- b1=v[j];
- if(a1+b1==b){
- break;
- }
- if(a1 + b1 < b){
- i+=1;
- }
- else{
- j-=1;
- }
- }
- int brojac1=-1;
- int brojac2=-1;
- for(int i1=0; i1<v2.size(); i1++){
- if(v2[i1]==a1){
- brojac1=i1;
- break;
- }
- }
- for(int i = 0; i < v2.size(); i++) {
- if(v2[i] == b1 and i != brojac1) {
- brojac2 = i;
- break;
- }
- }
- if((a1 + b1 != b) or (brojac1==-1)or(brojac2==-1)){
- cout<<"IMPOSSIBLE";
- return 0;
- }
- cout<<brojac1 + 1<<" ";
- cout<<brojac2 + 1;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement