Cod sursa(job #3359761)
| Utilizator | Data | 3 iulie 2026 18:17:03 | |
|---|---|---|---|
| Problema | Loto | Scor | 95 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 1.27 kb |
#include <fstream>
#include<tuple>
#include<bitset>
#include<vector>
using namespace std;
ifstream in("loto.in");
ofstream out("loto.out");
bitset<600000001> frec;
vector<tuple<int,int,int,int>> v;
int arr[101];
int main()
{
int n,s;
in>>n>>s;
for(int i=1; i<=n; i++)
{
in>>arr[i];
}
for(int i=1; i<=n; i++)
{
for(int j=1; j<=n; j++)
{
for(int f=1; f<=n; f++)
{
int sum=arr[i]+arr[j]+arr[f];
if(sum>s)
{
continue;
}
if(frec[s-sum])
{
out<<arr[i]<<" "<<arr[j]<<" "<<arr[f]<<" ";
for(int q=0; q<v.size(); q++)
{
if(get<0>(v[q])==s-sum)
{
out<<get<1>(v[q])<<" "<<get<2>(v[q])<<" "<<get<3>(v[q]);
return 0;
}
}
}
else
{
frec[sum]=1;
v.push_back(make_tuple(sum,arr[i],arr[j],arr[f]));
}
}
}
}
out<<-1;
return 0;
}
