結果

問題 No.2601 Very Poor
ユーザー zezero
提出日時 2024-01-12 21:46:07
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 820 bytes
コンパイル時間 3,206 ms
コンパイル使用メモリ 158,120 KB
最終ジャッジ日時 2025-02-18 18:02:42
ジャッジサーバーID
(参考情報)
judge3 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 4 WA * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <cstring>
#include <stack>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < int(n);i++)

int main(){
  int n;
  ll x;
  cin >> n >> x;
  vector<int> a(2*n);
  for (int i = 0; i < n;i++){
    cin >> a[i];
  }
  for (int i = 0; i < n;i++){
    a[n+i] = a[i];
  }
  int s = 0,t = 0;
  ll ans = 0;
  ll res = 0;
  while(s < 2*n){
    while(t < 2*n && res + a[t] <= x && t-s+1 <= n){
      res += a[t];
      t++;
    }
    ans = max(ans,res);
    res = 0;
    if (s == t){
      s++;
      t++;
    }
    else{
      s = t;
    }
  }
  cout << ans << endl;
  
  return 0;
}
0