Pagini recente » Monitorul de evaluare | Cod sursa (job #2472735) | Cod sursa (job #31048) | Cod sursa (job #2750545) | Cod sursa (job #1009602)
#include<iostream>
#include<fstream>
using namespace std;
int cmp(const void* x, const void* y){
if ((*(int*)x) > (*(int*)y)){
return 1;
}
return -1;
}
int main(){
ifstream f("loto.in");
ofstream o("loto.out");
int n = 0, s = 0;
int V[100];
f >> n >> s;
for (int i = 0; i < n; i++)
{
f>>V[i];
}
qsort(V, n, sizeof(int), cmp);
for (int i = 0; i < n; i++){
if (V[i] >= s){
continue;
}
for (int j = 0; j < n; j++){
if (V[i]+V[j] >= s){
continue;
}
for (int k = 0; k < n; k++){
if (V[i] + V[j]+V[k] >= s){
continue;
}
for (int l = 0; l < n; l++){
if (V[i] + V[j] + V[k]+V[l] >= s){
continue;
}
for (int m = 0; m < n; m++){
if (V[i] + V[j] + V[k] + V[l]+V[m] >= s){
continue;
}
for (int g = 0; g < n; g++){
int s1 = 0;
s1 = (V[i] + V[j] + V[k] + V[l] + V[m] + V[g]);
if (s1 == s){
o << V[i] << " " << V[j] << " " << V[k] << " " << V[l] << " " << V[m] << " " << V[g];
return 0;
}
else if (s1>s){
continue;
}
}
}
}
}
}
}
o << -1;
return 0;
}