Cod sursa(job #2116105)

Utilizator IVVladIon Vlad Vasile IVVlad Data 27 ianuarie 2018 12:37:11
Problema Loto Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.83 kb
#include <fstream>
#include <unordered_map>
using namespace std;
ifstream f("loto.in");
ofstream g("loto.out");
typedef struct nod
{
    int i,j,k;
} tip;
unordered_map <int,tip> H;
short n;
long s;
unsigned long a[101];
int main()
{
    int i,j,k;
    f>>n>>s;
    for(int x=1; x<=n; x++)
        f>>a[x];
    tip aux;
    for(i=1; i<=n; i++)
        for(j=1; j<=n; j++)
            for(k=1; k<=n; k++)
            {
                aux.i=i;
                aux.j=j;
                aux.k=k;
                H[a[i]+a[j]+a[k]]=aux;
                if(H.count(s-a[i]-a[j]-a[k])>0)
                {
                    aux=H[s-a[i]-a[j]-a[k]];
                    g<<aux.i<<" "<<aux.j<<" "<<aux.k<<" "<<a[i]<<" "<<a[j]<<" "<<a[k];
                    return 0;
                }

            }
g<<-1;
return 0;
}