結果
| 問題 |
No.2601 Very Poor
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-01-12 21:25:15 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 22 ms / 2,000 ms |
| コード長 | 434 bytes |
| コンパイル時間 | 424 ms |
| コンパイル使用メモリ | 65,224 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-09-30 06:11:44 |
| 合計ジャッジ時間 | 2,018 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 34 |
ソースコード
#include<iostream>
#include<cassert>
using namespace std;
int N,A[4<<17],X;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin>>N>>X;
long long S=0;
for(int i=0;i<N;i++)
{
cin>>A[i];
A[N+i]=A[i];
S+=A[i];
}
if(S<=X)
{
cout<<S<<endl;
return 0;
}
int ans=0;
int sum=0;
int r=0;
for(int l=0;l<N;l++)
{
while(sum<=X)
{
ans=max(ans,sum);
sum+=A[r++];
}
sum-=A[l];
}
cout<<ans<<endl;
}