Pagini recente » Cod sursa (job #2696634) | Cod sursa (job #2710222) | Cod sursa (job #303402) | Cod sursa (job #1644065) | Cod sursa (job #2744455)
#include <fstream>
#include <unordered_map>
using namespace std;
ifstream f("loto.in");
ofstream g("loto.out");
struct numere
{
int nr1,nr2,nr3;
};
unordered_map <int, numere> h;
int main()
{
int n,s;
f>>n>>s;
int v[100];
for(int i=0;i<n;i++)
f>>v[i];
for(int i=0;i<n;i++)
for(int j=i;j<n;j++)
for(int k=j;k<n;k++)
{
numere obiect;
obiect.nr1=v[i];
obiect.nr2=v[j];
obiect.nr3=v[k];
h[v[i]+v[j]+v[k]]=obiect;
}
for(auto i=h.begin(); i!=h.end();i++)
{
int rest=s-i->first;
if(h.find(rest)!=h.end())
{
g<<i->second.nr1<<' '<<i->second.nr2<<' '<<i->second.nr3<<' '<<h[rest].nr1<<' '<<h[rest].nr2<<' '<<h[rest].nr3;
return 0;
}
}
g<<"-1";
return 0;
}