結果

問題 No.2601 Very Poor
ユーザー Aeren
提出日時 2024-01-12 21:32:11
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 610 bytes
コンパイル時間 2,901 ms
コンパイル使用メモリ 246,816 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-09-30 06:15:59
合計ジャッジ時間 4,869 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
// #include <x86intrin.h>
using namespace std;
#if __cplusplus >= 202002L
using namespace numbers;
#endif



int main(){
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(ios::badbit | ios::failbit);
	int n, th;
	cin >> n >> th;
	vector<int> a(n);
	copy_n(istream_iterator<int>(cin), n, a.begin());
	for(auto i = 0; i < n; ++ i){
		a.push_back(a[i]);
	}
	long long res = 0;
	for(auto l = 0, r = 0; l < n; ++ l){
		static long long sum = 0;
		while(r < l + n && sum + a[r] <= th){
			sum += a[r ++];
		}
		res = max(res, sum);
		sum -= a[l];
	}
	cout << res << "\n";
	return 0;
}

/*

*/
0