結果

問題 No.2694 The Early Bird Catches The Worm
ユーザー hirakuuuuhirakuuuu
提出日時 2024-03-22 21:57:27
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 737 ms / 2,000 ms
コード長 1,271 bytes
コンパイル時間 3,122 ms
コンパイル使用メモリ 248,520 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-03-22 21:58:00
合計ジャッジ時間 31,347 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 5 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 3 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 3 ms
6,676 KB
testcase_15 AC 3 ms
6,676 KB
testcase_16 AC 3 ms
6,676 KB
testcase_17 AC 3 ms
6,676 KB
testcase_18 AC 3 ms
6,676 KB
testcase_19 AC 2 ms
6,676 KB
testcase_20 AC 3 ms
6,676 KB
testcase_21 AC 2 ms
6,676 KB
testcase_22 AC 2 ms
6,676 KB
testcase_23 AC 2 ms
6,676 KB
testcase_24 AC 180 ms
6,676 KB
testcase_25 AC 158 ms
6,676 KB
testcase_26 AC 209 ms
6,676 KB
testcase_27 AC 291 ms
6,676 KB
testcase_28 AC 328 ms
7,168 KB
testcase_29 AC 111 ms
6,676 KB
testcase_30 AC 548 ms
9,344 KB
testcase_31 AC 299 ms
6,784 KB
testcase_32 AC 598 ms
9,728 KB
testcase_33 AC 556 ms
9,472 KB
testcase_34 AC 26 ms
6,676 KB
testcase_35 AC 275 ms
6,676 KB
testcase_36 AC 355 ms
7,424 KB
testcase_37 AC 639 ms
10,368 KB
testcase_38 AC 429 ms
7,936 KB
testcase_39 AC 89 ms
6,676 KB
testcase_40 AC 293 ms
6,784 KB
testcase_41 AC 131 ms
6,676 KB
testcase_42 AC 12 ms
6,676 KB
testcase_43 AC 45 ms
6,676 KB
testcase_44 AC 662 ms
10,368 KB
testcase_45 AC 639 ms
10,368 KB
testcase_46 AC 192 ms
6,676 KB
testcase_47 AC 188 ms
6,676 KB
testcase_48 AC 332 ms
7,168 KB
testcase_49 AC 469 ms
11,136 KB
testcase_50 AC 486 ms
11,136 KB
testcase_51 AC 461 ms
11,136 KB
testcase_52 AC 489 ms
11,136 KB
testcase_53 AC 458 ms
11,136 KB
testcase_54 AC 736 ms
11,136 KB
testcase_55 AC 709 ms
11,136 KB
testcase_56 AC 733 ms
11,136 KB
testcase_57 AC 707 ms
11,136 KB
testcase_58 AC 716 ms
11,136 KB
testcase_59 AC 737 ms
11,136 KB
testcase_60 AC 709 ms
11,136 KB
testcase_61 AC 728 ms
11,136 KB
testcase_62 AC 728 ms
11,136 KB
testcase_63 AC 699 ms
11,136 KB
testcase_64 AC 737 ms
11,136 KB
testcase_65 AC 710 ms
11,136 KB
testcase_66 AC 734 ms
11,136 KB
testcase_67 AC 733 ms
11,136 KB
testcase_68 AC 712 ms
11,136 KB
testcase_69 AC 636 ms
11,136 KB
testcase_70 AC 611 ms
11,136 KB
testcase_71 AC 641 ms
11,136 KB
testcase_72 AC 648 ms
11,136 KB
testcase_73 AC 663 ms
11,136 KB
testcase_74 AC 261 ms
7,296 KB
testcase_75 AC 649 ms
11,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, n) for(int i = a; i < n; i++)
#define rrep(i, a, n) for(int i = a; i >= n; i--)
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
// constexpr ll MOD = 1000000007;
constexpr ll MOD = 998244353;
constexpr int IINF = 1001001001;
constexpr ll INF = 1LL<<60;

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    ll n, h; cin >> n >> h;
    vector<ll> a(n), b(n);
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, n) cin >> b[i];
    vector<ll> acc(n+1);
    rep(i, 0, n) acc[i+1] = acc[i]+a[i];
    vector<ll> acc_b(n+1);
    rep(i, 0, n) acc_b[i+1] = acc_b[i]+b[i];
    vector<ll> fatigue(n+1);
    rep(i, 0, n) fatigue[i+1] = fatigue[i]+b[i]*(i+1);

    ll ok = 0, ng = 1e18;
    while(ng-ok > 1){
        ll mid = (ok+ng)/2;
        bool f = false;
        rep(i, 0, n){
            auto itr = lower_bound(acc.begin(), acc.end(), mid+acc[i]);
            if(itr == acc.end()) continue;
            ll l = i, r = itr-acc.begin();
            if(h >= (fatigue[r]-fatigue[l])-(acc_b[r]-acc_b[l])*l) f = true;
        }
        if(f) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
    return 0;
}
0