Pagini recente » Cod sursa (job #1958285) | Cod sursa (job #2135851) | Cod sursa (job #3126499) | Cod sursa (job #370527) | Cod sursa (job #1465674)
#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.insert(make_pair(p, x1));
el2.insert(make_pair(p, x2));
el3.insert(make_pair(p, 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;
}