結果

問題 No.1150 シュークリームゲーム(Easy)
ユーザー chocono2230chocono2230
提出日時 2020-08-07 22:59:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,942 bytes
コンパイル時間 1,869 ms
コンパイル使用メモリ 173,360 KB
実行使用メモリ 6,416 KB
最終ジャッジ日時 2023-10-25 04:05:02
合計ジャッジ時間 4,950 ms
ジャッジサーバーID
(参考情報)
judge13 / 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 WA -
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 WA -
testcase_11 AC 2 ms
4,348 KB
testcase_12 WA -
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 51 ms
6,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

void fc(vector<ll> &sxl, vector<ll> &sxr, vector<ll> &syl, vector<ll> &syr, ll &xls, ll &xrs, int &xl, int &xr){
  // cerr << xl << " " << xr << endl;
  // for(ll tmp : sxl) cerr << tmp << " ";
  // cerr << endl;
  // for(ll tmp : sxr) cerr << tmp << " ";
  // cerr << endl;
  ll mr = sxr.at((sxr.size()+xr)/2) - xrs;
  ll ml = sxl.at((sxl.size()+xl)/2) - xls;
  if(mr > ml){
    xr++;
    xrs = sxr.at(xr);
    syl.pop_back();
  }else{
    xl++;
    xls = sxl.at(xl);
    syr.pop_back();
  }
}

int main(){
  int n, s, t;
  cin >> n >> s >> t;
  s--; t--;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  vector<ll> sxl, sxr, syl, syr;
  sxl.push_back(a.at(s));
  sxr.push_back(a.at(s));
  syl.push_back(a.at(t));
  syr.push_back(a.at(t));
  for(int i = (s-1+n)%n; i != t; i = (i-1+n)%n){
    sxl.push_back(sxl.back()+a.at(i));
  }
  for(int i = (s+1)%n; i != t; i = (i+1) % n){
    sxr.push_back(sxr.back()+a.at(i));
  }
  for(int i = (t-1+n)%n; i != s; i = (i-1+n)%n){
    syl.push_back(syl.back()+a.at(i));
  }
  for(int i = (t+1)%n; i != s; i = (i+1)%n){
    syr.push_back(syr.back()+a.at(i));
  }
  int xl = 0, xr = 0, yl = 0, yr = 0;
  ll xls = a.at(s), xrs = a.at(s), yls = a.at(t), yrs = a.at(t);
  rep(i, n-2){
    if(i % 2 == 0){
      fc(sxl, sxr, syl, syr, xls, xrs, xl, xr);
    }else{
      fc(syl, syr, sxl, sxr, yls, yrs, yl, yr);
    }
  }
  ll x = xls + xrs - a.at(s), y = yls + yrs - a.at(t);
  cout << x - y << endl;
  return 0;
}
0