結果

問題 No.2694 The Early Bird Catches The Worm
ユーザー askr58
提出日時 2024-03-22 21:50:26
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 667 bytes
コンパイル時間 4,511 ms
コンパイル使用メモリ 308,500 KB
実行使用メモリ 8,064 KB
最終ジャッジ日時 2024-09-30 11:19:16
合計ジャッジ時間 11,920 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19 WA * 53
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;

int main()
{
    int n;ll h;
    cin>>n>>h;
    vector<ll> a(n),b(n);
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)cin>>b[i];
    ll l=0,r=0;
    vector<ll> sumb(n+1);
    for(int i=0;i<n;i++)sumb[i+1]=sumb[i]+b[i];
    ll ans=0,suma=0,tsumb=0;
    while(l<n){
        while(r<n&&tsumb+(r-l+1)*b[r]<=h){
            tsumb+=(r-l+1)*b[r];
            suma+=a[r];
            r++;
        }
        ans=max(ans,suma);
        suma-=a[l];
        tsumb-=(sumb[r]-sumb[l]);
        if(r==l)r++;
        l++;


    }
    cout<<ans<<endl;
    
}
0