結果

問題 No.451 575
ユーザー chocoruskchocorusk
提出日時 2019-02-22 01:14:10
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 202 ms / 2,000 ms
コード長 1,050 bytes
コンパイル時間 2,097 ms
コンパイル使用メモリ 92,332 KB
実行使用メモリ 6,392 KB
最終ジャッジ日時 2023-08-13 22:40:18
合計ジャッジ時間 6,525 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
5,416 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 10 ms
5,612 KB
testcase_07 AC 65 ms
6,084 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 51 ms
4,388 KB
testcase_11 AC 154 ms
5,704 KB
testcase_12 AC 196 ms
6,136 KB
testcase_13 AC 193 ms
6,080 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 12 ms
4,376 KB
testcase_17 AC 66 ms
6,164 KB
testcase_18 AC 65 ms
6,276 KB
testcase_19 AC 43 ms
5,208 KB
testcase_20 AC 9 ms
5,488 KB
testcase_21 AC 3 ms
4,380 KB
testcase_22 AC 1 ms
4,508 KB
testcase_23 AC 202 ms
6,392 KB
testcase_24 AC 100 ms
5,044 KB
testcase_25 AC 2 ms
5,412 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 3 ms
4,376 KB
testcase_29 AC 8 ms
4,380 KB
testcase_30 AC 65 ms
6,292 KB
testcase_31 AC 2 ms
4,508 KB
testcase_32 AC 15 ms
4,384 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