結果

問題 No.2694 The Early Bird Catches The Worm
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2024-03-22 21:53:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 66 ms / 2,000 ms
コード長 975 bytes
コンパイル時間 2,146 ms
コンパイル使用メモリ 204,212 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-03-22 21:53:28
合計ジャッジ時間 7,277 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 2 ms
6,548 KB
testcase_03 AC 2 ms
6,548 KB
testcase_04 AC 2 ms
6,548 KB
testcase_05 AC 2 ms
6,548 KB
testcase_06 AC 2 ms
6,548 KB
testcase_07 AC 2 ms
6,548 KB
testcase_08 AC 2 ms
6,548 KB
testcase_09 AC 2 ms
6,548 KB
testcase_10 AC 2 ms
6,548 KB
testcase_11 AC 2 ms
6,548 KB
testcase_12 AC 1 ms
6,548 KB
testcase_13 AC 2 ms
6,548 KB
testcase_14 AC 2 ms
6,548 KB
testcase_15 AC 2 ms
6,548 KB
testcase_16 AC 2 ms
6,548 KB
testcase_17 AC 2 ms
6,548 KB
testcase_18 AC 2 ms
6,548 KB
testcase_19 AC 2 ms
6,548 KB
testcase_20 AC 2 ms
6,548 KB
testcase_21 AC 2 ms
6,548 KB
testcase_22 AC 2 ms
6,548 KB
testcase_23 AC 2 ms
6,548 KB
testcase_24 AC 19 ms
6,548 KB
testcase_25 AC 15 ms
6,548 KB
testcase_26 AC 21 ms
6,548 KB
testcase_27 AC 28 ms
6,656 KB
testcase_28 AC 28 ms
7,168 KB
testcase_29 AC 10 ms
6,548 KB
testcase_30 AC 45 ms
9,472 KB
testcase_31 AC 26 ms
6,784 KB
testcase_32 AC 53 ms
9,728 KB
testcase_33 AC 50 ms
9,600 KB
testcase_34 AC 4 ms
6,548 KB
testcase_35 AC 24 ms
6,548 KB
testcase_36 AC 33 ms
7,424 KB
testcase_37 AC 55 ms
10,368 KB
testcase_38 AC 34 ms
7,936 KB
testcase_39 AC 9 ms
6,548 KB
testcase_40 AC 26 ms
6,784 KB
testcase_41 AC 12 ms
6,548 KB
testcase_42 AC 2 ms
6,548 KB
testcase_43 AC 6 ms
6,548 KB
testcase_44 AC 50 ms
10,368 KB
testcase_45 AC 47 ms
10,368 KB
testcase_46 AC 17 ms
6,548 KB
testcase_47 AC 16 ms
6,548 KB
testcase_48 AC 31 ms
7,168 KB
testcase_49 AC 49 ms
11,136 KB
testcase_50 AC 48 ms
11,136 KB
testcase_51 AC 49 ms
11,136 KB
testcase_52 AC 48 ms
11,136 KB
testcase_53 AC 49 ms
11,136 KB
testcase_54 AC 61 ms
11,136 KB
testcase_55 AC 61 ms
11,136 KB
testcase_56 AC 59 ms
11,136 KB
testcase_57 AC 65 ms
11,136 KB
testcase_58 AC 55 ms
11,136 KB
testcase_59 AC 63 ms
11,136 KB
testcase_60 AC 63 ms
11,136 KB
testcase_61 AC 63 ms
11,136 KB
testcase_62 AC 66 ms
11,136 KB
testcase_63 AC 61 ms
11,136 KB
testcase_64 AC 53 ms
11,136 KB
testcase_65 AC 62 ms
11,136 KB
testcase_66 AC 60 ms
11,136 KB
testcase_67 AC 54 ms
11,136 KB
testcase_68 AC 52 ms
11,136 KB
testcase_69 AC 55 ms
11,136 KB
testcase_70 AC 55 ms
11,136 KB
testcase_71 AC 56 ms
11,136 KB
testcase_72 AC 55 ms
11,136 KB
testcase_73 AC 57 ms
11,136 KB
testcase_74 AC 28 ms
7,296 KB
testcase_75 AC 55 ms
11,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    ll N, H, ans=0;
    cin >> N >> H;
    vector<ll> A(N+1), B(N+1), SA(N+1), SB(N+1), SC(N+1);
    for (int i=1; i<=N; i++){
        cin >> A[i];
        SA[i] = SA[i-1] + A[i];
    }
    for (int i=1; i<=N; i++){
        cin >> B[i];
        SB[i] = SB[i-1] + B[i];
        SC[i] = SC[i-1] + B[i]*i;
    }

    for (int i=1; i<=N; i++){
        if (B[i] > H) continue;
        ll ok=i, ng=N+1;
        while (ng-ok > 1){
            ll mid = (ok+ng)/2;
            if (SC[mid] - SC[i-1] - (SB[mid]-SB[i-1]) * (i-1) <= H){
                ok = mid;
            } else {
                ng = mid;
            }
        }
        //cout << i << " " << ok << " " << SC[ok] - SC[i-1] - (SB[ok]-SB[i-1]) *(i-1) << " " <<  SA[ok]-SA[i-1] << endl;
        ans = max(ans, SA[ok]-SA[i-1]);
    }

    cout << ans << endl;

    return 0;
}
0