Pagini recente » Cod sursa (job #2692500) | Cod sursa (job #2532023) | Cod sursa (job #2539463) | Cod sursa (job #448601) | Cod sursa (job #3130173)
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
ifstream fin("loto.in");
ofstream fout("loto.out");
int n, s;
fin >> n >> s;
vector<int> v(n);
for(int i = 0; i < n; i++) {
fin >> v[i];
}
sort(v.begin(), v.end());
bool found = false;
vector<int> ans;
for(int i = 0; i < n && !found; i++) {
for(int j = i; j < n && !found; j++) {
for(int k = j; k < n && !found; k++) {
for(int l = k; l < n && !found; l++) {
for(int m = l; m < n && !found; m++) {
for(int o = m; o < n && !found; o++) {
if(v[i] + v[j] + v[k] + v[l] + v[m] + v[o] == s) {
ans.push_back(v[i]);
ans.push_back(v[j]);
ans.push_back(v[k]);
ans.push_back(v[l]);
ans.push_back(v[m]);
ans.push_back(v[o]);
found = true;
}
}
}
}
}
}
}
if(found) {
for(int i = 0; i < 6; i++) {
fout << ans[i] << " ";
}
} else {
fout << -1;
}
fin.close();
fout.close();
return 0;
}