Pagini recente » Cod sursa (job #871004) | Cod sursa (job #1171766) | Cod sursa (job #1804161) | Cod sursa (job #1043126) | Cod sursa (job #1051669)
#include <fstream>
#include <map>
using namespace std;
const int MAX_N = 110;
int A[MAX_N];
map <int, long long> M;
map <int, long long>::iterator it;
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 ){
it = M.find( A[i] + A[j] + A[h] );
if( it == M.end() ) M.insert( pair<int, long long>( A[i] + A[j] + A[h], ( 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 ){
it = M.find( S - A[i] - A[j] - A[h] );
if( it != M.end() ){
long long x = it->second;
cout << i << " " << j << " " << h << " " << A[x%1000] << " " << A[x/1000%1000] << " " << A[x/1000000%1000];
return 0;
}
}
cout.close();
cin.close();
return 0;
}