Pagini recente » Cod sursa (job #2294043) | Cod sursa (job #2436733) | Cod sursa (job #1093252) | Cod sursa (job #182667) | Cod sursa (job #1051683)
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
const int mod = 666013;
const int MAX_N = 110;
int A[MAX_N];
vector <pair< int, long long > > H[mod];
vector <pair< int, long long > >::iterator it;
vector <int> aux;
inline int max( int x, int y ){
if( x > y ) return x;
return y;
}
int main(){
ifstream cin( "loto.in" );
ofstream cout( "loto.out" );
int N, S, max_v = 0;
cin >> N >> S;
for( int i = 1; i <= N; ++i ){
cin >> A[i];
max_v = max( max_v, A[i] );
}
if( max_v * 6 < S ){
cout << -1;
return 0;
}
for( int i = 1; i <= N; ++i )
for( int j = 1; j <= N; ++j )
for( int h = 1; h <= N; ++h ){
int s = A[i] + A[j] + A[h];
int r = s % mod;
bool e = false;
if( H[r].size() > 0 )
for( it = H[r].begin(); it != H[r].end(); ++it )
if( (*it).first == s ) e = true;
if( !e ) H[r].push_back( make_pair( s, 1LL * ( i * 1000 + j ) * 1000 + h ) );
}
for( int i = 1; i <= N; ++i )
for( int j = 1; j <= N; ++j )
for( int h = 1; h <= N; ++h ){
int s = S - A[i] - A[j] - A[h];
int r = s % mod;
long long v = 0;
if( s > 0 && H[r].size() > 0 )
for( it = H[r].begin(); it != H[r].end(); ++it )
if( (*it).first == s ) v = (*it).second;
if( v != 0 ){
aux.push_back( A[i] );
aux.push_back( A[j] );
aux.push_back( A[h] );
aux.push_back( A[v%1000] );
aux.push_back( A[v/1000%1000] );
aux.push_back( A[v/1000000%1000] );
sort( aux.begin(), aux.end() );
for( int q = 0; q < 6; ++q )
cout << aux[q] << " ";
// cout << A[i] << " " << A[j] << " " << A[h] << " " << A[v%1000] << " " << A[v/1000%1000] << " " << A[v/1000000%1000];
return 0;
}
}
cout.close();
cin.close();
return 0;
}