結果
| 問題 |
No.2694 The Early Bird Catches The Worm
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2024-03-22 21:31:12 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 50 ms / 2,000 ms |
| コード長 | 700 bytes |
| コンパイル時間 | 4,170 ms |
| コンパイル使用メモリ | 250,204 KB |
| 最終ジャッジ日時 | 2025-02-20 11:14:38 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 72 |
ソースコード
#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 1000000000000000001
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
long long N,H;
cin>>N>>H;
vector<long long> a(N),b(N);
rep(i,N)cin>>a[i];
rep(i,N)cin>>b[i];
long long ans = 0;
long long as = 0;
long long bs = 0;
long long cs = 0;
int l = -1;
rep(i,N){
bs += b[i];
cs += b[i] * (i-l);
as += a[i];
while(cs > H){
cs -= bs;
bs -= b[l+1];
as -= a[l+1];
l++;
}
ans = max(ans,as);
}
cout<<ans<<endl;
return 0;
}
沙耶花