結果
| 問題 | No.2694 The Early Bird Catches The Worm |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-04-03 09:36:22 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 803 bytes |
| コンパイル時間 | 3,936 ms |
| コンパイル使用メモリ | 251,660 KB |
| 最終ジャッジ日時 | 2025-02-20 19:48:50 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 45 TLE * 1 -- * 26 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using mint = modint998244353;
int main() {
ll N, 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> sumA(N + 1), sumB(N + 1);
for (int i = 0; i < N; i++) {
sumA[i + 1] = sumA[i] + A[i];
sumB[i + 1] = sumB[i] + B[i];
}
int L = 0, R = 0;
ll ans = 0;
while (true) {
if (R >= N) break;
ll BB = 0;
for (int i = 1; i <= R - L + 1; i++) {
BB += sumB[R + 1] - sumB[L + i - 1];
}
if (BB <= H) {
ans = max(ans, sumA[R + 1] - sumA[L]);
R++;
} else {
L++;
R = L;
}
}
cout << ans << endl;
return 0;
}