結果

問題 No.451 575
ユーザー chocoruskchocorusk
提出日時 2019-02-22 01:14:10
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 208 ms / 2,000 ms
コード長 1,050 bytes
コンパイル時間 925 ms
コンパイル使用メモリ 95,528 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-01 12:21:46
合計ジャッジ時間 5,648 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,812 KB
testcase_01 AC 4 ms
6,940 KB
testcase_02 AC 4 ms
6,944 KB
testcase_03 AC 3 ms
6,944 KB
testcase_04 AC 4 ms
6,940 KB
testcase_05 AC 6 ms
6,940 KB
testcase_06 AC 13 ms
6,940 KB
testcase_07 AC 73 ms
6,944 KB
testcase_08 AC 4 ms
6,940 KB
testcase_09 AC 6 ms
6,944 KB
testcase_10 AC 54 ms
6,940 KB
testcase_11 AC 158 ms
6,944 KB
testcase_12 AC 207 ms
6,940 KB
testcase_13 AC 205 ms
6,944 KB
testcase_14 AC 4 ms
6,940 KB
testcase_15 AC 6 ms
6,940 KB
testcase_16 AC 15 ms
6,940 KB
testcase_17 AC 72 ms
6,944 KB
testcase_18 AC 72 ms
6,940 KB
testcase_19 AC 49 ms
6,940 KB
testcase_20 AC 12 ms
6,940 KB
testcase_21 AC 5 ms
6,940 KB
testcase_22 AC 3 ms
6,940 KB
testcase_23 AC 208 ms
6,940 KB
testcase_24 AC 108 ms
6,944 KB
testcase_25 AC 4 ms
6,940 KB
testcase_26 AC 4 ms
6,940 KB
testcase_27 AC 4 ms
6,940 KB
testcase_28 AC 4 ms
6,944 KB
testcase_29 AC 10 ms
6,940 KB
testcase_30 AC 72 ms
6,940 KB
testcase_31 AC 3 ms
6,940 KB
testcase_32 AC 18 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef __int128_t lll;
const ll MAX=1e18;
const ll MIN=1;
int main()
{
	int n; cin>>n;
	ll b[100001];
	for(int i=0; i<n; i++) cin>>b[i];
	int p[100001]; lll a[100001];
	p[0]=1, a[0]=0;
	for(int i=0; i<n; i++){
		if(i&1){
			p[i+1]=p[i];
			a[i+1]=a[i]-b[i];
		}else{
			p[i+1]=-p[i];
			a[i+1]=b[i]-a[i];
		}
	}
	lll l=MIN, r=MAX;
	for(int i=1; i<=n; i++){
		if(p[i]==1){
			l=max(l, MIN-a[i]);
			r=min(r, MAX-a[i]);
		}else{
			l=max(l, a[i]-MAX);
			r=min(r, a[i]-MIN);
		}
	}
	if(l>r){
		cout<<-1<<endl;
	}else{
		cout<<n+1<<endl;
		for(int i=0; i<=n; i++){
			if(p[i]==1) cout<<(ll)(l+a[i])<<endl;
			else cout<<(ll)(-l+a[i])<<endl;
		}
	}
	return 0;
}
0