結果

問題 No.2694 The Early Bird Catches The Worm
ユーザー aradarad
提出日時 2024-03-22 21:42:21
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 210 ms / 2,000 ms
コード長 1,790 bytes
コンパイル時間 5,349 ms
コンパイル使用メモリ 308,752 KB
実行使用メモリ 12,672 KB
最終ジャッジ日時 2024-03-22 21:42:38
合計ジャッジ時間 14,713 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 3 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 3 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 3 ms
6,676 KB
testcase_10 AC 3 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 3 ms
6,676 KB
testcase_15 AC 3 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 3 ms
6,676 KB
testcase_22 AC 2 ms
6,676 KB
testcase_23 AC 2 ms
6,676 KB
testcase_24 AC 50 ms
6,676 KB
testcase_25 AC 43 ms
6,676 KB
testcase_26 AC 57 ms
6,676 KB
testcase_27 AC 80 ms
7,296 KB
testcase_28 AC 87 ms
7,936 KB
testcase_29 AC 28 ms
6,676 KB
testcase_30 AC 136 ms
10,624 KB
testcase_31 AC 78 ms
7,424 KB
testcase_32 AC 152 ms
11,008 KB
testcase_33 AC 146 ms
10,752 KB
testcase_34 AC 8 ms
6,676 KB
testcase_35 AC 71 ms
7,040 KB
testcase_36 AC 96 ms
8,192 KB
testcase_37 AC 160 ms
11,776 KB
testcase_38 AC 102 ms
8,832 KB
testcase_39 AC 24 ms
6,676 KB
testcase_40 AC 76 ms
7,424 KB
testcase_41 AC 35 ms
6,676 KB
testcase_42 AC 5 ms
6,676 KB
testcase_43 AC 14 ms
6,676 KB
testcase_44 AC 155 ms
11,776 KB
testcase_45 AC 151 ms
11,776 KB
testcase_46 AC 48 ms
6,676 KB
testcase_47 AC 48 ms
6,676 KB
testcase_48 AC 88 ms
7,936 KB
testcase_49 AC 98 ms
12,672 KB
testcase_50 AC 98 ms
12,672 KB
testcase_51 AC 101 ms
12,672 KB
testcase_52 AC 99 ms
12,672 KB
testcase_53 AC 98 ms
12,672 KB
testcase_54 AC 178 ms
12,672 KB
testcase_55 AC 180 ms
12,672 KB
testcase_56 AC 176 ms
12,672 KB
testcase_57 AC 186 ms
12,672 KB
testcase_58 AC 171 ms
12,672 KB
testcase_59 AC 210 ms
12,672 KB
testcase_60 AC 184 ms
12,672 KB
testcase_61 AC 187 ms
12,672 KB
testcase_62 AC 185 ms
12,672 KB
testcase_63 AC 181 ms
12,672 KB
testcase_64 AC 169 ms
12,672 KB
testcase_65 AC 180 ms
12,672 KB
testcase_66 AC 180 ms
12,672 KB
testcase_67 AC 175 ms
12,672 KB
testcase_68 AC 169 ms
12,672 KB
testcase_69 AC 137 ms
12,672 KB
testcase_70 AC 138 ms
12,672 KB
testcase_71 AC 137 ms
12,672 KB
testcase_72 AC 138 ms
12,672 KB
testcase_73 AC 140 ms
12,672 KB
testcase_74 AC 70 ms
8,064 KB
testcase_75 AC 143 ms
12,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using P = pair<ll,ll>;
using VP = vector<P>;
#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define out(x) cout << x << endl
#define dout(x) cout << fixed << setprecision(10) << x << endl
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)(x.size())
#define re0 return 0
#define pcnt __builtin_popcountll
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
constexpr int inf = 1e9;
constexpr ll INF = 1e18;
//using mint = modint1000000007;
using mint = modint998244353;
int di[4] = {1,0,-1,0};
int dj[4] = {0,1,0,-1};

int main(){
    ll n,h;
    cin >> n >> h;
    VL a(n),b(n),c(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n) c[i] = (i+1)*b[i];
    VL cmla(n+1),cmlb(n+1),cmlc(n+1);
    rep(i,n) cmla[i+1] = cmla[i]+a[i];
    rep(i,n) cmlb[i+1] = cmlb[i]+b[i];
    rep(i,n) cmlc[i+1] = cmlc[i]+c[i];
    ll ans = 0;
    rep(i,n){
        if(h < b[i]) continue;
        auto get = [&](ll x){
            ll res = cmlc[x]-cmlc[i];
            res -= i*(cmlb[x]-cmlb[i]);
            return res;
        };
        ll ok = i+1,ng = n+1;
        while(abs(ok-ng)>1){
            ll mid = (ok+ng)/2;
            if(get(mid) <= h) ok = mid;
            else ng = mid;
            //cout << i << ' ' << mid << ' ' << get(mid) << endl;
        }
        chmax(ans,cmla[ok]-cmla[i]);
    }
    out(ans);
}
0