結果

問題 No.1780 [Cherry Anniversary] 真冬に咲く26の櫻の木
ユーザー 👑 ygussanyygussany
提出日時 2021-12-09 01:57:19
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 1,701 bytes
コンパイル時間 336 ms
コンパイル使用メモリ 30,844 KB
実行使用メモリ 36,496 KB
最終ジャッジ日時 2023-09-23 13:08:32
合計ジャッジ時間 6,981 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
36,496 KB
testcase_01 AC 14 ms
36,396 KB
testcase_02 AC 71 ms
36,288 KB
testcase_03 WA -
testcase_04 AC 89 ms
36,456 KB
testcase_05 AC 64 ms
36,348 KB
testcase_06 AC 79 ms
36,364 KB
testcase_07 AC 80 ms
36,352 KB
testcase_08 AC 86 ms
36,428 KB
testcase_09 AC 77 ms
36,396 KB
testcase_10 AC 74 ms
36,288 KB
testcase_11 AC 84 ms
36,224 KB
testcase_12 AC 27 ms
36,328 KB
testcase_13 AC 14 ms
36,344 KB
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

void chmax(int* a, int b)
{
	if (*a < b) *a = b;
}

void chmaxll(long long* a, long long b)
{
	if (*a < b) *a = b;
}

int main()
{
	const int inf = -(1 << 30);
	int i, j, k, l, u, w, C[26], K[26], N, A, B, E, adj[26][17][17];
	char S[31];
	for (i = 0; i < 26; i++) scanf("%d", &(C[i]));
	for (i = 0; i < 26; i++) scanf("%d", &(K[i]));
	for (i = 0; i < 26; i++) for (u = 1; u <= 16; u++) for (w = 1; w <= 16; w++) adj[i][u][w] = inf;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		scanf("%s %d %d %d", S, &A, &B, &E);
		for (j = 0; S[j] != 0; j++) {
			chmax(&(adj[S[j] - 'A'][A][B]), E);
			chmax(&(adj[S[j] - 'A'][B][A]), E);
		}
	}
	
	const long long infll = -(1LL << 60);
	long long ans = infll, dp[26][10001][17], tmp, sum;
	for (i = 0; i < 26; i++) {
		for (j = 0; j <= 10000; j++) {
			for (k = 1; k <= 16; k++) dp[i][j][k] = infll;
		}
		dp[i][0][C[i]] = 0;
		for (j = 0; j < 10000; j++) {
			for (k = 1; k <= 16; k++) {
				if (dp[i][j][k] == infll) continue;
				for (u = k, w = 1; w <= 16; w++) {
					if (adj[i][u][w] != inf) chmaxll(&(dp[i][j+1][w]), dp[i][j][u] + adj[i][u][w]);
				}
			}
		}
	}
	for (k = 1; k <= 16; k++) {
		for (i = 0, sum = 0; i < 26; i++) {
			for (j = 0, tmp = infll; j <= 10000 && j <= K[i]; j++) chmaxll(&tmp, dp[i][j][k]);
			if (K[i] > 100) {
				for (j = 2; j <= 1000; j++) {
					for (l = j; l <= 10000; l++) if (dp[i][l][k] != infll && dp[i][l-j][k] != infll) chmaxll(&tmp, (dp[i][l][k] - dp[i][l-j][k]) * ((K[i] - l) / j) + dp[i][l][k]);
				}
			}
			if (tmp == infll) break;
			sum += tmp;
		}
		if (i == 26) chmaxll(&ans, sum);
	}
	if (ans == infll) printf("Impossible\n");
	else printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}
0