結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
8,224 KB
testcase_01 AC 15 ms
7,860 KB
testcase_02 AC 15 ms
8,284 KB
testcase_03 AC 15 ms
7,732 KB
testcase_04 AC 15 ms
7,892 KB
testcase_05 AC 31 ms
8,680 KB
testcase_06 AC 68 ms
9,968 KB
testcase_07 AC 285 ms
17,400 KB
testcase_08 AC 15 ms
7,892 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 379 ms
16,016 KB
testcase_14 AC 15 ms
8,292 KB
testcase_15 AC 25 ms
8,620 KB
testcase_16 AC 58 ms
9,460 KB
testcase_17 AC 288 ms
16,176 KB
testcase_18 AC 289 ms
16,160 KB
testcase_19 AC 193 ms
13,564 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 16 ms
7,768 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 16 ms
7,860 KB
testcase_26 AC 16 ms
7,856 KB
testcase_27 AC 17 ms
7,864 KB
testcase_28 AC 18 ms
8,368 KB
testcase_29 AC 43 ms
9,216 KB
testcase_30 AC 289 ms
16,700 KB
testcase_31 AC 15 ms
8,136 KB
testcase_32 AC 20 ms
8,384 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 <= 1:
	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