結果
問題 | No.2694 The Early Bird Catches The Worm |
ユーザー |
![]() |
提出日時 | 2024-03-22 22:21:02 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 166 ms / 2,000 ms |
コード長 | 918 bytes |
コンパイル時間 | 2,380 ms |
コンパイル使用メモリ | 204,308 KB |
実行使用メモリ | 8,064 KB |
最終ジャッジ日時 | 2024-09-30 11:52:24 |
合計ジャッジ時間 | 10,363 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 72 |
ソースコード
#include <bits/stdc++.h>using namespace std;int main() {int n, h;cin >> n >> h;vector<long long> a(n + 1), b(n + 1);for (int i = 1; i <= n; i++) {cin >> a[i];}for (int i = 1; i <= n; i++) {cin >> b[i];}vector<long long> s(n + 1);for (int i = 1; i <= n; i++) {s[i] = s[i - 1] + b[i];}int r = 0;long long ans = 0LL, sat = 0LL, fat = 0LL;for (int l = 1; l <= n; l++) {//cout << "l = " << l << endl;if (l >= 2) {sat -= a[l - 1];fat -= s[r] - s[l - 2];}//cout << r << " " << sat << " " << fat << endl;while (r <= n && fat <= h) {r++;sat += a[r];fat += (long long)(r - l + 1) * b[r];}//cout << r << " " << sat << " " << fat << endl;ans = max(ans, sat - a[r]);}cout << ans << endl;}