結果

問題 No.451 575
ユーザー square1001square1001
提出日時 2017-03-07 19:10:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 589 bytes
コンパイル時間 1,383 ms
コンパイル使用メモリ 163,768 KB
実行使用メモリ 4,536 KB
最終ジャッジ日時 2023-09-05 21:59:24
合計ジャッジ時間 6,289 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const long long m = 1000000000000000000;
int n; long long b[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) {
			long long t = l;
			l = max(1LL, b[i] - r);
			r = min(m, b[i] - t);
		}
		else {
			l = max(1LL, l - b[i]);
			r = min(m, r - b[i]);
		}
	}
	if(l > r) puts("-1");
	else {
		printf("%d\n", n + 1);
		for(int i = 0; i < n + 1; i++) {
			printf("%lld\n", l);
			if(i & 1) l -= b[i];
			else l = b[i] - l;
		}
	}
	return 0;
}
0