結果

問題 No.2694 The Early Bird Catches The Worm
ユーザー mayocornmayocorn
提出日時 2024-03-22 21:43:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 72 ms / 2,000 ms
コード長 3,026 bytes
コンパイル時間 4,611 ms
コンパイル使用メモリ 269,384 KB
実行使用メモリ 16,296 KB
最終ジャッジ日時 2024-03-22 21:43:46
合計ジャッジ時間 10,479 ms
ジャッジサーバーID
(参考情報)
judge12 / 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 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 3 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 20 ms
6,688 KB
testcase_25 AC 18 ms
6,676 KB
testcase_26 AC 23 ms
6,816 KB
testcase_27 AC 32 ms
9,416 KB
testcase_28 AC 36 ms
9,680 KB
testcase_29 AC 12 ms
6,676 KB
testcase_30 AC 56 ms
15,208 KB
testcase_31 AC 32 ms
9,544 KB
testcase_32 AC 58 ms
15,312 KB
testcase_33 AC 58 ms
15,224 KB
testcase_34 AC 4 ms
6,676 KB
testcase_35 AC 30 ms
9,272 KB
testcase_36 AC 38 ms
9,904 KB
testcase_37 AC 63 ms
15,800 KB
testcase_38 AC 42 ms
10,248 KB
testcase_39 AC 11 ms
6,676 KB
testcase_40 AC 32 ms
9,544 KB
testcase_41 AC 16 ms
6,676 KB
testcase_42 AC 3 ms
6,676 KB
testcase_43 AC 6 ms
6,676 KB
testcase_44 AC 63 ms
15,720 KB
testcase_45 AC 63 ms
15,720 KB
testcase_46 AC 21 ms
6,676 KB
testcase_47 AC 21 ms
6,728 KB
testcase_48 AC 37 ms
9,680 KB
testcase_49 AC 65 ms
16,296 KB
testcase_50 AC 66 ms
16,296 KB
testcase_51 AC 65 ms
16,296 KB
testcase_52 AC 65 ms
16,296 KB
testcase_53 AC 69 ms
16,296 KB
testcase_54 AC 70 ms
16,296 KB
testcase_55 AC 70 ms
16,296 KB
testcase_56 AC 70 ms
16,296 KB
testcase_57 AC 70 ms
16,296 KB
testcase_58 AC 70 ms
16,296 KB
testcase_59 AC 70 ms
16,296 KB
testcase_60 AC 70 ms
16,296 KB
testcase_61 AC 70 ms
16,296 KB
testcase_62 AC 69 ms
16,296 KB
testcase_63 AC 70 ms
16,296 KB
testcase_64 AC 69 ms
16,296 KB
testcase_65 AC 70 ms
16,296 KB
testcase_66 AC 70 ms
16,296 KB
testcase_67 AC 69 ms
16,296 KB
testcase_68 AC 72 ms
16,296 KB
testcase_69 AC 68 ms
16,296 KB
testcase_70 AC 71 ms
16,296 KB
testcase_71 AC 70 ms
16,296 KB
testcase_72 AC 69 ms
16,296 KB
testcase_73 AC 68 ms
16,296 KB
testcase_74 AC 34 ms
9,856 KB
testcase_75 AC 68 ms
16,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

// type
typedef long long ll;
typedef long double ld;
using i128 = __int128_t;
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;
template<class T> using v = vector<T>;
#define V vector
#define pl pair<ll, ll>
#define vl v<ll>
#define vp v<pl>
#define vm v<mint>
 
// IN-OUT
#define NYAN ios::sync_with_stdio(false);cin.tie(nullptr);cout<<fixed<<setprecision(15);
ostream &operator<<(ostream &os, const i128 &v) {
    if(v == 0) { return (os << "0"); }
    i128 num = v;
    if(v < 0) { os << '-'; num = -num; }
    string s;
    for(; num > 0; num /= 10) { s.push_back((char)(num % 10) + '0'); }
    reverse(s.begin(), s.end());
    return (os << s);
}
void Yes(bool b=1) { cout << ( b == 1 ? "Yes" : "No" ) << "\n"; }
void YES(bool b=1) { cout << ( b == 1 ? "YES" : "NO" ) << "\n"; }
void No(bool b=1) { cout << ( b == 1 ? "No" : "Yes" ) << "\n"; }
void NO(bool b=1) { cout << ( b == 1 ? "NO" : "YES" ) << "\n"; }
void CIN() {}
template <typename T, class... U> void CIN(T &t, U &...u) { cin >> t; CIN(u...); }
void COUT() { cout << "\n"; }
template <typename T, class... U, char sep = ' '> void COUT(const T &t, const U &...u) { cout << t; if (sizeof...(u)) cout << sep; COUT(u...); }
#define dump(x) cerr << #x << ":"<< x << "\n";
#define vdump(x) rep(repeat, sz(x)) cerr << repeat << ":" << x[repeat] << "\n";
 
// macro
#define bp __builtin_popcountll
#define ALL(x) x.begin(),x.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define reps(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define sz(x) (ll)x.size()
ll xd[]={0, 1, 0, -1, 1, 1, -1, -1};
ll yd[]={1, 0, -1, 0, 1, -1, -1, 1};

// function
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T>int bl(T x) { int s = 0; while(x) {x >>= 1; s++;} return s; } // bitlength
ll rmax(ll a, ll b){return max(a, b);}
ll rmin(ll a, ll b){return min(a, b);}
ll rsum(ll a, ll b){return a + b;}
ll rzero(){return 0;}

// constant
long double PI = 3.14159265358979;
#define INF32 2147483647
#define INF64 9223372036854775807
#define INF 922337203685477580
using mint = modint998244353;
// using mint = modint1000000007;


/* SOLVE BEGIN ************************************************************************** */

void solve()
{
  ll n, H;
  cin >> n >> H;
  vl a(n), b(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  
  segtree<ll, rsum, rzero> A(n), B(n);
  rep(i, n) A.set(i, a[i]);
  rep(i, n) B.set(i, b[i]);
  
  ll ans = 0, h = 0, sum = 0;
  deque<ll> Q;
  rep(i, n){
    Q.emplace_back(i);
    h += sz(Q) * b[i];
    sum += a[i];
    while(h > H){
      auto now = Q.front(); Q.pop_front();
      sum -= a[now];
      h -= B.prod(now, i + 1);
    }
    chmax(ans, sum);
  }
  cout << ans << "\n";
}

int main()
{
  NYAN
  solve();
  return 0;
}
0