結果

問題 No.451 575
ユーザー 🐬hec🐬hec
提出日時 2016-12-02 18:58:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 607 bytes
コンパイル時間 1,520 ms
コンパイル使用メモリ 164,400 KB
実行使用メモリ 4,892 KB
最終ジャッジ日時 2023-08-22 13:15:26
合計ジャッジ時間 6,078 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 10 ms
4,376 KB
testcase_07 AC 65 ms
4,380 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 200 ms
4,892 KB
testcase_13 WA -
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 4 ms
4,376 KB
testcase_16 AC 11 ms
4,376 KB
testcase_17 AC 64 ms
4,380 KB
testcase_18 AC 66 ms
4,376 KB
testcase_19 AC 43 ms
4,376 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 2 ms
4,384 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 8 ms
4,376 KB
testcase_30 AC 65 ms
4,376 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 15 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;

const ll inf=1LL<<60;
ll a[100001],b[100000];

int main(void){
	int n;
	cin >> n;

	for(int i=0;i<n;++i) cin >> b[i];
	ll low=1LL,high=inf;

	for(int i=0;i<n;++i){
		ll nlow,nhigh;
		if(i%2==0)
			nlow=max(low-b[i],1LL),nhigh=high-b[i];
		else
			nlow=max(b[i]-high,1LL),nhigh=b[i]-low;
		low=nlow,high=nhigh;
	}

	if(low>high){
		puts("-1");
		return 0;
	}

	a[n]=low;

	for(int i=n-1;i>=0;--i){
		if(i%2)
			a[i]=b[i]+a[i+1];
		else
			a[i]=b[i]-a[i+1];
	}

	cout << n+1 << endl;
	for(int i=0;i<=n;++i) cout << a[i] << endl;

	return 0;
}
0