Pagini recente » Cod sursa (job #102657) | Cod sursa (job #2356479) | Cod sursa (job #1694755) | Cod sursa (job #2332858) | Cod sursa (job #2841137)
#include <iostream>
#include <unordered_map>
using namespace std;
struct pereche {
int i = -1;
int j = -1;
int k = -1;
int sum = 0;
};
unordered_map<int, pereche> mp;
int main() {
freopen("loto.in", "r", stdin);
freopen("loto.out", "w", stdout);
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int N, S;
int nr[100];
cin >> N >> S;
for (int i = 1; i <= N; i++) {
cin >> nr[i];
}
for (int i = 1; i <= N; i++)
for (int j = 1; j <= N; j++)
for (int k = 1; k <= N; k++) {
pereche p;
p.i = nr[i];
p.j = nr[j];
p.k = nr[k];
p.sum = nr[i] + nr[j] + nr[k];
mp[p.sum] = p;
}
for (auto &entry : mp) {
int sum = entry.second.sum;
int sn = S - sum;
if (mp[sn].i != -1) {
{
cout << entry.second.i << " " << entry.second.j << " "
<< entry.second.k << " ";
cout << mp[sn].i << " " << mp[sn].j << " " << mp[sn].k << " ";
return 0;
}
}
}
cout << -1;
return 0;
}