結果

問題 No.1150 シュークリームゲーム(Easy)
ユーザー どららどらら
提出日時 2020-08-07 22:34:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,197 bytes
コンパイル時間 8,671 ms
コンパイル使用メモリ 171,616 KB
実行使用メモリ 5,624 KB
最終ジャッジ日時 2023-10-25 02:28:28
合計ジャッジ時間 5,930 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,348 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1 ms
4,348 KB
testcase_08 WA -
testcase_09 AC 2 ms
4,348 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 2 ms
4,348 KB
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 AC 32 ms
5,624 KB
testcase_43 AC 33 ms
5,624 KB
testcase_44 AC 47 ms
5,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  int s, t;
  cin >> s >> t;
  s--; t--;
  vector<ll> tmp;
  rep(i,N){
    ll a;
    cin >> a;
    tmp.push_back(a);
  }
  vector<ll> v;
  rep(i,N){
    v.push_back(tmp[(s+i)%N]);
  }
  s = 0;
  t = (t+N-s)%N;

  ll X = v[s], Y = v[t];
  int rhs = t-1-s;
  int lhs = N-2-rhs;
  
  if(lhs%2==0 && rhs%2==0){
    {
      int p = s, q = t;
      while(true){
        p++; q--;
        if(p==(q+1)%N) break;
        X += v[p];
        Y += v[q];
      }
    }
    {
      int p = s, q = t;
      while(true){
        p=(p-1+N)%N;
        q=(q+1)%N;
        if(q==(p+1)%N) break;
        X += v[p];
        Y += v[q];
      }
    }
  }
  if(lhs%2==0 && rhs%2==1){
    {
      int p = s, q = t;
      while(true){
        p++; q--;
        X += v[p];
        if(p==q) break;
        Y += v[q];
      }
    }
    {
      int p = s, q = t;
      while(true){
        p=(p-1+N)%N;
        q=(q+1)%N;
        if(q==(p+1)%N) break;
        X += v[p];
        Y += v[q];
      }
    }
  }
  if(lhs%2==1 && rhs%2==0){
    {
      int p = s, q = t;
      while(true){
        p++; q--;
        if(p==(q+1)%N) break;
        X += v[p];
        Y += v[q];
      }
    }
    {
      int p = s, q = t;
      while(true){
        p=(p-1+N)%N;
        q=(q+1)%N;
        X += v[p];
        if(q==p) break;
        Y += v[q];
      }
    }
  }
  if(lhs%2==1 && rhs%2==1){
    int pp, qq;
    {
      int p = s, q = t;
      while(true){
        p++; q--;
        if(p==q) break;
        X += v[p];
        Y += v[q];
      }
      pp = p;
    }
    {
      int p = s, q = t;
      while(true){
        p=(p-1+N)%N;
        q=(q+1)%N;
        if(p==q) break;
        X += v[p];
        Y += v[q];
      }
      qq = p;
    }
    
    if(pp > qq){
      X += v[pp];
      Y += v[qq];
    }else{
      X += v[qq];
      Y += v[pp];
    }
  }

  cout << X - Y << endl;
  
  return 0;
}

0