結果

問題 No.2694 The Early Bird Catches The Worm
ユーザー eve__fuyukieve__fuyuki
提出日時 2024-03-23 04:44:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 1,045 bytes
コンパイル時間 2,423 ms
コンパイル使用メモリ 204,332 KB
実行使用メモリ 12,672 KB
最終ジャッジ日時 2024-03-23 04:44:51
合計ジャッジ時間 7,549 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 3 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 2 ms
6,676 KB
testcase_19 AC 2 ms
6,676 KB
testcase_20 AC 2 ms
6,676 KB
testcase_21 AC 4 ms
6,676 KB
testcase_22 AC 2 ms
6,676 KB
testcase_23 AC 2 ms
6,676 KB
testcase_24 AC 16 ms
6,676 KB
testcase_25 AC 14 ms
6,676 KB
testcase_26 AC 18 ms
6,676 KB
testcase_27 AC 24 ms
7,296 KB
testcase_28 AC 27 ms
7,808 KB
testcase_29 AC 10 ms
6,676 KB
testcase_30 AC 42 ms
10,496 KB
testcase_31 AC 25 ms
7,296 KB
testcase_32 AC 44 ms
10,880 KB
testcase_33 AC 43 ms
10,624 KB
testcase_34 AC 4 ms
6,676 KB
testcase_35 AC 23 ms
6,912 KB
testcase_36 AC 29 ms
8,064 KB
testcase_37 AC 49 ms
11,648 KB
testcase_38 AC 33 ms
8,704 KB
testcase_39 AC 9 ms
6,676 KB
testcase_40 AC 25 ms
7,296 KB
testcase_41 AC 12 ms
6,676 KB
testcase_42 AC 3 ms
6,676 KB
testcase_43 AC 5 ms
6,676 KB
testcase_44 AC 49 ms
11,648 KB
testcase_45 AC 48 ms
11,648 KB
testcase_46 AC 16 ms
6,676 KB
testcase_47 AC 16 ms
6,676 KB
testcase_48 AC 27 ms
7,808 KB
testcase_49 AC 37 ms
12,672 KB
testcase_50 AC 36 ms
12,672 KB
testcase_51 AC 36 ms
12,672 KB
testcase_52 AC 36 ms
12,672 KB
testcase_53 AC 36 ms
12,672 KB
testcase_54 AC 54 ms
12,672 KB
testcase_55 AC 54 ms
12,672 KB
testcase_56 AC 54 ms
12,672 KB
testcase_57 AC 53 ms
12,672 KB
testcase_58 AC 54 ms
12,672 KB
testcase_59 AC 54 ms
12,672 KB
testcase_60 AC 54 ms
12,672 KB
testcase_61 AC 54 ms
12,672 KB
testcase_62 AC 53 ms
12,672 KB
testcase_63 AC 54 ms
12,672 KB
testcase_64 AC 54 ms
12,672 KB
testcase_65 AC 54 ms
12,672 KB
testcase_66 AC 54 ms
12,672 KB
testcase_67 AC 53 ms
12,672 KB
testcase_68 AC 53 ms
12,672 KB
testcase_69 AC 43 ms
12,672 KB
testcase_70 AC 42 ms
12,672 KB
testcase_71 AC 42 ms
12,672 KB
testcase_72 AC 42 ms
12,672 KB
testcase_73 AC 42 ms
12,672 KB
testcase_74 AC 23 ms
7,936 KB
testcase_75 AC 42 ms
12,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
void fast_io() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
}

int main() {
    fast_io();
    int n;
    long long h;
    cin >> n >> h;
    vector<long long> a(n), b(n), bj(n), acum(n + 1), bcum(n + 1), bjcum(n + 1);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    for (int i = 0; i < n; i++) {
        bj[i] = (i + 1) * b[i];
        acum[i + 1] = acum[i] + a[i];
        bcum[i + 1] = bcum[i] + b[i];
        bjcum[i + 1] = bjcum[i] + bj[i];
    }
    long long ans = 0, score = 0;
    for (int l = 0, r = 0; l < n; l++) {
        while (r < n &&
               bjcum[r + 1] - bjcum[l] - l * (bcum[r + 1] - bcum[l]) <= h) {
            score += a[r];
            r++;
        }
        // cout << l << " " << r << " " << score << endl;
        ans = max(ans, score);
        score -= a[l];
        if (l == r) {
            r++;
            score += a[l];
        }
    }
    cout << ans << endl;
}
0