Pagini recente » Cod sursa (job #2487406) | Cod sursa (job #2899395) | Cod sursa (job #1539564) | Cod sursa (job #584047) | Cod sursa (job #2960995)
#include <bits/stdc++.h>
using namespace std;
ifstream f("loto.in");
ofstream g("loto.out");
struct triplu
{
long long a, b, c;
};
long long n, S, A[105];
map<long long, triplu> sum;
int main()
{
f >> n >> S;
for(long long i = 1; i <= n; i ++)
f >> A[i];
for(long long i = 1; i <= n; i ++)
for(long long j = 1; j <= n; j ++)
for(long long k = 1; k <= n; k ++)
sum[A[i] + A[j] + A[k]] = {A[i], A[j], A[k]};
for(long long i = 1; i <= n; i ++)
for(long long j = 1; j <= n; j ++)
for(long long k = 1; k <= n; k ++)
{
if(sum.count(S - (A[i] + A[j] + A[k])))
{
g << sum[S - (A[i] + A[j] + A[k])].a << " ";
g << sum[S - (A[i] + A[j] + A[k])].b << " ";
g << sum[S - (A[i] + A[j] + A[k])].c << " ";
g << A[i] << " " << A[j] << " " << A[k];
return 0;
}
}
g << -1;
return 0;
}