Cod sursa(job #2745984)

Utilizator andreinovaNacu Andrei Emilian andreinova Data 27 aprilie 2021 12:40:05
Problema Loto Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.97 kb
#include <bits/stdc++.h>

using namespace std;

ifstream in("loto.in");
ofstream out("loto.out");

struct rasp
{
    int primul;
    int alDoilea;
    int alTreilea;
};

int n, s;
int v[101];
unordered_map <int, rasp> m;

int main()
{
    in>>n>>s;

    for(int i = 1; i <= n; i++)
        in>>v[i];

    for(int i = 1; i <= n; i++)
    {
        for(int j = i; j <= n; j++)
        {
            for(int q = j; q <= n; q++)
            {
                int scurent = v[i]+v[j]+v[q];
                m[scurent].primul = v[i];
                m[scurent].alDoilea = v[j];
                m[sc].alTreilea = v[q];
                if(m.find(s-scurent) != m.end())
                {
                    out << v[i] << " " << v[j] << " " <<v[q] << " " << m[s-scurent].primul << " " << m[s-scurent].alDoilea << " " << m[s-scurent].alTreilea;
                    return 0;
                }
            }
        }
    }

    out << -1;
    return 0;
}