Pagini recente » Cod sursa (job #3230350) | Cod sursa (job #1996813) | Cod sursa (job #1850734) | Cod sursa (job #628810) | Cod sursa (job #3241026)
#include <bits/stdc++.h>
using namespace std;
const int NMAX = 102;
using tii = tuple<int, int, int>;
int n,s,a[NMAX];
unordered_map<int, tii> vf;
ifstream fin("loto.in");
ofstream fout("loto.out");
int main()
{
fin >> n >> s;
for(int i = 1; i <= n; i++){
fin >> a[i];
}
for(int i = 1; i <= n; i++){
for(int j = 1; j <= n; j++){
for(int k = 1; k <= n; k++){
int sum = a[i] + a[j] + a[k];
if(!vf.count(sum)){
vf[sum] = {a[i], a[j], a[k]};
}
}
}
}
for(auto [sum, t]: vf){
auto [a, b, c] = t;
int rem = s - sum;
if(vf.count(rem)){
auto [x, y, z] = vf[rem];
for(int it: {a, b, c, x, y, z}){
fout << it << " ";
}
exit(0);
}
}
fout << "-1";
return 0;
}