結果
| 問題 |
No.2601 Very Poor
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-01-15 15:53:11 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 807 bytes |
| コンパイル時間 | 1,205 ms |
| コンパイル使用メモリ | 111,564 KB |
| 最終ジャッジ日時 | 2025-02-18 20:11:45 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 32 WA * 2 |
ソースコード
#include <iostream>
#include <iomanip>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <bitset>
#include <ctype.h>
#include <numeric>
#include<unordered_set>
using namespace std;
using ll = long long;
//yukicoder414C
int main() {
ll n, x;
cin >> n >> x;
vector<ll> a(2 * n), sum(2 * n + 1);
for (int i = 0; i < n; i++) {
cin >> a[i];
a[i + n] = a[i];
}
sum[1] = a[0];
for (int i = 2; i < 2 * n + 1; i++) {
sum[i] = sum[i - 1] + a[i - 1];
}
ll mx = 0;
ll left = 0;
ll right = 1;
ll ans = 0;
while (right < 2 * n + 1) {
ll num = sum[right] - sum[left];
if (num <= x) {
right++;
ans = max(ans, num);
}
else {
left++;
}
}
cout << ans << endl;
}