結果

問題 No.451 575
ユーザー 🐬hec🐬hec
提出日時 2016-12-02 16:26:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,066 bytes
コンパイル時間 1,541 ms
コンパイル使用メモリ 164,560 KB
実行使用メモリ 5,036 KB
最終ジャッジ日時 2023-08-22 13:37:05
合計ジャッジ時間 5,900 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 4 ms
4,380 KB
testcase_06 AC 9 ms
4,376 KB
testcase_07 AC 64 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 51 ms
4,380 KB
testcase_11 AC 151 ms
4,536 KB
testcase_12 AC 198 ms
5,036 KB
testcase_13 AC 194 ms
4,964 KB
testcase_14 AC 1 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 64 ms
4,376 KB
testcase_19 AC 42 ms
4,376 KB
testcase_20 AC 9 ms
4,376 KB
testcase_21 AC 3 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 196 ms
4,952 KB
testcase_24 AC 103 ms
4,380 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 8 ms
4,380 KB
testcase_30 AC 64 ms
4,440 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

using namespace std;
using ll=long long;

// Problem Specific Parameter:

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

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

	rep(i,n) cin >> b[i];
	ll low=1LL,high=inf;

	rep(i,n){
		ll nlow,nhigh;
		// K=b[i]
		if(i%2==0){
			// [low,high] -> [K-high,K-low]
			nlow=max(b[i]-high,1LL),nhigh=b[i]-low;
		}else{
			// [low,high] -> [low-K,high-K]
			nlow=max(low-b[i],1LL),nhigh=high-b[i];
		}
		low=nlow,high=nhigh;
	}

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

	// a[n+1]=[low,high] 
	a[n]=low;

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


	cout << n+1 << endl;
	rep(i,n+1) cout << a[i] << endl;

	return 0;
}
0