Pagini recente » Cod sursa (job #1470651) | Cod sursa (job #935884) | Cod sursa (job #1695498) | Cod sursa (job #1578795) | Cod sursa (job #130507)
Cod sursa(job #130507)
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
using namespace std;
int S(0),
N(0),
v[100];
int main(int argc, char *argv[]) {
ifstream fin("loto.in");
fin >> N >> S;
for (int i(0); i < N; ++i)
fin >> v[i];
fin.close();
map<int, vector<int> > sume;
for (int i(0); i < N; ++i)
for (int j(0); j < N; ++j)
for (int k(0); k < N; ++k)
if (sume.count(v[i] + v[j] + v[k]) == 0) {
vector<int> aux;
aux.push_back(v[i]);
aux.push_back(v[j]);
aux.push_back(v[k]);
sume.insert(pair<int, vector<int> >(v[i] + v[j] + v[k], aux));
}
for (map<int, vector<int> >::const_iterator it = sume.begin(); it != sume.end(); ++it)
if (sume.count(S - it->first)) {
ofstream fout("loto.out");
vector<int> aux = sume[S - it->first];
fout << it->second[0] << " " << it->second[1] << " " << it->second[2] << " "
<< aux[0] << " " << aux[1] << " " << aux[2] << endl;
fout.close();
return 0;
}
ofstream fout("loto.out");
fout << -1 << endl;
fout.close();
return 0;
}