結果

問題 No.2309 [Cherry 5th Tune D] 夏の先取り
ユーザー pointNpointN
提出日時 2023-05-19 23:28:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,647 bytes
コンパイル時間 1,449 ms
コンパイル使用メモリ 132,268 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-10 06:45:01
合計ジャッジ時間 6,293 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
5,248 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 47 ms
5,376 KB
testcase_21 AC 40 ms
5,376 KB
testcase_22 AC 44 ms
5,376 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 49 ms
5,376 KB
testcase_28 AC 51 ms
5,376 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 3 ms
5,376 KB
testcase_37 AC 2 ms
5,376 KB
testcase_38 AC 3 ms
5,376 KB
testcase_39 AC 2 ms
5,376 KB
testcase_40 AC 2 ms
5,376 KB
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 AC 51 ms
5,376 KB
testcase_46 AC 46 ms
5,376 KB
testcase_47 WA -
testcase_48 AC 2 ms
5,376 KB
testcase_49 AC 2 ms
5,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 = W*s3;
    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