結果

問題 No.1279 Array Battle
ユーザー tailstails
提出日時 2020-11-08 04:13:37
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 358 bytes
コンパイル時間 230 ms
コンパイル使用メモリ 29,568 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-22 15:00:47
合計ジャッジ時間 1,023 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,816 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 1 ms
6,944 KB
testcase_10 AC 1 ms
6,944 KB
testcase_11 AC 1 ms
6,940 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 1 ms
6,944 KB
testcase_15 AC 5 ms
6,940 KB
testcase_16 AC 5 ms
6,944 KB
testcase_17 AC 5 ms
6,940 KB
testcase_18 AC 5 ms
6,944 KB
testcase_19 AC 6 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:3:15: warning: return type defaults to 'int' [-Wimplicit-int]
    3 | static inline sat(a){
      |               ^~~
main.c: In function 'sat':
main.c:3:15: warning: type of 'a' defaults to 'int' [-Wimplicit-int]
main.c: At top level:
main.c:7:1: warning: data definition has no type or storage class
    7 | n,a[1<<9],b[9];
      | ^
main.c:7:1: warning: type defaults to 'int' in declaration of 'n' [-Wimplicit-int]
main.c:7:3: warning: type defaults to 'int' in declaration of 'a' [-Wimplicit-int]
    7 | n,a[1<<9],b[9];
      |   ^
main.c:7:11: warning: type defaults to 'int' in declaration of 'b' [-Wimplicit-int]
    7 | n,a[1<<9],b[9];
      |           ^
main.c:8:1: warning: data definition has no type or storage class
    8 | z,m;
      | ^
main.c:8:1: warning: type defaults to 'int' in declaration of 'z' [-Wimplicit-int]
main.c:8:3: warning: type defaults to 'int' in declaration of 'm' [-Wimplicit-int]
    8 | z,m;
      |   ^
main.c:9:1: warning: return type defaults to 'int' [-Wimplicit-int]
    9 | f(c,j,s){
      | ^
main.c: In function 'f':
main.c:9:1: warning: type of 'c' defaults to 'int' [-Wimplicit-int]
main.c:9:1: warning: type of 'j' defaults to 'int' [-Wimplicit-int]
main.c:9:1: warning: type of 's' defaults to 'int' [-Wimplicit-int]
main.c: At top level:
main.c:20:1: warning: return type defaults to 'int' [-Wimplicit-int]
   20 | main(){
      | ^~~~
main.c: In function 'main':
main.c:1:15: warning: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    1 | #define RD(a) scanf("%d",&a)
      |               ^~~~~
main.c:21:9: note: in expansion of macro 'RD'
   21 |         RD(n);
      |         ^~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | #define RD(a) scanf("%d",&a)
main.c:1:15: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
    1 | #define RD(a) scanf("%d",&a)
      |               ^~~~~
mai

ソースコード

diff #

#define RD(a) scanf("%d",&a)

static inline sat(a){
	return a>=0?a:0;
}

n,a[1<<9],b[9];
z,m;
f(c,j,s){
	if(c){
		for(int i=c;i;i&=i-1){
			int d=i&-i;
			f(c^d,j+1,s+sat(a[d]-b[j]));
		}
	}else{
		if(m<s) m=s,z=0;
		z+=m==s;
	}
}
main(){
	RD(n);
	for(int i=0;i<n;++i) RD(a[1<<i]);
	for(int i=0;i<n;++i) RD(b[i]);
	m=-1;
	f((1<<n)-1,0,0);
	printf("%d",z);
}
0