Pagini recente » Cod sursa (job #2650891) | Cod sursa (job #824629) | Cod sursa (job #87597) | Cod sursa (job #746327) | Cod sursa (job #2745984)
#include <bits/stdc++.h>
using namespace std;
ifstream in("loto.in");
ofstream out("loto.out");
struct rasp
{
int primul;
int alDoilea;
int alTreilea;
};
int n, s;
int v[101];
unordered_map <int, rasp> m;
int main()
{
in>>n>>s;
for(int i = 1; i <= n; i++)
in>>v[i];
for(int i = 1; i <= n; i++)
{
for(int j = i; j <= n; j++)
{
for(int q = j; q <= n; q++)
{
int scurent = v[i]+v[j]+v[q];
m[scurent].primul = v[i];
m[scurent].alDoilea = v[j];
m[sc].alTreilea = v[q];
if(m.find(s-scurent) != m.end())
{
out << v[i] << " " << v[j] << " " <<v[q] << " " << m[s-scurent].primul << " " << m[s-scurent].alDoilea << " " << m[s-scurent].alTreilea;
return 0;
}
}
}
}
out << -1;
return 0;
}