Pagini recente » Cod sursa (job #850868) | Cod sursa (job #2794985) | Cod sursa (job #2290524) | Cod sursa (job #1315295) | Cod sursa (job #1465671)
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <cmath>
#include <climits>
#include <list>
#include <iomanip>
#include <cstdlib>
#include <fstream>
#include <map>
#include <algorithm>
using namespace std;
int main() {
freopen("loto.in", "r", stdin);
freopen("loto.out", "w", stdout);
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, s;
cin >> n >> s;
int* v = new int[n + 1];
for (int i = 1; i <= n; i++) {
cin >> v[i];
}
map<int, int> el1;
map<int, int> el2;
map<int, int> el3;
for (int x1 = 1; x1 <= n; x1++) {
for (int x2 = x1; x2 <= n; x2++) {
for (int x3 = x2; x3 <= n; x3++) {
int p = v[x1] + v[x2] + v[x3];
el1[p] = v[x1];
el2[p] = v[x2];
el3[p] = v[x3];
}
}
}
for (map<int, int>::iterator it = el1.begin(); it != el1.end(); it++) {
int k = it->first;
if (k + k > s) {
break;
}
int r = s - k;
map<int, int>::iterator jt = el1.find(r);
if (jt != el1.end()) {
cout << el1[k] << " " << el2[k] << " " << el3[k] << " ";
k = jt->first;
cout << el1[k] << " " << el2[k] << " " << el3[k] << " ";
return 0;
}
}
cout << -1;
return 0;
}