Pagini recente » Cod sursa (job #1099844) | Cod sursa (job #2108872) | Cod sursa (job #2975891) | Cod sursa (job #1153357) | Cod sursa (job #2823159)
#include <bits/stdc++.h>
using namespace std;
class innput
{
private:
FILE *fin;
char *buff;
int sp;
char read_ch()
{
++sp;
if(sp==4096)
{
sp=0;
fread(buff,1,4096,fin);
}
return buff[sp];
}
public:
innput(const char* nume)
{
fin=fopen(nume,"r");
buff=new char[4096]();
sp=4095;
}
innput& operator >> (int &n)
{
char c;
while(!isdigit(c=read_ch())&&c!='-');
int sgn=1;
if (c=='-')
{
n=0;
sgn=-1;
}
else
{
n=c-'0';
}
while(isdigit(c=read_ch()))
{
n=10*n+c-'0';
}
n*=sgn;
return *this;
}
innput& operator >> (long long &n)
{
char c;
n=0;
while(!isdigit(c=read_ch())&&c!='-');
long long sgn=1;
if(c=='-')
{
n=0;
sgn=-1;
}
else
{
n=c-'0';
}
while(isdigit(c=read_ch()))
{
n=10*n+c-'0';
}
n*=sgn;
return *this;
}
};
class output
{
private:
FILE *fout;
char *buff;
int sp;
void write_ch(char ch)
{
if(sp==20)
{
fwrite(buff,1,20,fout);
sp=0;
buff[sp++]=ch;
}
else
{
buff[sp++]=ch;
}
}
public:
output(const char* name)
{
fout=fopen(name,"w");
buff=new char[20]();
sp=0;
}
~output()
{
fwrite(buff,1,sp,fout);
fclose(fout);
}
output& operator <<(int vu32)
{
if(vu32<=9)
{
write_ch(vu32+'0');
}
else
{
(*this) <<(vu32/10);
write_ch(vu32%10+'0');
}
return *this;
}
output& operator <<(long long vu64)
{
if(vu64<=9)
{
write_ch(vu64+'0');
}
else
{
(*this) <<(vu64/10);
write_ch(vu64%10+'0');
}
return *this;
}
};
///
template<int n,typename T>
class f
{
public:
T a[n];
};
unordered_map <int , f<3,int>> mp;
innput fin("loto.in");
output fout("loto.out");
int main()
{
int n,s;
cin>>n>>s;
const int n2=n;
int a[n];
for(int i=0;i<n;i++)
{
fin>>a[i];
}
for(int i=0;i<n;i++)
{
for(int j=i;j<n;j++)
{
for(int k=j;k<n;k++)
{
mp[a[i]+a[j]+a[k]]={a[i],a[j],a[k]};
}
}
}
for(int i=0;i<n;i++)
{
for(int j=i;j<n;j++)
{
for(int k=j;k<n;k++)
{
const int x=s-a[i]-a[j]-a[k];
if(mp.find(x)!=mp.end())
{
fout<<a[i]<<" "<<mp[x].a[0]<<" "<<a[j]<<" "<<mp[x].a[1]<<" "<<a[k]<<" "<<mp[x].a[2];
return 0;
}
}
}
}
fout<<"-1";
return 0;
}