Pagini recente » Cod sursa (job #1116711) | Monitorul de evaluare | Cod sursa (job #2512112) | Cod sursa (job #2777958) | Cod sursa (job #2738818)
#include <fstream>
#include <vector>
#include <unordered_map>
using namespace std;
ifstream in("loto.in");
ofstream out("loto.out");
int n, s, aux;
vector<int> a;
unordered_map<int, vector<pair<int, int>>> m;
int main(){
in>>n>>s;
for(int i=0;i<n;++i){
in>>aux;
a.push_back(aux);
}
for(int i:a){
for(int j:a){
m[i+j].push_back(make_pair(i,j));
}
}
for(auto i:m){
for(auto j:m){
for(auto k:m){
if(i.first + j.first + k.first == s){
out<<i.second[0].first<<" "<<i.second[0].second<<" "<<j.second[0].first<<" "<<j.second[0].second<<" "<<k.second[0].first<<" "<<k.second[0].second;
return 0;
}
}
}
}
out<<"-1";
}