Pagini recente » Cod sursa (job #2534921) | Cod sursa (job #3135937) | Cod sursa (job #750177) | Cod sursa (job #2032381) | Cod sursa (job #2667857)
/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <cstdio>
#include <iostream>
#include <map>
using namespace std;
struct half{
int a=-1,b,c;
};
map <int,half> m;
int main()
{
freopen("loto.in","r",stdin);
freopen("loto.out","w",stdout);
int n,v[101],ss;
cin>>n>>ss;
for(int i=0;i<n;i++)
{
cin>>v[i];
}
half x;
for(int i=0;i<n;i++)
{
x.a=v[i];
for(int j=i;j<n;j++)
{
x.b=v[j];
for(int y=j;y<n;y++)
{
x.c=v[y];
int s=x.a+x.b+x.c;
m[s]=x;
}
}
}
for(int i=0;i<n;i++)
{
x.a=v[i];
for(int j=i;j<n;j++)
{
x.b=v[j];
for(int y=j;y<n;y++)
{
x.c=v[y];
int s=ss-(x.a+x.b+x.c);
int sss=x.a+x.b+x.c;
if (m[s].a!=-1)
{
cout<<x.a<<' '<<x.b<<' '<<x.c<<' '<<m[s].a<<' '<<m[s].b<<' '<<m[s].c;
return 0;
}
}
}
}
cout<<-1;
return 0;
}