結果

問題 No.451 575
ユーザー _____TAB__________TAB_____
提出日時 2016-12-02 12:13:42
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 782 bytes
コンパイル時間 759 ms
コンパイル使用メモリ 10,856 KB
実行使用メモリ 17,452 KB
最終ジャッジ日時 2023-08-22 13:03:32
合計ジャッジ時間 7,570 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
8,300 KB
testcase_01 AC 16 ms
8,152 KB
testcase_02 AC 15 ms
8,184 KB
testcase_03 AC 15 ms
7,832 KB
testcase_04 AC 16 ms
7,848 KB
testcase_05 AC 32 ms
8,728 KB
testcase_06 AC 70 ms
9,900 KB
testcase_07 AC 298 ms
17,452 KB
testcase_08 AC 16 ms
7,820 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 399 ms
16,216 KB
testcase_14 AC 16 ms
8,228 KB
testcase_15 AC 26 ms
8,636 KB
testcase_16 AC 60 ms
9,464 KB
testcase_17 AC 301 ms
16,076 KB
testcase_18 WA -
testcase_19 AC 204 ms
13,452 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 16 ms
7,784 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 16 ms
7,844 KB
testcase_26 AC 15 ms
7,784 KB
testcase_27 AC 17 ms
7,844 KB
testcase_28 AC 19 ms
8,268 KB
testcase_29 AC 44 ms
9,212 KB
testcase_30 AC 303 ms
16,864 KB
testcase_31 AC 16 ms
8,152 KB
testcase_32 AC 20 ms
8,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n  = int(input())
b = []
f = 0
a_01 = []
a_23 = [1]
m_01 = 1
m_23 = 1

for i in range(n):
	b.append(int(input()))
	if f <= 1:
		if f == 0:
			if b[i] == 1:
				print(-1)
				exit()
			ai = b[i] - a_23[-1]
		else:
			ai = a_01[-1] - b[i]
		a_01.append(ai)
		m_01 = min(m_01, ai)
	else:
		if f == 2:
			ai = b[i] - a_01[-1]
			if b[i] == 1:
				print(-1)
				exit()
		else:
			ai = a_23[-1] - b[i]
		a_23.append(ai)
		m_23 = min(m_23, ai)
	f = (f + 1) % 4

#print(a_01)
#print(a_23)

if m_23 + m_01 <= 0:
	print(-1)
else:
	f = 3
	a_01.reverse()
	a_23.reverse()
	print(n+1)
	if m_01 > 0 and m_23 > 0:
		m = 0
	elif m_01 < m_23:
		m = -m_01 + 1
	else:
		m = m_23 - 1

	for i in range(n + 1):
		if f <= 1:
			a = a_01.pop() + m
		else:
			a = a_23.pop() - m
		f = (f + 1) % 4
		print(a)
0