Pagini recente » Monitorul de evaluare | Cod sursa (job #409320) | Cod sursa (job #440068) | Cod sursa (job #1156598) | Cod sursa (job #3304205)
//https://www.nerdarena.ro/problema/loto1
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("fast-math")
//#pragma GCC optimize ("unroll-loops")
//#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <vector>
//#include <cstring>
//#include <cmath>
//#include <bitset>
//#include <queue>
//#include <stack>
//#include <utility>
//#include <algorithm>
//#include <string>
//#include <map>
#include <unordered_map>
//#include <set>
//#include <unordered_set>
//#include <cstdint>
//#include <climits>
//#include <iomanip>
//#include <cstdio>
using namespace std;
ifstream fin("loto.in");
ofstream fout("loto.out");
int v[110], s, sum;
int n;
unordered_map <int, tuple<int, int, int>> mp;
void generare()
{
int i, j, k;
int sum;
for (i = 1; i <= n; ++i)
{
for (j = 1; j <= n; ++j)
{
for (k = 1; k <= n; ++k)
{
sum = v[i] + v[j] + v[k];
mp[sum] = { i,j,k };
}
}
}
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int i, j, k;
fin >> n >> s;
for (i = 1; i <= n; ++i)
{
fin >> v[i];
}
generare();
for (auto it=mp.begin();it!=mp.end();++it)
{
int a1 = get<0>(it->second);
int b1 = get<1>(it->second);
int c1 = get<2>(it->second);
//cout << it->first << " " << a1 << " " << b1 << " " << c1 << " ";
int key = s - it->first;
//cout << key << "\n";
if (mp.find(key) != mp.end())
{
int a2 = get<0>(mp[key]);
int b2 = get<1>(mp[key]);
int c2 = get<2>(mp[key]);
fout << v[a1] << " " << v[b1] << " " << v[c1] << " " << v[a2] << " " << v[b2] << " " << v[c2] << "\n";
return 0;
}
}
fout << "-1";
return 0;
}