Mai intai trebuie sa te autentifici.

Cod sursa(job #2854792)

Utilizator BlueLuca888Girbovan Robert Luca BlueLuca888 Data 21 februarie 2022 19:21:45
Problema Loto Scor 65
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.94 kb
#define boostIO ios_base::sync_with_stdio(false); fin.tie(nullptr); fout.tie(nullptr);
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>

using namespace std;

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

struct sum{
    bool exist;
    int a, b, c;
}; map <int, sum> mp;

int n, s, current, target;
int v[105];

int main (){
    boostIO
    fin>>n>>s;
    for(int i=1; i<=n; i++)
        fin>>v[i];

    for(int i1=1; i1<=n; i1++)
        for(int i2=1; i2<=n; i2++)
            for(int i3=1; i3<=n; i3++){
                current = v[i1] + v[i2] + v[i3];
                target = s - current;

                if(mp[target].exist == true){
                    fout<<mp[target].a<<" "<<mp[target].b<<" "<<mp[target].c<<" "<<v[i1]<<" "<<v[i2]<<" "<<v[i3];
                    return 0;
                }

                mp[current] = {true, v[i1], v[i2], v[i3]};
            }
    fout<<-1;
    return 0;
}