Pagini recente » Borderou de evaluare (job #2051291) | Cod sursa (job #298212) | Cod sursa (job #45552) | Cod sursa (job #1147573) | Cod sursa (job #2896473)
#include <iostream>
#include <fstream>
#include <vector>
#include <unordered_map>
using namespace std;
ifstream f ("loto.in");
ofstream g ("loto.out");
vector <int> v;
unordered_map<int, int[3]> loto;
int n, x, y, z;
long long s, s1, d;
int main() {
f >> n;
f >> s;
for(int i = 0; i < n; i++) {
int nr;
f >> nr;
v.push_back(nr);
}
for(x = 0; x < n; x++)
for(y = x; y < n; y++)
for(z = y; z < n; z++) {
s1 = v[x] + v[y] + v[z];
loto[s1][0] = v[x];
loto[s1][1] = v[y];
loto[s1][2] = v[z];
}
for(x = 0; x < n; x++)
for(y = x; y < n; y++)
for(z = y; z < n; z++) {
d = s - (v[x] + v[y] + v[z]);
if(loto.find(d) != loto.end()) {
g << v[x] << " " << v[y] << " " << v[z] << " " << loto[d][0] << " " << loto[d][1] << " " << loto[d][2];
return 0;
}
}
g << -1;
return 0;
}