結果

問題 No.1279 Array Battle
ユーザー pengin_2000pengin_2000
提出日時 2021-09-06 00:54:26
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 970 bytes
コンパイル時間 782 ms
コンパイル使用メモリ 29,792 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-24 05:32:26
合計ジャッジ時間 1,696 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 0 ms
4,376 KB
testcase_02 AC 0 ms
4,376 KB
testcase_03 AC 0 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 0 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 0 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 3 ms
4,376 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 AC 26 ms
4,380 KB
testcase_16 AC 26 ms
4,376 KB
testcase_17 AC 26 ms
4,376 KB
testcase_18 AC 26 ms
4,380 KB
testcase_19 AC 26 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
int n;
int a[16], b[16];
int max, f;
int ans;
void check(int c[])
{
	int v, i;
	if (f == 0)
	{
		v = 0;
		for (i = 0; i < n; i++)
			if (a[c[i]] > b[i])
				v += a[c[i]] - b[i];
		if (v > max)
			max = v;
	}
	else
	{
		v = 0;
		for (i = 0; i < n; i++)
			if (a[c[i]] > b[i])
				v += a[c[i]] - b[i];
		if (v == max)
			ans++;
	}
	return;
}
void make(int c[], int cc, int d[], int dd)
{
	if (dd == 0)
	{
		check(c);
		return;
	}
	int e[16], i, j;
	for (i = 0; i < dd; i++)
	{
		for (j = 0; j < i; j++)
			e[j] = d[j];
		for (j = i + 1; j < dd; j++)
			e[j - 1] = d[j];
		c[cc] = d[i];
		make(c, cc + 1, e, dd - 1);
	}
	return;
}
int main()
{
	scanf("%d", &n);
	int i;
	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);
	for (i = 0; i < n; i++)
		scanf("%d", &b[i]);
	int c[16], d[16];
	for (i = 0; i < n; i++)
		d[i] = i;
	f = 0;
	make(c, 0, d, n);
	f = 1;
	ans = 0;
	for (i = 0; i < n; i++)
		d[i] = i;
	make(c, 0, d, n);
	printf("%d\n", ans);
	return 0;
}
0