Pagini recente » Cod sursa (job #3174867) | Cod sursa (job #899008) | Cod sursa (job #2577106) | Cod sursa (job #2664577) | Cod sursa (job #2748116)
#include <bits/stdc++.h>
using namespace std;
ifstream in("loto.in");
ofstream out("loto.out");
struct numere3
{
int x,y,z;
};
unordered_map <int, numere3> nrloto;
int v[101],n,s,ok,i,j,k;
int main()
{
in>>n>>s;
for(i=1; i<=n; i++)
in>>v[i];
for(i=1; i<=n; i++)
for(j=i; j<=n; j++)
for(k=j; k<=n; k++)
nrloto[v[i]+v[j]+v[k]]= {v[i],v[j],v[k]};
ok=0;
for(auto i:nrloto)
if(nrloto.find(s-i.first)!=nrloto.end())
{
out<<nrloto[s-i.first].x<<" "<<nrloto[s-i.first].y<<" "<<nrloto[s-i.first].z<< " " <<i.second.x<<" "<<i.second.y <<" "<<i.second.z;
ok=1;
break;
}
if(ok==0) out<<"-1";
return 0;
}