Skip to content

Instantly share code, notes, and snippets.

@andreuinyu
Last active January 18, 2016 20:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andreuinyu/cff77a19ed109effe62e to your computer and use it in GitHub Desktop.
Save andreuinyu/cff77a19ed109effe62e to your computer and use it in GitHub Desktop.
#include <iostream>
#include <vector>
using namespace std;
struct p{
int a;
int b;
};
p mam(int x, vector<int>& v){
int i=0, f=v.size()-1;
p q;
while (true){
int S=v[i]+v[f];
if (S==x){
q.a=v[i];
q.b=v[f];
return q;
}
if (S > x) f--;
if (S < x) i++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment