結果

問題 No.451 575
ユーザー square1001square1001
提出日時 2017-03-07 19:58:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 715 bytes
コンパイル時間 1,411 ms
コンパイル使用メモリ 165,336 KB
実行使用メモリ 5,144 KB
最終ジャッジ日時 2023-09-05 22:31:04
合計ジャッジ時間 4,093 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 4 ms
4,380 KB
testcase_07 AC 20 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 9 ms
4,380 KB
testcase_11 AC 26 ms
4,728 KB
testcase_12 AC 33 ms
5,144 KB
testcase_13 AC 33 ms
5,140 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 5 ms
4,380 KB
testcase_17 AC 21 ms
4,376 KB
testcase_18 AC 20 ms
4,376 KB
testcase_19 AC 14 ms
4,380 KB
testcase_20 AC 3 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 33 ms
5,028 KB
testcase_24 AC 16 ms
4,444 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 1 ms
4,380 KB
testcase_29 AC 4 ms
4,376 KB
testcase_30 AC 21 ms
4,380 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 6 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const long long m = 1000000000000000000;
int n; long long b[100009], a[100009];
int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; i++) scanf("%lld", &b[i]);
	long long l = 1, r = m;
	for(int i = 0; i < n; i++) {
		if(i & 1) {
			l = max(1LL, l - b[i]);
			r = max(-4 * m, min(m, r - b[i]));
		}
		else {
			long long t = l;
			l = max(1LL, b[i] - r);
			r = max(-4 * m, min(m, b[i] - t));
		}
		//cout << l << ' ' << r << endl;
	}
	if(l > r) puts("-1");
	else {
		printf("%d\n", n + 1);
		for(int i = n; i >= 0; i--) {
			a[i] = l;
			if((i + 1) & 1) l += b[i - 1];
			else l = b[i - 1] - l;
		}
		for(int i = 0; i <= n; i++) printf("%lld\n", a[i]);
	}
	return 0;
}
0