Pagini recente » Cod sursa (job #725506) | Cod sursa (job #2664790) | Cod sursa (job #2520607) | Cod sursa (job #3240547) | Cod sursa (job #3280275)
#include <fstream>
#include <unordered_map>
using namespace std;
ifstream cin("loto.in");
ofstream cout("loto.out");
struct three{
int x, y, z;
};
int n, s, v[105];
unordered_map <int, three> mapa;
bool ok ;
int main()
{
cin >> n >> s;
for(int i = 1; i <= n; ++i)
cin >> v[i];
for(int i = 1; i <= n; ++i)
for(int j = 1; j <= n; ++j)
for(int k = 1; k <= n; ++k)
mapa[v[i] + v[j] + v[k]] = {v[i], v[j], v[k]};
for(int i = 1; i <= n; ++i) {
if(ok) break;
for(int j = 1; j <= n; ++j) {
if(ok) break;
for(int k = 1; k <= n; ++k) {
int remainder = s - (v[i] + v[j] + v[k]);
if(mapa.find(remainder) != mapa.end()) {
cout << v[i] << " " << v[j] << " " << v[k] << " " << mapa[remainder].x << " " << mapa[remainder].y <<" " << mapa[remainder].z;
ok = 1;
break;
}
}
}
}
if(!ok) cout << -1;
return 0;
}