結果

問題 No.2694 The Early Bird Catches The Worm
ユーザー MMMM
提出日時 2024-02-16 23:22:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 3,051 bytes
コンパイル時間 4,041 ms
コンパイル使用メモリ 231,788 KB
実行使用メモリ 14,740 KB
最終ジャッジ日時 2024-02-16 23:36:47
合計ジャッジ時間 18,848 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 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 2 ms
6,676 KB
testcase_22 AC 2 ms
6,676 KB
testcase_23 AC 2 ms
6,676 KB
testcase_24 AC 15 ms
6,676 KB
testcase_25 AC 14 ms
6,676 KB
testcase_26 AC 17 ms
6,676 KB
testcase_27 AC 23 ms
6,676 KB
testcase_28 AC 25 ms
6,676 KB
testcase_29 AC 9 ms
6,676 KB
testcase_30 AC 40 ms
7,040 KB
testcase_31 AC 23 ms
6,676 KB
testcase_32 AC 41 ms
7,168 KB
testcase_33 AC 41 ms
7,040 KB
testcase_34 AC 4 ms
6,676 KB
testcase_35 AC 21 ms
6,676 KB
testcase_36 AC 27 ms
6,676 KB
testcase_37 AC 45 ms
7,552 KB
testcase_38 AC 30 ms
6,676 KB
testcase_39 AC 8 ms
6,676 KB
testcase_40 AC 23 ms
6,676 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 45 ms
7,552 KB
testcase_45 AC 45 ms
7,552 KB
testcase_46 AC 14 ms
6,676 KB
testcase_47 AC 16 ms
6,676 KB
testcase_48 AC 25 ms
6,676 KB
testcase_49 AC 1,186 ms
8,064 KB
testcase_50 AC 1,433 ms
8,064 KB
testcase_51 AC 1,812 ms
8,064 KB
testcase_52 AC 1,563 ms
8,064 KB
testcase_53 AC 1,883 ms
8,064 KB
testcase_54 AC 51 ms
8,064 KB
testcase_55 AC 51 ms
8,064 KB
testcase_56 AC 50 ms
8,064 KB
testcase_57 AC 50 ms
8,064 KB
testcase_58 AC 50 ms
8,064 KB
testcase_59 AC 50 ms
8,064 KB
testcase_60 AC 50 ms
8,064 KB
testcase_61 AC 49 ms
8,064 KB
testcase_62 AC 50 ms
8,064 KB
testcase_63 AC 50 ms
8,064 KB
testcase_64 AC 50 ms
8,064 KB
testcase_65 AC 50 ms
8,064 KB
testcase_66 AC 51 ms
8,064 KB
testcase_67 AC 50 ms
8,064 KB
testcase_68 AC 50 ms
8,064 KB
testcase_69 TLE -
testcase_70 -- -
testcase_71 -- -
testcase_72 -- -
testcase_73 -- -
testcase_74 -- -
testcase_75 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

// yspwさんのコードでassertを修正
#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
template <class T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, a, b) for(ll i=a; i<b; i++)
#define rrep(i, a, b) for(ll i=a; i>=b; i--)
#define all(a) (a).begin(), (a).end()
#define smod(n, m) ((((n) % (m)) + (m)) % (m)) // 非負mod
#define YesNo(bool) if(bool){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }

inline int popcount(int n) { return __builtin_popcount(n); } // 2進数で表した場合に立ってるビット数がいくつか
inline int popcount(ll n) { return __builtin_popcountll(n); }
inline int ctz(int n) { return n != 0 ? __builtin_ctz(n) : -1; } // 2進数で表した場合に 1 の位からいくつ 0 が連なっているか
inline int ctz(ll n) { return n != 0 ? __builtin_ctzll(n) : -1; }
inline int clz(int n) { return n != 0 ? (31 - __builtin_clz(n)) : -1; } // 2進数で表した場合に左側にいくつ 0 を埋める必要があるか
inline int clz(ll n) { return n != 0 ? (63 - __builtin_clzll(n)) : -1; }

const double PI = 3.141592653589793;
const vector<int> DX = { 1, 0, -1, 0 };
const vector<int> DY = { 0, 1, 0, -1 };
const long long INF = (ll)1e18+10;
ll coordinate(ll h, ll w, ll W){ return h*W + w; } // 二次元座標を一次元座標に変換

#define endl "\n" // インタラクティブの時はコメントアウトする

template<typename T>
struct Cum{
    vector<T> cum;
    // コンストラクタ
    Cum() {}
    Cum(vector<T>& arr){
        int n = arr.size();
        cum.resize(n+1,0);
        // 累積和を計算
        for (int i=0; i<n; i++){
            cum[i+1] = cum[i] + arr[i];
        }
    }
    // 0-indexed, 区間 [l,r) の和を取得
    T get(int l, int r){
        assert(l<=r);
        return cum[r] - cum[l];
    }
};

int main()
{
    // TLE 解法、疲労度を愚直に計算
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    // cout << fixed << setprecision(18);

    ll n,h;
    cin>>n>>h;
    // assert(1<=n && n<=(ll)1e5);
    assert(1<=n && n<=(ll)2e5);
    assert(1<=h && h<=(ll)1e9);
    vector<ll>a(n),b(n);
    rep(i,0,n){
        cin>>a[i];
        if(a[i] < 1 || a[i] > 1e9) cout << i << " " << a[i] << endl;
        assert(1<=a[i] && a[i]<=(ll)1e9); 
    }
    rep(i,0,n){
        cin>>b[i];
        if(b[i] < 1 || b[i] > 1e9) cout << i << " " << b[i] << endl;
        assert(1<=b[i] && b[i]<=(ll)1e9);
    }

    Cum<ll> cuma(a);

    
    ll ans = 0;
    rep(l,0,n){
        ll r = l;
        ll now = 0;
        while(r<n && now+(r-l+1)*b[r]<=h){
            now += (r-l+1)*b[r];
            r++;
        }
        chmax(ans, cuma.get(l,r));
    }
    cout << ans << endl;       
    
    return 0;
}
0