Pagini recente » Cod sursa (job #1418080) | Cod sursa (job #1419736) | Cod sursa (job #2442467) | Cod sursa (job #2299771) | Cod sursa (job #2732751)
#include <iostream>
#include <fstream>
#include <unordered_map>
#include <vector>
using namespace std;
ifstream f ("loto.in");
ofstream g ("loto.out");
unordered_map<unsigned int,vector<unsigned int>> dic;
unsigned int v[100];
int main()
{
int n;
unsigned int s;
f >> n >> s;
for (int i = 0; i < n; i++)
f >> v[i];
/*
for (int i = 0; i < n;i ++)
for (int j = 0; j < n; j++)
dic[v[i]+v[j]] = {v[i],v[j]};
for (auto p1: dic)
for (auto p2:dic){
if (dic.find(s-p1.first - p2.first) != dic.end()) {
auto test = dic[s-p1.first - p2.first];
g << p1.second.first << ' ' << p1.second.second << ' ' << p2.second.first << ' ' << p2.second.second << ' ' << test.first << ' ' << test.second;
return 0;
}
}
*/
for (int i = 0; i < n;i ++)
for (int j = 0; j < n; j++)
for (int k = 0; k < n; k++)
dic[v[i]+v[j]+v[k]] = vector<unsigned>{v[i],v[j],v[k]};
for (auto p1: dic)
if (dic.find(s-p1.first) != dic.end()) {
auto test = dic[s-p1.first];
g << p1.second[0] << ' ' << p1.second[1] << ' ' << p1.second[2] << ' ' << test[0] << ' ' << test[1] << ' ' << test[2];
return 0;
}
g << -1;
return 0;
}