結果

問題 No.2601 Very Poor
ユーザー lumidlumid
提出日時 2024-01-12 22:13:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,554 bytes
コンパイル時間 1,977 ms
コンパイル使用メモリ 204,092 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-02-27 19:07:10
合計ジャッジ時間 3,870 ms
ジャッジサーバーID
(参考情報)
judge12 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
#include <climits>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long double ld;
typedef pair<ll, ll> pll;
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define ROF(i, a, b) for(int i = a; i >= b; i--)
#define ms memset
#define pb push_back
#define fi first
#define se second
#define inp(n, a) vector<ll> a;for(int i=0;i<n;i++){ll now;cin>>now;a.pb(now);}
#define all(a) a.begin(),a.end()
#define show(a) for(long long loppls=0;loppls<(long long)(a.size()-1);loppls++)cout<<a[loppls]<<' ';cout<<a[a.size()-1];

long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

ll sum2(ll a, ll l, ll n){return (n*(a+l))/2;}
ll ceil2(ll a, ll b){return (a+b-1)/b;}

const long long INF=1e16,MAX=200020,MOD=998244353;

void solve() {
    ll n,x;cin>>n>>x;
    inp(n,a);
    ll dp[n];
    ll sum=0,tail=0,oops=1;
    for(int i=0;i<n;i++){
        if(i!=0)sum-=a[i-1];
        oops=tail==i;
        while(sum+a[tail]<=x&&(tail!=i||oops)){
            sum+=a[tail];
            tail=(tail+1)%n;
            oops=0;
        }
        dp[i]=sum;
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        ans=max(ans,dp[i]);
    }
    cout<<ans;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	solve();
}
0