結果

問題 No.1375 Divide and Update
ユーザー kotatsugamekotatsugame
提出日時 2021-02-05 21:46:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 341 ms / 2,000 ms
コード長 465 bytes
コンパイル時間 475 ms
コンパイル使用メモリ 66,396 KB
実行使用メモリ 8,020 KB
最終ジャッジ日時 2023-09-15 07:35:45
合計ジャッジ時間 6,130 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,432 KB
testcase_01 AC 2 ms
5,400 KB
testcase_02 AC 2 ms
5,444 KB
testcase_03 AC 2 ms
5,456 KB
testcase_04 AC 2 ms
5,456 KB
testcase_05 AC 2 ms
5,500 KB
testcase_06 AC 2 ms
5,400 KB
testcase_07 AC 2 ms
5,432 KB
testcase_08 AC 2 ms
5,404 KB
testcase_09 AC 2 ms
5,436 KB
testcase_10 AC 294 ms
7,444 KB
testcase_11 AC 274 ms
7,292 KB
testcase_12 AC 146 ms
6,412 KB
testcase_13 AC 124 ms
6,264 KB
testcase_14 AC 336 ms
7,900 KB
testcase_15 AC 332 ms
8,020 KB
testcase_16 AC 337 ms
7,780 KB
testcase_17 AC 337 ms
7,736 KB
testcase_18 AC 340 ms
7,992 KB
testcase_19 AC 341 ms
7,836 KB
testcase_20 AC 291 ms
7,784 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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[2<<17];
long L[2<<17],R[2<<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