結果
| 問題 |
No.2694 The Early Bird Catches The Worm
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-03-22 21:50:28 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 55 ms / 2,000 ms |
| コード長 | 852 bytes |
| コンパイル時間 | 2,124 ms |
| コンパイル使用メモリ | 195,560 KB |
| 最終ジャッジ日時 | 2025-02-20 11:33:10 |
|
ジャッジサーバーID (参考情報) |
judge5 / 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";
}