Pagini recente » Cod sursa (job #2649229) | Cod sursa (job #2067836) | Cod sursa (job #1143006) | Cod sursa (job #452128) | Cod sursa (job #2982051)
#include<fstream>
#include<unordered_map>
#include<vector>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
ifstream cin("loto.in");
ofstream cout("loto.out");
struct info
{
int a = -1,b = -1,c = -1;
};
gp_hash_table<int,info> m;
gp_hash_table<int,bool> avem;
int main()
{
int n,s; cin >> n >> s;
vector<int> v(n); for(auto &it : v) cin >> it;
for(int i = 0; i < n ; i++)
{
for(int j = 0 ; j < n ; j++)
{
for(int k = 0 ; k < n ; k++)
{
int suma = v[i] + v[j] + v[k];
if(avem[suma]) continue;
m[suma] = {i,j,k};
avem[suma] = 1;
}
}
}
for(int i = 0; i < n ; i++)
{
for(int j = 0 ; j < n ; j++)
{
for(int k = 0 ; k < n ; k++)
{
int suma = v[i] + v[j] + v[k];
if(s - suma < 3) continue;
if(!avem[s - suma]) continue;
info one = m[s - suma];
cout << v[i] << " " << v[j] << " " << v[k] << " " << v[one.a] << " " << v[one.b] << " " << v[one.c];
return 0;
}
}
}
cout << -1;
}