Pagini recente » Cod sursa (job #3255273) | Cod sursa (job #972765) | Cod sursa (job #1406404) | Cod sursa (job #2605838) | Cod sursa (job #3129377)
#include <bits/stdc++.h>
using namespace std;
ifstream f("loto.in");
ofstream g("loto.out");
const int NMAX = 105;
int n, S, a[NMAX];
map<int, vector<int>> mp;
int main(){
f >> n >> S;
for(int i = 1; i <= n; ++i){
f >> a[i];
}
for(int i = 1; i <= n; ++i){
for(int j = 1; j <= n; ++j){
for(int k = 1; k <= n; ++k){
mp[a[i] + a[j] + a[k]] = {a[i], a[j], a[k]};
}
}
}
bool ok = false;
for(int i = 1; i <= n; ++i){
for(int j = 1; j <= n; ++j){
for(int k = 1; k <= n; ++k){
int s = a[i] + a[j] + a[k];
if(mp.find(S - s) != mp.end()){
ok = true;
g << mp[S - s][0] << " " << mp[S - s][1] << " " << mp[S - s][2] << " " << a[i] << " " << a[j] << " " << a[k];
return 0;
}
}
}
}
if(!ok){
g << -1;
}
return 0;
}