結果

問題 No.451 575
ユーザー olphe
提出日時 2016-12-02 00:48:27
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 500 bytes
コンパイル時間 752 ms
コンパイル使用メモリ 53,596 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-16 08:52:12
合計ジャッジ時間 4,554 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "iostream" 
using namespace std;

int N;
long long int num[100000];
long long int ans[100001];


int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> num[i];
	}
	ans[0] = 1;
	for (int i = 1; i < N + 1; i++) {
		if (i % 2 == 1) {
			ans[i] = num[i - 1] - ans[i - 1];
		}
		else {
			ans[i] = ans[i - 1] - num[i - 1];
		}
		if (ans[i] <= 0) {
			cout << "-1\n";
			return 0;
		}
	}
	cout << N + 1 << "\n";
	for (int i = 0; i < N + 1; i++) {
		cout << ans[i] << "\n";
	}
	return 0;
}
0