Pagini recente » Profil mihaita_piticu | Istoria paginii utilizator/mada_fucku | Istoria paginii utilizator/floater | Monitorul de evaluare | Cod sursa (job #2895864)
#include <bits/stdc++.h>
using namespace std;
ifstream f("loto.in");
ofstream g("loto.out");
struct adunari
{
int x, y, z;
};
unordered_map<int, adunari> loto;
int main()
{
int N, S, i, j ,p, v[105], elemente, ok=0;
f>>N>>S;
for(i=0; i<N; i++)
f>>v[i];
for(i=0; i<N; i++)
for(j=i; j<N; j++)
for(p=j; p<N; p++)
loto[v[i]+v[j]+v[p]]={v[i], v[j], v[p]};
for(auto elemente:loto)
{
if(loto.find(S-elemente.first) != loto.end())
{
g<<loto[elemente.first].x<<" "<<loto[elemente.first].y<<" "<<loto[elemente.first].z<<" "<<loto[S-elemente.first].x<<" "<<loto[S-elemente.first].y<<" "<<loto[S-elemente.first].z;
ok=1;
break;
}
}
if(ok==0)
g<<-1;
return 0;
}