Pagini recente » Cod sursa (job #2096115) | Cod sursa (job #443471) | Cod sursa (job #3269151) | Cod sursa (job #2557900) | Cod sursa (job #2980188)
/// [A][M][C][B][N] ///
#include <bits/stdc++.h>
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const char sp = ' ', nl = '\n';
using namespace std;
ifstream fin("loto.in");
ofstream fout("loto.out");
struct foo {
int s, a, b, c;
};
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n, s;
fin >> n >> s;
vector<int> v(n);
for (auto& x : v) {
fin >> x;
}
vector<foo> w(n * n * n);
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
for (int k = 0; k < n; ++k) {
w[i * n * n + j * n + k] = { v[i] + v[j] + v[k], i, j, k };
}
}
}
sort(w.begin(), w.end(), [&](const foo& a, const foo& b) {
return a.s < b.s;
});
int i = 0, j = w.size() - 1;
while (i < j) {
if (w[i].s + w[j].s < s) {
i++;
}
else if (w[i].s + w[j].s > s) {
j--;
}
else {
fout << v[w[i].a] << sp
<< v[w[i].b] << sp
<< v[w[i].c] << sp
<< v[w[j].a] << sp
<< v[w[j].b] << sp
<< v[w[j].c];
return 0;
}
}
fout << -1;
}