Pagini recente » Cod sursa (job #3188920) | Cod sursa (job #3275014) | Cod sursa (job #1117384) | Cod sursa (job #2968770) | Cod sursa (job #2661560)
#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 {
int sum = 0;
for(int i = 0; i <= k; ++i)
sum += sol[i];
if(sum < S)
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);
for(int& x : a)
fin >> x;
sort(a.begin(), a.end(), greater<int>());
if(*a.begin() * 6 < S) {
fout << -1;
return 0;
}
Back(0);
fout << -1;
}