結果
| 問題 |
No.2694 The Early Bird Catches The Worm
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-03-22 21:41:55 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 51 ms / 2,000 ms |
| コード長 | 759 bytes |
| コンパイル時間 | 2,234 ms |
| コンパイル使用メモリ | 195,392 KB |
| 最終ジャッジ日時 | 2025-02-20 11:26:01 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 72 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
long long N,H; cin >> N >> H;
vector<long long> A(N),B(N);
for(auto &a : A) cin >> a;
for(auto &b : B) cin >> b;
long long answer = 0,nowa = 0,nowb = 0,pos = 0,sumb = 0;
for(int i=0; i<N; i++){
while(pos != N){
long long a = A.at(pos),b = B.at(pos);
long long nb = nowb+(pos-i+1)*b;
if(nb > H) break;
pos++; nowb = nb;
nowa += a; sumb += b;
}
answer = max(answer,nowa);
if(pos == i) pos++;
else{
nowa -= A.at(i); nowb -= sumb;
sumb -= B.at(i);
}
}
cout << answer << endl;
}