Pagini recente » Cod sursa (job #1194065) | Cod sursa (job #273986) | Cod sursa (job #1402219) | Cod sursa (job #307274) | Cod sursa (job #1222019)
#include <stdio.h>
#include <unordered_map>
#define NMAX 101
#define llong long long
using namespace std;
struct three {
three(int zero, int one, int two) {
this->zero = zero;
this->one = one;
this->two = two;
}
llong get_sum() {
llong sum = 0;
sum += zero + one + two;
return sum;
}
int zero, one, two;
};
int numbers[NMAX];
unordered_map<llong, three> threes;
unordered_map<llong, three>::iterator it;
unordered_map<llong, three>::iterator sit;
int main() {
freopen("loto.in", "rt", stdin);
freopen("loto.out", "wt", stdout);
llong n, s;
scanf("%lld %lld\n", &n, &s);
for (int i = 0; i < n; i++) {
scanf("%d", &numbers[i]);
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
for (int k = 0; k < n; k++) {
three element(numbers[i], numbers[j], numbers[k]);
threes.insert(pair<llong, three>(element.get_sum(), element));
}
}
}
for (it = threes.begin(); it != threes.end(); it++) {
llong first_sum = it->first;
llong second_sum = s - first_sum;
sit = threes.find(second_sum);
if (sit != threes.end()) {
printf("%d %d %d %d %d %d\n", it->second.zero, it->second.one, it->second.two, sit->second.zero, sit->second.one, sit->second.two);
return 0;
}
}
printf("%d\n", -1);
return 0;
}