結果
| 問題 |
No.1150 シュークリームゲーム(Easy)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-08-07 22:10:31 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 22 ms / 2,000 ms |
| コード長 | 540 bytes |
| コンパイル時間 | 2,638 ms |
| コンパイル使用メモリ | 194,844 KB |
| 最終ジャッジ日時 | 2025-01-12 16:59:16 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 43 |
コンパイルメッセージ
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[2*n+i]=a[i];
| ~~~~~^~~~~~~~~~~~
ソースコード
#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(3*n);
rep(i,n) scanf("%d",&a[i]), a[n+i]=a[2*n+i]=a[i];
vector<lint> cum(3*n+1);
rep(i,3*n) cum[i+1]=cum[i]+a[i];
s+=n; t+=n;
if(t<s) t+=n;
lint ans=-INF;
rep(l,3*n){
int r=l+(n+1)/2;
if(s-(s-(t-n))/2<=l && r<=s+(t-s)/2+1){
ans=max(ans,2*(cum[r]-cum[l])-cum[n]);
}
}
printf("%lld\n",ans);
return 0;
}