結果

問題 No.2309 [Cherry 5th Tune D] 夏の先取り
ユーザー pointNpointN
提出日時 2023-05-20 00:03:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 242 ms / 3,000 ms
コード長 1,680 bytes
コンパイル時間 1,254 ms
コンパイル使用メモリ 130,892 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-23 02:07:13
合計ジャッジ時間 6,757 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
4,380 KB
testcase_01 AC 71 ms
4,376 KB
testcase_02 AC 67 ms
4,380 KB
testcase_03 AC 52 ms
4,376 KB
testcase_04 AC 62 ms
4,376 KB
testcase_05 AC 47 ms
4,380 KB
testcase_06 AC 49 ms
4,376 KB
testcase_07 AC 54 ms
4,376 KB
testcase_08 AC 62 ms
4,376 KB
testcase_09 AC 68 ms
4,376 KB
testcase_10 AC 46 ms
4,380 KB
testcase_11 AC 61 ms
4,376 KB
testcase_12 AC 56 ms
4,376 KB
testcase_13 AC 75 ms
4,380 KB
testcase_14 AC 44 ms
4,376 KB
testcase_15 AC 56 ms
4,380 KB
testcase_16 AC 41 ms
4,380 KB
testcase_17 AC 63 ms
4,380 KB
testcase_18 AC 67 ms
4,376 KB
testcase_19 AC 42 ms
4,380 KB
testcase_20 AC 49 ms
4,380 KB
testcase_21 AC 42 ms
4,376 KB
testcase_22 AC 46 ms
4,380 KB
testcase_23 AC 48 ms
4,380 KB
testcase_24 AC 84 ms
4,380 KB
testcase_25 AC 57 ms
4,380 KB
testcase_26 AC 91 ms
4,380 KB
testcase_27 AC 50 ms
4,376 KB
testcase_28 AC 53 ms
4,380 KB
testcase_29 AC 62 ms
4,380 KB
testcase_30 AC 82 ms
4,376 KB
testcase_31 AC 205 ms
4,376 KB
testcase_32 AC 201 ms
4,380 KB
testcase_33 AC 203 ms
4,376 KB
testcase_34 AC 202 ms
4,376 KB
testcase_35 AC 201 ms
4,376 KB
testcase_36 AC 3 ms
4,380 KB
testcase_37 AC 1 ms
4,376 KB
testcase_38 AC 2 ms
4,376 KB
testcase_39 AC 2 ms
4,380 KB
testcase_40 AC 2 ms
4,376 KB
testcase_41 AC 242 ms
4,376 KB
testcase_42 AC 241 ms
4,376 KB
testcase_43 AC 75 ms
4,380 KB
testcase_44 AC 54 ms
4,380 KB
testcase_45 AC 54 ms
4,376 KB
testcase_46 AC 48 ms
4,376 KB
testcase_47 AC 25 ms
4,376 KB
testcase_48 AC 1 ms
4,376 KB
testcase_49 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
//#include <atcoder/all>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

ll g(ll X, ll Y, ll A, ll C, ll B){
  ll ans = 0;
  vector<ll> x = {A,B,0,  A,0,B-C,A};
  vector<ll> y = {0,0,C,B-A,B,  C,C};
  rep(i,7){
    ll xx = x[i], yy = y[i];
    if(xx>=0 && yy>=0 && xx<=A && yy<=C && xx+yy<=B){
      chmax(ans,X*xx+Y*yy);
    }
  }
  return ans;
}

ll f(vector<ll> ABC, vector<ll> XYZ){
  ll ans = 0;
  rep(i,3){
    chmax(ans,g(XYZ[i],XYZ[(i+1)%3],ABC[i],ABC[(i+2)%3],ABC[(i+1)%3]));
  }
  return ans;
}

void solve(){
  ll A,B,C; cin >> A >> B >> C;
  ll X,Y,Z,W; cin >> X >> Y >> Z >> W;
  ll mx3 = min({A,B,C});
  ll ans = 0;
  for(ll s3=0;s3<=mx3;s3++){
    ll ws = max(W*s3,(X+Y+Z)*(s3/2)+W*(s3%2));
    ll a = A-s3;
    ll b = B-s3;
    ll c = C-s3;
    chmax(ans,ws+f({a,b,c},{X,Y,Z}));
  }
  cout << ans << '\n';
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int T; cin >> T;
  while(T--) solve();
  return 0;
}
0