Pagini recente » Cod sursa (job #1288283) | Cod sursa (job #2036860) | Istoria paginii runda/knird/clasament | Cod sursa (job #1090645) | Cod sursa (job #1284338)
#include<fstream>
#include<unordered_map>
using namespace std;
struct vect
{
int a,b,c;
}x;
int n,i,j,k,rez,sum,temp;
int v[105];
unordered_map<int,vect >mymap;
unordered_map<int,vect > :: iterator it;
int main()
{
ifstream f("loto.in");
ofstream g("loto.out");
f>>n>>sum;
for (i=1;i<=n;i++)
f>>v[i];
for (i=1;i<=n;i++)
for(j=1;j<=n;j++)
for(k=1;k<=n;k++)
{
temp=v[i]+v[j]+v[k];
x.a=v[i],x.b=v[j],x.c=v[k];
mymap[temp]=x;
}
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
for(k=1;k<=n;k++)
{
temp=sum-v[i]-v[j]-v[k];
it=mymap.find(temp);
if (it!=mymap.end())
{
g<<v[i]<<" "<<v[j]<<" "<<v[k]<<" ";
g<<it->second.a<<" "<<it->second.b<<" "<<it->second.c<<"\n";
return 0;
}
}
g<<"-1\n";
return 0;
}