結果

問題 No.1150 シュークリームゲーム(Easy)
ユーザー furafura
提出日時 2020-08-07 21:56:26
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 551 bytes
コンパイル時間 2,125 ms
コンパイル使用メモリ 194,712 KB
最終ジャッジ日時 2025-01-12 16:48:27
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 9 WA * 34
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:11:25: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |         int n,s,t; scanf("%d%d%d",&n,&s,&t); s--; t--;
      |                    ~~~~~^~~~~~~~~~~~~~~~~~~
main.cpp:13:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |         rep(i,n) scanf("%d",&a[i]), a[n+i]=a[i];
      |                  ~~~~~^~~~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

const long long INF=1LL<<61;

int main(){
	int n,s,t; scanf("%d%d%d",&n,&s,&t); s--; t--;
	vector<int> a(2*n);
	rep(i,n) scanf("%d",&a[i]), a[n+i]=a[i];

	vector<lint> cum(2*n+1);
	rep(i,2*n) cum[i+1]=cum[i]+a[i];

	lint ans=-INF;
	rep(l,n){
		int r=l+(n+1)/2;
		if((l<=s && s<r) || (l<=s+n && s+n<r)){
			if(!(l<=t && t<r) && !(l<=t+n && t+n<r)){
				ans=max(ans,2*(cum[r]-cum[l])-cum[n]);
			}
		}
	}
	printf("%lld\n",ans);

	return 0;
}
0