結果
問題 | No.2694 The Early Bird Catches The Worm |
ユーザー |
![]() |
提出日時 | 2024-03-22 22:16:46 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 157 ms / 2,000 ms |
コード長 | 735 bytes |
コンパイル時間 | 2,278 ms |
コンパイル使用メモリ | 202,892 KB |
実行使用メモリ | 9,600 KB |
最終ジャッジ日時 | 2024-09-30 11:44:33 |
合計ジャッジ時間 | 9,417 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 72 |
ソースコード
#include <bits/stdc++.h>using namespace std;template<class T> bool chmax(T &a, const T &x) { return x > a ? a = x, true : false; }int main() {int N, H;cin >> N >> H;vector<long long> A(N), B(N);for (int i=0; i < N; ++i)cin >> A[i];for (int i=0; i < N; ++i)cin >> B[i];long long answer=0, SH=0;vector<long long> SA(N+1), SB(N+1);inclusive_scan(A.begin(), A.end(), ++SA.begin());inclusive_scan(B.begin(), B.end(), ++SB.begin());for (int L=0, R=0; L < N; NULL) {while (R < N && SH + (R - L + 1) * B[R] <= H) {SH += (R - L + 1) * B[R];++R;}chmax(answer, SA[R] - SA[L]);SH -= SB[R] - SB[L];++L;if (R < L)R = L;}cout << answer << endl;}