Cod sursa(job #2740159)

Utilizator HatersMcCristian Ioan HatersMc Data 11 aprilie 2021 19:19:11
Problema Loto Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.92 kb
#include <fstream>
#include <unordered_map>
#include <vector>
using namespace std;
ifstream f("loto.in");
ofstream g("loto.out");
int main() {
    unordered_map<int, pair<int,int>> harta;
    vector<int> vector;
    int n,s,x;
    bool ok=true;
    f>>n>>s;
    for(int  i = 0 ; i < n ; ++i)
    {
        f>>x;
        vector.push_back(x);
    }
    for(int  i = 0 ; i < n ; ++i)
        for(int  j = i ; j < n ; ++j)
            for(int  l = j ; l < n ; ++l)
                harta[vector[i] + vector[j] + vector[l]] = { vector[i],vector[j]};
    for(auto i : harta)
    {
        auto j = harta.find(s-i.first);
        if(j!=harta.end())
        {
            g<<i.first-(i.second.first+i.second.second)<<i.second.first<<" "<<i.second.second<<" "<<
            " "<<s-i.first-(j->second.first+j->second.second)<<" "<<j->second.first<<" "<<j->second.second;
            ok= false;
        }
    }
    if(ok)
        g<<-1;

    return 0;
}