結果

問題 No.451 575
ユーザー くれちーくれちー
提出日時 2016-12-02 01:01:33
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 816 bytes
コンパイル時間 456 ms
コンパイル使用メモリ 24,864 KB
実行使用メモリ 6,796 KB
最終ジャッジ日時 2023-08-22 12:12:20
合計ジャッジ時間 4,639 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 22 ms
6,660 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 34 ms
6,796 KB
testcase_14 WA -
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 5 ms
4,376 KB
testcase_17 AC 22 ms
6,732 KB
testcase_18 WA -
testcase_19 AC 14 ms
6,380 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 2 ms
4,376 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 1 ms
4,376 KB
testcase_26 WA -
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 3 ms
4,376 KB
testcase_30 AC 22 ms
6,592 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 6 ms
6,068 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <assert.h>

int main() {
	const long long max = 1000000000000000000;

	int n;
	scanf("%d", &n);

	static long long b[500000];
	int flag = 0;
	int i;

	for (i = 0; i < n; i++) {
		scanf("%lld", &b[i]);
		if (i % 2 == 1 && b[i] == max) flag = 1;
		else if (i % 2 == 0 && b[i] == 1) flag = 1;
	}

	static long long ans[500001];
	long long ansmin = 1;
	ans[0] = 1;
	
	for (i = 1; i < n + 1; i++) {
		if (i % 2 == 1) ans[i] = b[i - 1] - ans[i - 1];
		else ans[i] = ans[i - 1] - b[i - 1];
		if (ans[i] < 1 && ans[i] < ansmin) ansmin = ans[i];
	}
	for (i = 0; i < n + 1; i++) {
		ans[i] -= ansmin - 1;
		if (ans[i] > max) flag = 1;
	}

	if (flag) puts("-1");
	else {
		printf("%d\n", n + 1);
		for (i = 0; i < n + 1; i++) {
			printf("%lld\n", ans[i]);
			assert(ans[i] > 0);
		}
	}
	return 0;
}
0