結果

問題 No.2601 Very Poor
ユーザー vjudge1
提出日時 2025-07-19 20:35:33
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 690 bytes
コンパイル時間 5,040 ms
コンパイル使用メモリ 212,692 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-07-19 20:35:41
合計ジャッジ時間 7,803 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 11 WA * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;

int n, x;

int main() {
  //freopen("rental.in" , "r", stdin);
  //freopen("rental.out" , "w", stdout);
  ios::sync_with_stdio(false); cin.tie(nullptr);

  cin >> n >> x;

  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];

  int64_t m = 0;
  for (int i =0 ; i < n; ++i) {
    m += a[i];
  }

  vector<int64_t> sum(n * 2 + 1);
  for (int i = 0; i < 2 * n; ++i) {
    sum[i + 1] = sum[i] + a[i % n];
  }

  int64_t ans = 0;
  for (int i = 0; i < n; ++i) {
    auto it = lower_bound(sum.begin(), sum.end(), x + sum[i] - 1);
    it--;
    int64_t tmp = *it - sum[i];
    ans = max(ans, min(tmp, m));
  }
  cout << ans;
  return 0;
}

0