Pagini recente » Cod sursa (job #298938) | Cod sursa (job #2276429) | Cod sursa (job #2214144) | Cod sursa (job #406725) | Cod sursa (job #2980176)
/// [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 + 1, j + 1, k + 1 };
}
}
}
map<int, int> mp;
for (int i = 0; i < w.size(); ++i) {
if (mp.count(s - w[i].s)) {
int j = mp[s - w[i].s];
fout << w[i].a << sp;
fout << w[i].b << sp;
fout << w[i].c << sp;
fout << w[j].a << sp;
fout << w[j].b << sp;
fout << w[j].c;
return 0;
}
mp[w[i].s] = i;
}
fout << -1;
}