Cod sursa(job #2570141)

Utilizator betybety bety bety Data 4 martie 2020 15:15:39
Problema Loto Scor 25
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.77 kb
#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;
}