結果

問題 No.1925 悪鬼三七次元
ユーザー KudeKude
提出日時 2022-05-03 00:28:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,415 bytes
コンパイル時間 2,612 ms
コンパイル使用メモリ 226,620 KB
実行使用メモリ 6,532 KB
最終ジャッジ日時 2023-09-14 21:43:14
合計ジャッジ時間 5,250 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 15 ms
6,444 KB
testcase_04 AC 15 ms
6,528 KB
testcase_05 AC 15 ms
6,428 KB
testcase_06 AC 16 ms
6,380 KB
testcase_07 AC 15 ms
6,504 KB
testcase_08 AC 15 ms
6,440 KB
testcase_09 AC 15 ms
6,456 KB
testcase_10 AC 16 ms
6,440 KB
testcase_11 AC 16 ms
6,528 KB
testcase_12 AC 15 ms
6,532 KB
testcase_13 AC 16 ms
6,524 KB
testcase_14 AC 16 ms
6,468 KB
testcase_15 AC 15 ms
6,500 KB
testcase_16 AC 16 ms
6,356 KB
testcase_17 AC 15 ms
6,384 KB
testcase_18 AC 15 ms
6,376 KB
testcase_19 AC 16 ms
6,376 KB
testcase_20 AC 15 ms
6,384 KB
testcase_21 AC 16 ms
6,464 KB
testcase_22 AC 15 ms
6,468 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 5 ms
4,380 KB
testcase_26 AC 3 ms
4,380 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 6 ms
4,396 KB
testcase_30 WA -
testcase_31 AC 10 ms
5,120 KB
testcase_32 AC 5 ms
4,380 KB
testcase_33 AC 6 ms
4,376 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 6 ms
4,376 KB
testcase_37 AC 8 ms
4,644 KB
testcase_38 AC 9 ms
4,880 KB
testcase_39 WA -
testcase_40 AC 12 ms
5,644 KB
testcase_41 AC 9 ms
4,904 KB
testcase_42 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
namespace {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
#include<atcoder/all>
#pragma GCC diagnostic pop
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; }
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;

} int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  VI a(n);
  rep(i, n) cin >> a[i];
  constexpr ll INF = 1002003004005006007;
  if (n % 2) {
    int m = n / 2;
    ll ans = INF;
    ll now = accumulate(a.begin(), a.begin() + m, 0LL);
    rep(i, m + 1) {
      now += a[i + m];
      chmin(ans, now);
      now -= a[i];
    }
    cout << ans << '\n';
    return 0;
  }
  int m = n / 2;
  VL accmf(n + 1, INF), accmb(n + 1, INF), accm1f(n + 1, INF), accm1b(n + 1);
  {
    ll now = accumulate(a.begin(), a.begin() + m - 1, 0LL);
    ll acc = INF;
    for(int i = 0; i + m - 1 < n; i++) {
      now += a[i + m - 1];
      chmin(acc, now);
      accmf[i] = acc;
      now -= a[i];
    }
  }
  {
    ll now = accumulate(a.end() - (m - 1), a.end(), 0LL);
    ll acc = INF;
    for(int i = n - m; i >= 0; i--) {
      now += a[i];
      chmin(acc, now);
      accmb[i] = acc;
      now -= a[i + m - 1];
    }
  }
  m++;
  {
    ll now = accumulate(a.begin(), a.begin() + m - 1, 0LL);
    ll acc = INF;
    for(int i = 0; i + m - 1 < n; i++) {
      now += a[i + m - 1];
      chmin(acc, now);
      accm1f[i] = acc;
      now -= a[i];
    }
  }
  {
    ll now = accumulate(a.end() - (m - 1), a.end(), 0LL);
    ll acc = INF;
    for(int i = n - m; i >= 0; i--) {
      now += a[i];
      chmin(acc, now);
      accm1b[i] = acc;
      now -= a[i + m - 1];
    }
  }
  m--;
  ll ans = 0;
  for(int i = 0; i < n - 1; i++) {
    if (i < m - 1) {
      chmax(ans, min(accm1f[i], accmb[i + 2]));
    } else if (i == m - 1) {
      chmax(ans, accm1f[i]);
    } else {
      chmax(ans, min(accmf[i - m], accm1b[i - m + 1]));
    }
  }
  cout << ans << '\n';
}
0