結果

問題 No.451 575
ユーザー YamyukiYamyuki
提出日時 2016-12-02 00:36:29
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 657 bytes
コンパイル時間 1,024 ms
コンパイル使用メモリ 20,864 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-09 17:03:53
合計ジャッジ時間 6,229 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 0 ms
5,376 KB
testcase_02 AC 0 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 0 ms
5,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 32 ms
5,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 1 ms
5,376 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 1 ms
5,376 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 1 ms
5,376 KB
testcase_32 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:36:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   36 |         scanf("%ld",&n);
      |         ^~~~~~~~~~~~~~~
main.c:38:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   38 |                 scanf("%lld",&a[i]);
      |                 ^~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>

unsigned long long a[100000],b[100001];
long n;

int set(long c){
	int f;
	unsigned long long i;
	if(c==n+1) return 1;
	if(c==0){
		for(i=1;i<a[0];i++){
			b[0]=i;
			f=set(1);
			if(f) return 1;
		}
		return 0;
	}
	if(c%2==1){
		if(a[c-1]-b[c-1]>0){
			b[c]=a[c-1]-b[c-1];
			f=set(c+1);
			if(f) return 1;
		}
		return 0;
	}
	if(b[c-1]-a[c-1]>0){
		b[c]=b[c-1]-a[c-1];
		f=set(c+1);
		if(f) return 1;
	}
	return 0;
}

int main(){
	long i;
	scanf("%ld",&n);
	for(i=0;i<n;i++){
		scanf("%lld",&a[i]);
	}
	if(set(0)){
		printf("%ld\n",n+1);
		for(i=0;i<n+1;i++){
			printf("%lld\n",b[i]);
		}
		return 0;
	}
	printf("-1\n");
  return 0;
}
0