結果

問題 No.1150 シュークリームゲーム(Easy)
ユーザー tnakao0123tnakao0123
提出日時 2020-08-09 01:56:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,662 bytes
コンパイル時間 761 ms
コンパイル使用メモリ 93,820 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-10 11:19:21
合計ジャッジ時間 2,793 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 WA -
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,948 KB
testcase_10 WA -
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 2 ms
6,944 KB
testcase_22 AC 15 ms
6,940 KB
testcase_23 AC 15 ms
6,944 KB
testcase_24 WA -
testcase_25 AC 14 ms
6,944 KB
testcase_26 AC 16 ms
6,940 KB
testcase_27 AC 16 ms
6,944 KB
testcase_28 WA -
testcase_29 AC 13 ms
6,944 KB
testcase_30 AC 15 ms
6,940 KB
testcase_31 AC 15 ms
6,944 KB
testcase_32 AC 14 ms
6,940 KB
testcase_33 AC 15 ms
6,944 KB
testcase_34 AC 16 ms
6,944 KB
testcase_35 AC 16 ms
6,944 KB
testcase_36 AC 16 ms
6,944 KB
testcase_37 AC 16 ms
6,940 KB
testcase_38 AC 13 ms
6,940 KB
testcase_39 AC 14 ms
6,944 KB
testcase_40 WA -
testcase_41 AC 16 ms
6,940 KB
testcase_42 AC 15 ms
6,948 KB
testcase_43 AC 14 ms
6,940 KB
testcase_44 AC 17 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 1150.cc:  No.1150 シュークリームゲーム(Easy) - yukicoder
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;
const int MAX_N2 = MAX_N * 2;
const long long LINF = 1LL << 62;

/* typedef */

typedef long long ll;

/* global variables */

int as[MAX_N2];
ll ass[MAX_N2 + 1];

/* subroutines */

/* main */

int main() {
  int n, s, t;
  scanf("%d%d%d", &n, &s, &t);
  s--, t--;
  int n2 = n * 2;

  for (int i = 0; i < n; i++) scanf("%d", as + i), as[i + n] = as[i];
  for (int i = 0; i < n2; i++) ass[i + 1] = ass[i] + as[i];

  int s0, t0, t1, s1;
  if (s < t)
    s0 = s, t0 = t1 = t, s1 = s + n;
  else
    s0 = s, t0 = t + n, t1 = t, s1 = s;

  int k = t0 - (s0 + 1), l = s1 - (t1 + 1);
  int hk = k / 2, hl = l / 2;
  int w0 = t0 - hk, w1 = t1 + 1 + hl;
  ll x = as[s], y = as[t];

  if (! (k & 1) || ! (l & 1)) {
    x += (ass[w0] - ass[s0 + 1]) + (ass[s1] - ass[w1]);
    y += (ass[t0] - ass[w0]) + (ass[w1] - ass[t1 + 1]);
  }
  else {
    if (as[w0 - 1] > as[w1 - 1]) {
      x += (ass[w0] - ass[s0 + 1]) + (ass[s1] - ass[w1 + 1]);
      y += (ass[t0] - ass[w0]) + (ass[w1 + 1] - ass[t1 + 1]);
    }
    else {
      x += (ass[w0 - 1] - ass[s0 + 1]) + (ass[s1] - ass[w1]);
      y += (ass[t0] - ass[w0 - 1]) + (ass[w1] - ass[t1 + 1]);
    }
  }

  printf("%lld\n", x - y);
  return 0;
}
0