結果

問題 No.1104 オンライン点呼
ユーザー kotatsugamekotatsugame
提出日時 2020-07-04 02:36:58
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 377 bytes
コンパイル時間 641 ms
コンパイル使用メモリ 66,300 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-17 07:03:40
合計ジャッジ時間 2,728 ms
ジャッジサーバーID
(参考情報)
judge6 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24 WA * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;
int N;
long K,A[1<<17],B[1<<17];
long t[1<<17];
main()
{
	cin>>N>>K;
	for(int i=0;i<N;i++)cin>>A[i];
	for(int i=0;i<N;i++)cin>>B[i];
	t[0]=0;
	long ans=0;
	for(int i=1;i<N;i++)
	{
		t[i]=t[i-1]+A[i-1]+B[i];
		if(i>=2&&t[i]>t[i-2]+A[i-2]+B[i]+K)t[i]=t[i-2]+A[i-2]+B[i]+K;
		if(ans<t[i])ans=t[i];
	}
	cout<<ans<<endl;
}
0