結果
| 問題 |
No.2601 Very Poor
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2024-01-14 01:24:40 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 30 ms / 2,000 ms |
| コード長 | 775 bytes |
| コンパイル時間 | 364 ms |
| コンパイル使用メモリ | 41,800 KB |
| 実行使用メモリ | 7,108 KB |
| 最終ジャッジ日時 | 2024-09-30 06:35:35 |
| 合計ジャッジ時間 | 2,152 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 34 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 2601.cc: No.2601 Very Poor - yukicoder
*/
#include<cstdio>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_N = 200000;
const int MAX_N2 = MAX_N * 2;
/* typedef */
typedef long long ll;
/* global variables */
int as[MAX_N];
ll ass[MAX_N2 + 1];
/* subroutines */
/* main */
int main() {
int n, x;
scanf("%d%d", &n, &x);
for (int i = 0; i < n; i++) scanf("%d", as + i);
int n2 = n * 2;
for (int i = 0; i < n2; i++) ass[i + 1] = ass[i] + as[i % n];
if (ass[n] <= x) { printf("%lld\n", ass[n]); return 0; }
ll maxs = 0;
for (int i = 0, j = 0; i < n; i++) {
while (j < n2 && ass[j + 1] - ass[i] <= x) j++;
maxs = max(maxs, ass[j] - ass[i]);
}
printf("%lld\n", maxs);
return 0;
}
tnakao0123