結果

問題 No.2309 [Cherry 5th Tune D] 夏の先取り
ユーザー tnakao0123tnakao0123
提出日時 2023-06-23 16:46:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,156 bytes
コンパイル時間 1,950 ms
コンパイル使用メモリ 42,280 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-13 11:41:56
合計ジャッジ時間 3,964 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,376 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 15 ms
4,380 KB
testcase_21 AC 13 ms
4,380 KB
testcase_22 AC 14 ms
4,376 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 15 ms
4,380 KB
testcase_28 AC 16 ms
4,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 1 ms
4,380 KB
testcase_37 AC 1 ms
4,380 KB
testcase_38 AC 2 ms
4,376 KB
testcase_39 AC 1 ms
4,376 KB
testcase_40 AC 1 ms
4,380 KB
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 AC 16 ms
4,376 KB
testcase_46 AC 14 ms
4,376 KB
testcase_47 WA -
testcase_48 AC 1 ms
4,376 KB
testcase_49 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 2309.cc:  No.2309 [Cherry 5th Tune D] 夏の先取り - yukicoder
 */

#include<cstdio>
#include<algorithm>
 
using namespace std;

/* constant */

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

ll calc(int a, int b, int c, int x, int y, int z, int ps[]) {
  ll sum = 0;
  for (int i = 0; i < 3; i++) {
    if (ps[i] == 0) {
      int d0 = min(a, b);
      sum += (ll)x * d0;
      a -= d0, b -= d0;
    }
    else if (ps[i] == 1) {
      int d1 = min(b, c);
      sum += (ll)y * d1;
      b -= d1, c -= d1;
    }
    else {
      int d2 = min(c, a);
      sum += (ll)z * d2;
      c -= d2, a -= d2;
    }
  }
  return sum;
}

/* main */

int main() {
  int tn;
  scanf("%d", &tn);

  while (tn--) {
    int a, b, c, x, y, z, w;
    scanf("%d%d%d%d%d%d%d", &a, &b, &c, &x, &y, &z, &w);

    ll maxsum = 0, sw = 0;
    while (a >= 0 && b >= 0 && c >= 0) {
      int ps[3] = { 0, 1, 2 };
      do {
	maxsum = max(maxsum, sw + calc(a, b, c, x, y, z, ps));
      } while (next_permutation(ps, ps + 3));

      sw += w;
      a--, b--, c--;
    }

    printf("%lld\n", maxsum);
  }
  return 0;
}
0