結果

問題 No.451 575
ユーザー fine
提出日時 2016-12-02 22:32:25
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 579 bytes
コンパイル時間 1,826 ms
コンパイル使用メモリ 168,696 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-12-16 10:42:12
合計ジャッジ時間 4,724 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll INF = 1000000000000000000;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<ll> b(n);
	for (int i = 0; i < n; i++) cin >> b[i];
	vector<ll> a(n + 1);
	a[0] = 1;
	for (int i = 1; i <= n; i++) {
		if (i % 2 == 1) {
			a[i] = b[i - 1] - a[i - 1];
		} else {
			a[i] = a[i - 1]- b[i - 1];
		}
		
		if (a[i] <= 0 || a[i] > INF) {
			cout << -1 << endl;
			return 0;
		}
	} 
	cout << n + 1 << endl;
	for (int i = 0; i <= n; i++) {
		cout << a[i] << endl;
	}
	return 0;
}
0