fork download
  1. #include <bits/stdc++.h>
  2.  
  3. #define all(v) begin(v), end(v)
  4. #define fi first
  5. #define se second
  6.  
  7.  
  8. #define siz(v) (int)(v).size()
  9. #define dbg(x) "[" #x " = " << x << "]"
  10.  
  11. #define BIT(x, i) (((x) >> (i)) & 1)
  12. #define MASK(i) (1LL << (i))
  13.  
  14. using namespace std;
  15.  
  16. const long long inf = 4e18 + 12;
  17. const int infINT = 1e9 + 123, mod = 999876149;
  18.  
  19. bool M1;
  20.  
  21. typedef pair<int, int > ii;
  22.  
  23. void add(int &a, const int &b){
  24. a += b;
  25. if (a >= mod) a -= mod;
  26. }
  27.  
  28. int bin_pow(int a, int k){
  29. int res = 1;
  30. while(k){
  31. if (k & 1) res = 1LL * res * 1LL * a % mod;
  32. k >>= 1; a = 1LL * a * 1LL * a % mod;
  33. }
  34. return res;
  35. }
  36.  
  37. template<class X, class Y> bool minimize(X &x, const Y &y){return x >= y ? x = y, 1: 0;}
  38. template<class X, class Y> bool maximize(X &x, const Y &y){return x < y ? x = y, 1: 0;}
  39.  
  40. long long a[3], b[3];
  41.  
  42. long long solveA(){
  43. return max({a[0], a[1], a[2]}) * (b[0] + b[1] + b[2]);
  44. }
  45.  
  46. long long solveB(){
  47. long long mi = inf;
  48. for(int i = 0; i < 3; i++){
  49. long long A = 0, B = 0;
  50. for(int j = 0; j < 3; j++) if (i != j){
  51. A = max(A, a[j]); B += b[j];
  52. }
  53. A += a[i]; B = max(B, b[i]);
  54. mi = min(mi, 1LL * A * 1LL * B);
  55. }
  56. return mi;
  57. }
  58.  
  59. void input(){
  60. for(int i = 0; i < 3; i++) cin >> a[i] >> b[i];
  61. }
  62.  
  63. void solve(){
  64. long long res = inf;
  65.  
  66. for(int mask = 0; mask < 8; mask++){
  67. for(int i = 0; i < 3; i++) if (BIT(mask, i)){
  68. swap(a[i], b[i]);
  69. }
  70.  
  71. res = min(res, solveA());
  72. res = min(res, solveB());
  73.  
  74. for(int i = 0; i < 3; i++) if (BIT(mask, i)){
  75. swap(a[i], b[i]);
  76. }
  77. }
  78.  
  79. cout << res << '\n';
  80. }
  81.  
  82. bool M2;
  83. signed main(){
  84. ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  85. #define task "test"
  86. if (fopen(task".inp", "r")){
  87. freopen(task".inp", "r", stdin);
  88. freopen(task".out", "w", stdout);
  89. }
  90. int t = 1;
  91. cin >> t;
  92. while(t--){
  93. input();
  94. solve();
  95. }
  96. cerr << (1.0 * clock()) / CLOCKS_PER_SEC << ".s\n";
  97. cerr << (&M2 - &M1) / 1048576 << " mb\n";
  98. }
Success #stdin #stdout #stderr 0s 5312KB
stdin
Standard input is empty
stdout
0
stderr
0.003878.s
0 mb