結果

問題 No.2601 Very Poor
ユーザー hanagehanage
提出日時 2024-01-12 21:42:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 411 ms / 2,000 ms
コード長 916 bytes
コンパイル時間 2,146 ms
コンパイル使用メモリ 207,676 KB
実行使用メモリ 17,756 KB
最終ジャッジ日時 2024-03-20 19:46:14
合計ジャッジ時間 11,727 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 4 ms
6,676 KB
testcase_06 AC 4 ms
6,676 KB
testcase_07 AC 4 ms
6,676 KB
testcase_08 AC 4 ms
6,676 KB
testcase_09 AC 4 ms
6,676 KB
testcase_10 AC 4 ms
6,676 KB
testcase_11 AC 4 ms
6,676 KB
testcase_12 AC 4 ms
6,676 KB
testcase_13 AC 4 ms
6,676 KB
testcase_14 AC 5 ms
6,676 KB
testcase_15 AC 387 ms
17,756 KB
testcase_16 AC 378 ms
17,756 KB
testcase_17 AC 398 ms
17,756 KB
testcase_18 AC 407 ms
17,756 KB
testcase_19 AC 406 ms
17,756 KB
testcase_20 AC 395 ms
17,756 KB
testcase_21 AC 401 ms
17,756 KB
testcase_22 AC 409 ms
17,756 KB
testcase_23 AC 393 ms
17,756 KB
testcase_24 AC 403 ms
17,756 KB
testcase_25 AC 406 ms
17,756 KB
testcase_26 AC 411 ms
17,756 KB
testcase_27 AC 405 ms
17,756 KB
testcase_28 AC 405 ms
17,756 KB
testcase_29 AC 402 ms
17,756 KB
testcase_30 AC 399 ms
17,756 KB
testcase_31 AC 405 ms
17,756 KB
testcase_32 AC 405 ms
17,756 KB
testcase_33 AC 404 ms
17,756 KB
testcase_34 AC 403 ms
17,756 KB
testcase_35 AC 3 ms
6,676 KB
testcase_36 AC 4 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/segtree>
using namespace atcoder;

long long op(long long a, long long b) {
  return a + b;
}

long long e() {
  return (long long)0;
}

int main() {
  int N;
  long long X;
  cin >> N >> X;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < N; i++) {
    A.push_back(A[i]);
  }
  segtree<long long, op, e> seg(2 * N);
  for (int i = 0; i < 2 * N; i++) {
    seg.set(i, A[i]);
  }
  long long ans = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] > X) {
      continue;
    }
    int ac = i, wa = i + N;
    while (abs(ac - wa) > 1) {
      int wj = (ac + wa) / 2;
      // cout << ac << " " << wa << " " << wj << endl;
      if (seg.prod(i, wj + 1) <= X) {
        ac = wj;
      } else {
        wa = wj;
      }
    }
    ans = max(ans, seg.prod(i, ac + 1));
  }
  cout << ans << endl;
  return 0;
}
0