結果

問題 No.1150 シュークリームゲーム(Easy)
ユーザー bachoppibachoppi
提出日時 2020-08-07 22:57:48
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 46 ms / 2,000 ms
コード長 1,117 bytes
コンパイル時間 3,138 ms
コンパイル使用メモリ 121,648 KB
実行使用メモリ 4,700 KB
最終ジャッジ日時 2023-10-25 03:57:10
合計ジャッジ時間 4,441 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 36 ms
4,588 KB
testcase_23 AC 37 ms
4,596 KB
testcase_24 AC 34 ms
4,544 KB
testcase_25 AC 36 ms
4,576 KB
testcase_26 AC 39 ms
4,648 KB
testcase_27 AC 41 ms
4,660 KB
testcase_28 AC 44 ms
4,692 KB
testcase_29 AC 36 ms
4,560 KB
testcase_30 AC 38 ms
4,616 KB
testcase_31 AC 37 ms
4,596 KB
testcase_32 AC 37 ms
4,580 KB
testcase_33 AC 38 ms
4,620 KB
testcase_34 AC 40 ms
4,648 KB
testcase_35 AC 40 ms
4,664 KB
testcase_36 AC 41 ms
4,680 KB
testcase_37 AC 42 ms
4,692 KB
testcase_38 AC 35 ms
4,568 KB
testcase_39 AC 36 ms
4,568 KB
testcase_40 AC 38 ms
4,612 KB
testcase_41 AC 40 ms
4,668 KB
testcase_42 AC 31 ms
4,700 KB
testcase_43 AC 32 ms
4,700 KB
testcase_44 AC 46 ms
4,700 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}

0