Pagini recente » Cod sursa (job #1405596) | Cod sursa (job #1890708) | Cod sursa (job #2295035) | Cod sursa (job #459728) | Cod sursa (job #3336766)
#include <fstream>
#include <vector>
#include <unordered_map>
#include <array>
using namespace std;
ifstream fin("loto.in");
ofstream fout("loto.out");
int main() {
int N;
long long S;
fin>>N>>S;
vector<long long> a(N);
for (int i=0; i<N; i++) {
fin>>a[i];
}
unordered_map<long long, array<long long, 3>> m;
m.reserve(1000000);
for (int i=0; i<N; i++) {
for (int j=0; j<N; j++) {
for (int k=0; k<N; k++) {
long long sum=a[i]+a[j]+a[k];
if (m.find(sum)==m.end()) {
m[sum]={a[i],a[j],a[k]};
}
}
}
}
for (auto it=m.begin(); it!=m.end(); ++it) {
long long chud=it->first;
long long foid=S-chud;
if (m.find(foid)!=m.end()) {
auto t1=it->second;
auto t2=m[foid];
fout << t1[0]<<" "<<t1[1]<<" "<<t1[2]<<" "<<t2[0]<<" "<<t2[1]<<" "<<t2[2]<<endl;
return 0;
}
}
fout<<-1<<endl;
return 0;
}