結果
| 問題 | No.2601 Very Poor |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-01-13 17:58:02 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 26 ms / 2,000 ms |
| コード長 | 530 bytes |
| 記録 | |
| コンパイル時間 | 1,972 ms |
| コンパイル使用メモリ | 194,624 KB |
| 最終ジャッジ日時 | 2025-02-18 19:45:23 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 34 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int N,X; cin >> N >> X;
vector<int> A(N);
for(auto &a : A) cin >> a;
for(int i=0; i<N; i++) A.push_back(A.at(i));
int pos = 0,sum = 0,answer = 0;
for(int i=0; i<N; i++){
if(i) sum -= A.at(i-1);
while(pos < i+N){
if(sum+A.at(pos) > X) break;
sum += A.at(pos); pos++;
}
answer = max(answer,sum);
}
cout << answer << endl;
}