Pagini recente » Cod sursa (job #1867371) | Cod sursa (job #1979345) | Cod sursa (job #2377733) | Cod sursa (job #112997) | Cod sursa (job #2570141)
#include <fstream>
#include <map>
using namespace std;
ifstream cin("loto.in");
ofstream cout("loto.out");
map<pair<int,int>,int> m;
int main()
{
int n,s,a;
cin>>n>>s;
m[{s,0}]=1;
for(int i=1;i<=n;++i)
{
cin>>a;
for(int rep=1;rep<=6;++rep)
{
for(auto x:m)
if(x.first.first-a>=0 and x.first.second<=5){
if(x.first.first-a==0 and x.first.second==5)
{
int xx=0,yy=6;
for(int k=1;k<=6;++k)
cout<<a<<' ',xx+=a,yy--,a=m[{xx,yy}];
return 0;
}
m[{x.first.first-a,x.first.second+1}]=a;
}
}
}
cout<<-1;
return 0;
}