Pagini recente » Cod sursa (job #1214173) | Cod sursa (job #1074926) | Cod sursa (job #1911188) | Cod sursa (job #309277) | Cod sursa (job #2546134)
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("loto.in");
ofstream fout ("loto.out");
int n, s;
int v[105];
struct sasecinci{
int x, y, z;
};
unordered_map <int, sasecinci> mep;
int main(){
fin >> n >> s;
for (int i=1; i<=n; i++){
fin >> v[i];
}
for (int i=1; i<=n; i++){
for (int j=i; j<=n; j++){
for (int k=j; k<=n; k++){
if (mep.find (v[i] + v[j] + v[k]) == mep.end()){
mep[v[i] + v[j] + v[k]] = {v[i], v[j], v[k]};
}
}
}
}
for (auto it : mep){
if (mep.find (s - it.first) != mep.end()){
fout << it.second.x << " " << it.second.y << " " << it.second.z << " " << mep[s - it.first].x << " " << mep[s - it.first].y << " " << mep[s - it.first].z;
return 0;
}
}
fout << -1;
return 0;
}