結果
問題 | No.2694 The Early Bird Catches The Worm |
ユーザー |
|
提出日時 | 2024-03-22 21:50:28 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 51 ms / 2,000 ms |
コード長 | 852 bytes |
コンパイル時間 | 2,252 ms |
コンパイル使用メモリ | 202,604 KB |
実行使用メモリ | 9,472 KB |
最終ジャッジ日時 | 2024-09-30 11:19:02 |
合計ジャッジ時間 | 6,815 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 72 |
ソースコード
#include<bits/stdc++.h>using namespace std;using ll=long long;#define all(v) v.begin(),v.end()#define rall(v) v.rbegin(),v.rend()template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;}template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;}int main(){ios::sync_with_stdio(false);cin.tie(nullptr);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];vector<ll>S(N+1),T(N+1);for(int i=0;i<N;i++)S[i+1]=S[i]+A[i];for(int i=0;i<N;i++)T[i+1]=T[i]+B[i];ll ans=0,r=0,b=0;for(int l=0;l<N;l++){while(r<N&&b+(r-l+1)*B[r]<=H){b+=(r-l+1)*B[r];r++;}chmax(ans,S[r]-S[l]);b-=T[r]-T[l];}cout<<ans<<"\n";}