結果
| 問題 |
No.2694 The Early Bird Catches The Worm
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-03-22 21:31:26 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 52 ms / 2,000 ms |
| コード長 | 494 bytes |
| コンパイル時間 | 614 ms |
| コンパイル使用メモリ | 64,924 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-09-30 10:54:14 |
| 合計ジャッジ時間 | 5,487 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 72 |
ソースコード
#include<iostream>
#include<cassert>
using namespace std;
int N,H;
int A[2<<17],B[2<<17];
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin>>N>>H;
for(int i=0;i<N;i++)cin>>A[i];
for(int i=0;i<N;i++)cin>>B[i];
long ans=0;
long sumB=0,sum=0,sumA=0;
int l=0;
for(int r=0;r<N;r++)
{
sumB+=B[r];
sumA+=A[r];
sum+=(long)(r-l+1)*B[r];
while(sum>H)
{
assert(l<=r);
sum-=sumB;
sumA-=A[l];
sumB-=B[l];
l++;
}
ans=max(ans,sumA);
}
cout<<ans<<endl;
}