Pagini recente » Cod sursa (job #1728309) | Cod sursa (job #2724933) | Cod sursa (job #1442593) | Cod sursa (job #3175841) | Cod sursa (job #2406719)
#include<bits/stdc++.h>
#define N 120
#define ll long long
using namespace std;
struct lol {
int x,y,z;
};
int n,s;
int a[N];
map<int, lol>M;
ofstream fout("loto.out");
void out(lol p, lol q) {
multiset<int>S={a[p.x],a[p.y],a[p.z],a[q.x],a[q.y],a[q.z]};
for (auto it:S) fout<<it<<" ";
}
int main() {
ifstream cin("loto.in");
cin>>n>>s;
for (int i=1; i<=n; ++i) cin>>a[i];
for (int i=1; i<=n; ++i) {
for (int j=i; j<=n; ++j) {
for (int k=j; k<=n; ++k) {
int s1=a[i]+a[j]+a[k];
M[s1]={i,j,k};
}
}
}
for (int i=1; i<=n; ++i) {
for (int j=i; j<=n; ++j) {
for (int k=j; k<=n; ++k) {
int s2=a[i]+a[j]+a[k];
int s3=s-s2;
if (s3<0) continue;
if (M.find(s3)!=M.end()) {
out(M[s3], {i,j,k});
return 0;
}
}
}
} fout<<"-1";
return 0;
}