結果

問題 No.1375 Divide and Update
ユーザー kotatsugamekotatsugame
提出日時 2021-02-05 21:46:16
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 465 bytes
コンパイル時間 535 ms
コンパイル使用メモリ 66,440 KB
実行使用メモリ 5,008 KB
最終ジャッジ日時 2023-09-15 07:35:22
合計ジャッジ時間 4,058 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 AC 150 ms
5,008 KB
testcase_13 AC 124 ms
4,716 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:8:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    8 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;
int N;
long X,Y;
int A[1<<17];
long L[1<<17],R[1<<17];
main()
{
	cin>>N>>X>>Y;
	long S=0;
	for(int i=0;i<N;i++)
	{
		cin>>A[i];
		S+=A[i];
	}
	L[0]=-9e18;
	long nS=0;
	for(int i=0;i<N-2;i++)
	{
		nS+=X-A[i];
		L[i+1]=max(L[i],nS);
		if(nS<0)nS=0;
	}
	R[N-1]=-9e18;
	nS=0;
	for(int i=N-1;i>1;i--)
	{
		nS+=Y-A[i];
		R[i-1]=max(R[i],nS);
		if(nS<0)nS=0;
	}
	for(int i=1;i<N-1;i++)cout<<S+L[i]+R[i]<<endl;
}
0