Pagini recente » Cod sursa (job #2475997) | Cod sursa (job #2092800) | Cod sursa (job #690181) | Cod sursa (job #830739) | Cod sursa (job #2661557)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("loto.in");
ofstream fout("loto.out");
inline void max_self(int& a, int b) {
a = max(a, b);
}
int N, S;
vector < int > a, sol(6);
void Back(int k) {
for(int x : a) {
sol[k] = x;
if(k == 5) {
int sum = 0;
for(int i = 0; i < 6; ++i)
sum += sol[i];
if(sum == S) {
for(int v : sol)
fout << v << ' ';
exit(0);
}
}
else
Back(k + 1);
}
}
int main() {
fin.sync_with_stdio(false);
fout.sync_with_stdio(false);
fin.tie(nullptr);
fout.tie(nullptr);
fin >> N >> S;
a.resize(N);
int mx = 0;
for(int& x : a) {
fin >> x;
max_self(mx, x);
}
if(mx * 6 < S) {
fout << -1;
return 0;
}
Back(0);
fout << -1;
}