Pagini recente » Cod sursa (job #659064) | Cod sursa (job #3152645) | Cod sursa (job #1207187) | Cod sursa (job #885222) | Cod sursa (job #2227047)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("loto.in");
ofstream fout("loto.out");
int v[101];
map <int, vector<int>> hashh[1000000];
void insertt(int a, int b, int c, int d){
int modulo = a % 1000000;
for(auto y: hashh[modulo])
if(y.first == a) return;
hashh[modulo][a].push_back(b);
hashh[modulo][a].push_back(c);
hashh[modulo][a].push_back(d);
}
bool isIn(int x, int i, int j, int k){
int modulo = x % 1000000;
for(auto current : hashh[modulo]){
if(current.first == x){
for(auto y : current.second){
fout << v[y] << " " ;
}
fout << v[i] << " " << v[j] << " " << v[k];
return true;
}
}
return false;
}
int main(){
int n;
long long S;
fin >> n >> S;
for(int i = 1; i <= n; ++i){
fin >> v[i];
}
for(int i = 1; i <= n; ++i){
for(int j = 1; j <= n; ++j){
for(int k = 1; k <= n; ++k){
long long s = 1LL * v[i] + v[j] + v[k];
if(s > S)
continue;
insertt(s, i, j, k);
int dif = S - s;
if(isIn(dif, i, j, k))
return 0;
}
}
}
fout << "-1";
return 0;
}