結果

問題 No.2694 The Early Bird Catches The Worm
ユーザー ypwwypww
提出日時 2024-02-15 22:41:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,967 bytes
コンパイル時間 4,275 ms
コンパイル使用メモリ 264,824 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2024-02-16 23:35:12
合計ジャッジ時間 10,134 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 1 ms
6,548 KB
testcase_03 AC 2 ms
6,548 KB
testcase_04 AC 2 ms
6,548 KB
testcase_05 AC 1 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 WA -
testcase_10 AC 2 ms
6,548 KB
testcase_11 AC 2 ms
6,548 KB
testcase_12 AC 2 ms
6,548 KB
testcase_13 AC 1 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 1 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 14 ms
6,548 KB
testcase_25 AC 12 ms
6,548 KB
testcase_26 AC 15 ms
6,548 KB
testcase_27 AC 22 ms
6,548 KB
testcase_28 AC 24 ms
6,548 KB
testcase_29 AC 9 ms
6,548 KB
testcase_30 RE -
testcase_31 AC 22 ms
6,548 KB
testcase_32 RE -
testcase_33 RE -
testcase_34 AC 3 ms
6,548 KB
testcase_35 AC 21 ms
6,548 KB
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 AC 8 ms
6,548 KB
testcase_40 AC 22 ms
6,548 KB
testcase_41 AC 11 ms
6,548 KB
testcase_42 AC 2 ms
6,548 KB
testcase_43 AC 5 ms
6,548 KB
testcase_44 RE -
testcase_45 RE -
testcase_46 AC 14 ms
6,548 KB
testcase_47 AC 13 ms
6,548 KB
testcase_48 AC 24 ms
6,548 KB
testcase_49 RE -
testcase_50 RE -
testcase_51 RE -
testcase_52 RE -
testcase_53 RE -
testcase_54 RE -
testcase_55 RE -
testcase_56 RE -
testcase_57 RE -
testcase_58 RE -
testcase_59 RE -
testcase_60 RE -
testcase_61 RE -
testcase_62 RE -
testcase_63 RE -
testcase_64 RE -
testcase_65 RE -
testcase_66 RE -
testcase_67 RE -
testcase_68 RE -
testcase_69 RE -
testcase_70 RE -
testcase_71 RE -
testcase_72 RE -
testcase_73 RE -
testcase_74 AC 19 ms
6,548 KB
testcase_75 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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()
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    // cout << fixed << setprecision(18);

    // WA 解法、不等号のミス
    ll n,h;
    cin>>n>>h;
    assert(1<=n && n<=(ll)1e5);
    assert(1<=h && h<=(ll)1e9);
    vector<ll>a(n),b(n);
    rep(i,0,n){
        ll aa;
        cin>>aa;
        assert(1<=aa && aa<=(ll)1e9);
        a[i] = aa; 
    }
    rep(i,0,n){
        ll bb;
        cin>>bb;
        assert(1<=bb && bb<=(ll)1e9);
        b[i] = bb;
    }

    Cum<ll> cuma(a), cumb(b);

    ll now = 0;
    ll r = 0;
    ll ans = 0;
    rep(l,0,n){
        if (l!=0) now -= cumb.get(l-1, r);
        // 本来は <= の部分を < にした
        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