結果

問題 No.2601 Very Poor
ユーザー Today03
提出日時 2024-01-13 18:21:54
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 411 bytes
コンパイル時間 2,145 ms
コンパイル使用メモリ 193,196 KB
最終ジャッジ日時 2025-02-18 19:46:42
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#ifdef LOCAL
#include "./debug.cpp"
#else
#define debug(...)
#define print_line
#endif
using namespace std;
using ll=long long;

int main(){
	int N;
	ll X;
	cin>>N>>X;
	vector<ll>A(N);
	for(int i=0;i<N;i++)cin>>A[i];

	ll ans=0,now=0;
	int l=0,r=0;
	while(l<N){
		while(r<l+N&&now+A[r%N]<=X){
			now+=A[r%N];
			ans=max(ans,now);
			r++;
		}
		now-=A[l];
		l++;
	}

	cout<<ans<<endl;
}
0