提出 #72055471


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;
inline long long read()
{
	long long x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();}
	return x*f;
}
void out(long long x)
{
    if(x<0)putchar('-'),x=-x;
    if(x<10)putchar(x+'0');
    else out(x/10),putchar(x%10+'0');
}
long long n;
long long a[300005],b[300005],c[300005];
long long qza[300005],qzb[300005],qzc[300005];
long long jq[300005];
long long maxa[300005];
int main(){
	n=read();
	for(long long i=1;i<=n;i++) a[i]=read();
	for(long long i=1;i<=n;i++) b[i]=read();
	for(long long i=1;i<=n;i++) c[i]=read();
	for(long long i=1;i<=n;i++) qza[i]=qza[i-1]+a[i];
	for(long long i=1;i<=n;i++) qzb[i]=qzb[i-1]+b[i];
	for(long long i=1;i<=n;i++) qzc[i]=qzc[i-1]+c[i];
	for(long long i=2;i<n;i++) jq[i]=qzb[i]+qzc[n]-qzc[i];
	for(long long i=n-1;i>=2;i--) maxa[i]=max(maxa[i+1],jq[i]);

   /* for(long long i=1;i<=n;i++) cout<<qza[i]<<" ";
    cout<<endl;
	for(long long i=1;i<=n;i++) cout<<qzb[i]<<" ";
	cout<<endl;
	for(long long i=1;i<=n;i++) cout<<qzc[i]<<" ";
	cout<<endl;
	for(long long i=1;i<=n;i++) cout<<jq[i]<<" ";
	cout<<endl;
	for(long long i=1;i<=n;i++) cout<<maxa[i]<<" ";
	cout<<endl;*/
	
	
	long long ans=0;
	for(long long i=1;i<=n-2;i++) ans=max(ans,maxa[i+1]-qzb[i]+qza[i]);
	cout<<ans;
	return 0;
}

提出情報

提出日時
問題 D - Tail of Snake
ユーザ Fireflies
言語 C++23 (GCC 15.2.0)
得点 400
コード長 1402 Byte
結果 AC
実行時間 28 ms
メモリ 22448 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 3
AC × 38
セット名 テストケース
Sample sample00.txt, sample01.txt, sample02.txt
All sample00.txt, sample01.txt, sample02.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt, testcase12.txt, testcase13.txt, testcase14.txt, testcase15.txt, testcase16.txt, testcase17.txt, testcase18.txt, testcase19.txt, testcase20.txt, testcase21.txt, testcase22.txt, testcase23.txt, testcase24.txt, testcase25.txt, testcase26.txt, testcase27.txt, testcase28.txt, testcase29.txt, testcase30.txt, testcase31.txt, testcase32.txt, testcase33.txt, testcase34.txt
ケース名 結果 実行時間 メモリ
sample00.txt AC 1 ms 3676 KiB
sample01.txt AC 1 ms 3668 KiB
sample02.txt AC 1 ms 3760 KiB
testcase00.txt AC 1 ms 3520 KiB
testcase01.txt AC 1 ms 3416 KiB
testcase02.txt AC 1 ms 3680 KiB
testcase03.txt AC 24 ms 22180 KiB
testcase04.txt AC 23 ms 22104 KiB
testcase05.txt AC 23 ms 22288 KiB
testcase06.txt AC 23 ms 22288 KiB
testcase07.txt AC 23 ms 22368 KiB
testcase08.txt AC 23 ms 22288 KiB
testcase09.txt AC 25 ms 22128 KiB
testcase10.txt AC 25 ms 22448 KiB
testcase11.txt AC 26 ms 22104 KiB
testcase12.txt AC 23 ms 22408 KiB
testcase13.txt AC 23 ms 22268 KiB
testcase14.txt AC 23 ms 22288 KiB
testcase15.txt AC 19 ms 22116 KiB
testcase16.txt AC 19 ms 22376 KiB
testcase17.txt AC 10 ms 9664 KiB
testcase18.txt AC 25 ms 20096 KiB
testcase19.txt AC 28 ms 22180 KiB
testcase20.txt AC 20 ms 16656 KiB
testcase21.txt AC 17 ms 14640 KiB
testcase22.txt AC 28 ms 22280 KiB
testcase23.txt AC 5 ms 6364 KiB
testcase24.txt AC 21 ms 17256 KiB
testcase25.txt AC 28 ms 22324 KiB
testcase26.txt AC 20 ms 17124 KiB
testcase27.txt AC 25 ms 20056 KiB
testcase28.txt AC 28 ms 22268 KiB
testcase29.txt AC 18 ms 16228 KiB
testcase30.txt AC 20 ms 16804 KiB
testcase31.txt AC 27 ms 22376 KiB
testcase32.txt AC 26 ms 21392 KiB
testcase33.txt AC 23 ms 18912 KiB
testcase34.txt AC 27 ms 22336 KiB