Pagini recente » Cod sursa (job #2963562) | Cod sursa (job #1765399) | Cod sursa (job #954377) | Cod sursa (job #2553427) | Cod sursa (job #2457660)
#pragma optmize GCC("O3")
#include <iostream>
#include <fstream>
#include <map>
#include <unordered_map>
using namespace std;
ifstream fin("loto.in");
ofstream fout("loto.out");
int N, M;
int arr[110];
struct sol {
int x1, x2, x3;
};
unordered_map<int, sol> sum;
int main() {
sum.reserve(1000010);
fin >> N >> M;
for (int i = 1; i <= N;i++) fin >> arr[i];
for (int i = 1; i <= N;i++)
for (int j = i; j <= N;j++)
for (int k = j; k <= N;k++) {
sum[ arr[i] + arr[j] + arr[k] ] = {arr[i], arr[j], arr[k]};
}
for (auto it: sum) {
if (sum.count(M - it.first)) {
fout << it.second.x1 << " " << " " << it.second.x2 << " " << it.second.x3 << " ";
sol sol2 = sum[M-it.first];
fout << sol2.x1 << " " << sol2.x2 << " " <<sol2.x3;
return 0;
}
}
fout << "-1";
return 0;
}