Pagini recente » Cod sursa (job #1739766) | Cod sursa (job #2283584) | Cod sursa (job #885656) | Cod sursa (job #1277296) | Cod sursa (job #1204775)
#include <fstream>
#include <set>
using namespace std;
struct P{
long long x;
int i,j,k;
bool operator<(const P& m) const{
return x<m.x;
}
bool operator==(const P& m) const{
return x==m.x;
}
};
int a[101];
set<P> S;
set<P>::iterator it,it1;
int main(){
ifstream f("loto.in");
ofstream g("loto.out");
int n,s;
f >> n >> s;
for(int i=1;i<=n;i++)
f >> a[i];
for(int i=1;i<=n;i++){
for(int j=i;j<=n;j++){
for(int k=j;k<=n;k++){
P y;
y.x=a[i]+a[j]+a[k];
y.i=a[i];
y.j=a[j];
y.k=a[k];
S.insert(y);
}
}
}
bool ok=0;
for(it=S.begin();it!=S.end();it++){
P y;
y.x=s-(it->x);
it1=S.find(y);
if(it1!=S.end()){
g << it->i <<" "<< it->j <<" "<< it->k <<" ";
g << it1->i <<" "<< it1->j <<" "<< it1->k << " ";
ok=1;
break;
}
}
if(!ok) g << -1;
}