結果

問題 No.2694 The Early Bird Catches The Worm
ユーザー ypwwypww
提出日時 2024-02-15 22:15:22
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 57 ms / 2,000 ms
コード長 2,645 bytes
コンパイル時間 2,711 ms
コンパイル使用メモリ 197,824 KB
最終ジャッジ日時 2025-02-19 13:18:28
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 72
権限があれば一括ダウンロードができます

ソースコード

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);
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];
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;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0