Pagini recente » Cod sursa (job #3283392) | Cod sursa (job #2922614) | Cod sursa (job #3262568) | Cod sursa (job #2159825) | Cod sursa (job #2457654)
#include <iostream>
#include <fstream>
#include <map>
using namespace std;
ifstream fin("loto.in");
ofstream fout("loto.out");
int N, M;
int arr[110];
struct sol {
int x1, x2, x3;
};
map<int, sol> sum;
int main() {
fin >> N >> M;
for (int i = 1; i <= N;i++) fin >> arr[i];
for (int i = 1; i <= N;i++)
for (int j = 1; j <= N;j++)
for (int k = 1; k <= N;k++) {
sum[ arr[i] + arr[j] + arr[k] ] = {i,j,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;
}