結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2 ms
6,940 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
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 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;

  ll minp0 = -LINF, minp1 = -LINF;

  if (s0 + 1 < t0) {
    int l = (t0 + 1 - s0) / 2;
    int w = t0 + 1 - l;
    ll q = (ass[w] - ass[s0]) - (ass[t0 + 1] - ass[w]);
    ll r = (ass[t0] - ass[s0]) - (ass[s1] - ass[t1]);
    minp0 = min(q, r);
  }
  if (t1 + 1 < s1) {
    int l = (s1 + 1 - t1) / 2;
    int w = t1 + l;
    ll q = (ass[s1 + 1] - ass[w]) - (ass[w] - ass[t1]);
    ll r = (ass[s1 + 1] - ass[t1 + 1]) - (ass[t0 + 1] - ass[s0 + 1]);
    minp1 = min(q, r);
  }

  printf("%lld\n", max(minp0, minp1));
  return 0;
}
0