結果

問題 No.2601 Very Poor
ユーザー nononnonon
提出日時 2024-01-12 21:39:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 542 bytes
コンパイル時間 2,115 ms
コンパイル使用メモリ 201,388 KB
実行使用メモリ 10,516 KB
最終ジャッジ日時 2024-01-12 21:39:53
合計ジャッジ時間 7,604 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 2 ms
6,548 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2 ms
6,548 KB
testcase_06 AC 3 ms
6,548 KB
testcase_07 AC 3 ms
6,548 KB
testcase_08 AC 2 ms
6,548 KB
testcase_09 AC 2 ms
6,548 KB
testcase_10 AC 3 ms
6,548 KB
testcase_11 AC 2 ms
6,548 KB
testcase_12 AC 2 ms
6,548 KB
testcase_13 AC 2 ms
6,548 KB
testcase_14 AC 2 ms
6,548 KB
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
int N,X;
long A[4<<17],S[4<<17];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>N>>X;
    for(int i=0;i<N;i++)
    {
        cin>>A[i];
        A[i+N]=A[i];
    }
    for(int i=1;i<=4*N;i++)S[i]=S[i-1]+A[i-1];
    long ans=0;
    for(int i=0;i<N;i++)
    {
        int l=i,r=i+N;
        while(r-l>1)
        {
            int m=(r+l)/2;
            if(S[m]-S[i]<=X)l=m;
            else r=m;
        }
        ans=max(ans,S[l]-S[i]);
    }
    cout << ans << endl;
}
0