結果
| 問題 | 
                            No.1150 シュークリームゲーム(Easy)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             bachoppi
                         | 
                    
| 提出日時 | 2020-08-07 22:57:48 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 52 ms / 2,000 ms | 
| コード長 | 1,117 bytes | 
| コンパイル時間 | 4,322 ms | 
| コンパイル使用メモリ | 117,112 KB | 
| 最終ジャッジ日時 | 2025-01-12 17:55:09 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 43 | 
ソースコード
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define pai 3.141592653589793238462643383279
int main(){
  int n, s, t; cin >> n >> s >> t; s--; t--; ll a[n]; ll sum=0;
  rep(i, n){
    cin >> a[i]; sum+=a[i];
  }
  vector<ll>tmp;
  if(s<t) s+=n;
  for(int i=s-(s-t)/2; i<s; i++){
    tmp.push_back(a[i%n]);
  }
  if(s>=n) s-=n;
  if(s>t) t+=n;
  for(int i=s; i<=(t-s)/2+s; i++){
    tmp.push_back(a[i%n]); 
  }
  ll nyan = 0;
  rep(i, (n+1)/2){
    nyan+=tmp[i];
  }
  ll ans=nyan;
  //for(auto k: tmp){
    //cout << k << "o " << endl;
  //}
  for(int i=(n+1)/2; i<tmp.size(); i++){
    nyan+=tmp[i]; nyan-=tmp[i-(n+1)/2];  ans=max(ans, nyan);
  }
  cout << 2*ans-sum << endl;
}
            
            
            
        
            
bachoppi