結果
問題 | No.2601 Very Poor |
ユーザー |
|
提出日時 | 2024-01-12 21:46:07 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 820 bytes |
コンパイル時間 | 3,016 ms |
コンパイル使用メモリ | 166,992 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-27 21:49:40 |
合計ジャッジ時間 | 5,641 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 4 WA * 30 |
ソースコード
#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;}