解法
それぞれの荷物の置き方について、(一例として)縦、横、高さの順に長さが昇順になるように並べます。
その後、それぞれの方向について最大値をとったものの積が答えです。
コード
typedef vector<int> VI; typedef vector<VI> VVI; #define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i ) #define FOR( v, c ) for ( auto &v : c ) #define ALL( c ) (c).begin(), (c).end() int main() { cin.tie( 0 ); ios::sync_with_stdio( false ); int c; cin >> c; VVI box( 3, VI( c ) ); REP( i, 0, c ) { VI tmp( 3 ); FOR( t, tmp ) { cin >> t; } sort( ALL( tmp ) ); REP( j, 0, 3 ) { box[j][i] = tmp[j]; } } int res = 1; REP( i, 0, 3 ) { res *= *max_element( ALL( box[i] ) ); } cout << res << endl; return 0; }