Cod sursa(job #2667857)

Utilizator Botnaru_VictorBotnaru Victor Botnaru_Victor Data 3 noiembrie 2020 23:43:12
Problema Loto Scor 85
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.41 kb
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <cstdio>
#include <iostream>
#include <map>

using namespace std;

struct half{
    int a=-1,b,c;
};

map <int,half> m;

int main()
{
    freopen("loto.in","r",stdin);
    freopen("loto.out","w",stdout);
    int n,v[101],ss;
    cin>>n>>ss;
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
    }
    half x;
    for(int i=0;i<n;i++)
    {
       x.a=v[i];
       for(int j=i;j<n;j++)
       {
           x.b=v[j];
           for(int y=j;y<n;y++)
            {
                x.c=v[y];
                int s=x.a+x.b+x.c;
                m[s]=x;
            }
       }
    }
    for(int i=0;i<n;i++)
    {
       x.a=v[i];
       for(int j=i;j<n;j++)
       {
           x.b=v[j];
           for(int y=j;y<n;y++)
            {
                x.c=v[y];
                int s=ss-(x.a+x.b+x.c);
                int sss=x.a+x.b+x.c;
                if (m[s].a!=-1)
                {
                    cout<<x.a<<' '<<x.b<<' '<<x.c<<' '<<m[s].a<<' '<<m[s].b<<' '<<m[s].c;
                    return 0;
                }
            }
       }
    }
    cout<<-1;
    return 0;
}