結果

問題 No.451 575
ユーザー kotatsugamekotatsugame
提出日時 2020-03-02 23:34:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 206 ms / 2,000 ms
コード長 614 bytes
コンパイル時間 559 ms
コンパイル使用メモリ 67,292 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 22:56:33
合計ジャッジ時間 4,434 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 4 ms
5,376 KB
testcase_06 AC 11 ms
5,376 KB
testcase_07 AC 73 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 4 ms
5,376 KB
testcase_10 AC 52 ms
5,376 KB
testcase_11 AC 156 ms
5,376 KB
testcase_12 AC 206 ms
5,376 KB
testcase_13 AC 204 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 4 ms
5,376 KB
testcase_16 AC 13 ms
5,376 KB
testcase_17 AC 73 ms
5,376 KB
testcase_18 AC 73 ms
5,376 KB
testcase_19 AC 48 ms
5,376 KB
testcase_20 AC 10 ms
5,376 KB
testcase_21 AC 4 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 205 ms
5,376 KB
testcase_24 AC 103 ms
5,376 KB
testcase_25 AC 1 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 3 ms
5,376 KB
testcase_29 AC 9 ms
5,376 KB
testcase_30 AC 72 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 16 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;
int N;
long B[1<<17],A[1<<17];
main()
{
	cin>>N;
	for(int i=0;i<N;i++)cin>>B[i];
	long cumsum=0;
	long T=2e18;
	long L=1,R=T/2;
	for(int i=0;i<N;i++)
	{
		if(i%4==0||i%4==3)
		{
			cumsum+=B[i];
		}
		else
		{
			cumsum-=B[i];
		}
		if(i%4<2)
		{
			L=max(L,cumsum-T/2);
			R=min(R,cumsum-1);
		}
		else
		{
			L=max(L,cumsum+1);
			R=min(R,cumsum+T/2);
		}
		if(L>R)
		{
			cout<<-1<<endl;
			return 0;
		}
	}
	cout<<N+1<<endl;
	cout<<L<<endl;
	for(int i=0;i<N;i++)
	{
		if(i%2==0)
		{
			L=B[i]-L;
		}
		else
		{
			L=L-B[i];
		}
		cout<<L<<endl;
	}
}
0