Pagini recente » Cod sursa (job #2136412) | Cod sursa (job #1399987) | Cod sursa (job #1559026) | Cod sursa (job #323472) | Cod sursa (job #792061)
Cod sursa(job #792061)
//
// main.cpp
// a1
//
// Created by abc on 9/20/12.
// Copyright (c) 2012 abc. All rights reserved.
//
# include <iostream>
# include <cstdio>
# include <cstdlib>
# include <iomanip>
# include <cmath>
# include <map>
# include <vector>
# include <set>
# include <algorithm>
# include <unordered_map>
using namespace std;
# define ISALPHA(Q) (('a' <= Q && Q <= 'z') || ('A' <= Q && Q <= 'Z'))
# define ISDIGIT(a) ('0' <= a && a <= '9')
# define TODIGIT(a) (a - '0')
# define LIKELY(a) (__builtin_expect((a), 1))
# define UNLIKELY(a) (__builtin_expect(!!(a), 0))
typedef unsigned char U8;
typedef long long LONG;
void init()
{
freopen("loto.in", "r", stdin);
freopen("loto.out", "w", stdout);
}
template <typename T> void read(vector<T> &vec)
{
for(size_t i=0; i<vec.size(); ++i) {
cin >> vec[i];
}
}
typedef struct __cont{
int sum;
int a,b,c;
} Cont_t;
struct key_cmp
{
bool operator()(const __cont &a, const __cont &b) { return (a.sum < b.sum); }
};
int main(int argc, const char * argv[])
{
init();
int N, S; cin >> N >> S;
vector<int> vec(N); read(vec);
//sort(vec.begin(), vec.end());
unordered_map<int, Cont_t> conv;
for(int i=0; LIKELY(i<N); ++i)
{
for(int k=0; LIKELY(k<N); ++k)
{
for(int j=0; LIKELY(j<N); ++j)
{
conv[vec[i]+vec[k]+vec[j]] = Cont_t {vec[i]+vec[k]+vec[j], vec[i], vec[k], vec[j]};
}
}
}
for(auto it = conv.begin(); it != conv.end(); ++it)
{
int one = it->first;
int two = S - one;
auto com = conv.find(two);
if (com != conv.end())
{
printf("%d %d %d %d %d %d", it->second.a, it->second.b, it->second.c,
com->second.a, com->second.b, com->second.c);
return 0;
}
}
cout << -1;
return 0;
}