Pagini recente » Cod sursa (job #406403) | Cod sursa (job #1410960) | Cod sursa (job #1644011) | Cod sursa (job #2230350) | Cod sursa (job #2893610)
#include <fstream>
#include<unordered_map>
using namespace std;
ifstream fin("loto.in");
ofstream fout("loto.out");
struct pereche
{int x,y,z;}pereche1;
unordered_map<int,pereche> second;
int main()
{
int n,s,v[101],s1;
bool ok=false;
fin>>n>>s;
for(int i=1;i<=n;i++)
fin>>v[i];
for(int i=1;i<=n&&!ok;i++)
for(int j=i;j<=n&&!ok;j++)
for(int t=j;t<=n&&!ok;t++)
{
s1=v[i]+v[j]+v[t];
if(s>s1)
{
pereche1.x=v[i];
pereche1.y=v[j];
pereche1.z=v[t];
second[s1]=pereche1;
}
if(second.find(s-s1)!=second.end()&&ok==false&&s>s1)
{
fout<<v[i]<<" "<<v[j]<<" "<<v[t]<<" "<<second[s-s1].x<<" "<<second[s-s1].y<<" "<<second[s-s1].z;
ok=true;
}
}
if(ok==false)
fout<<"-1";
return 0;
}