結果

問題 No.2694 The Early Bird Catches The Worm
ユーザー inksamuraiinksamurai
提出日時 2024-03-22 21:59:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 1,311 bytes
コンパイル時間 2,178 ms
コンパイル使用メモリ 206,252 KB
実行使用メモリ 12,600 KB
最終ジャッジ日時 2024-03-22 21:59:26
合計ジャッジ時間 7,354 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 2 ms
6,548 KB
testcase_03 AC 2 ms
6,548 KB
testcase_04 AC 2 ms
6,548 KB
testcase_05 AC 2 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 AC 2 ms
6,548 KB
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 2 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 2 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 18 ms
6,548 KB
testcase_25 AC 17 ms
6,548 KB
testcase_26 AC 21 ms
6,548 KB
testcase_27 AC 29 ms
7,480 KB
testcase_28 AC 33 ms
7,756 KB
testcase_29 AC 12 ms
6,548 KB
testcase_30 AC 52 ms
11,160 KB
testcase_31 AC 29 ms
7,516 KB
testcase_32 AC 53 ms
11,340 KB
testcase_33 AC 52 ms
11,232 KB
testcase_34 AC 4 ms
6,548 KB
testcase_35 AC 27 ms
7,208 KB
testcase_36 AC 34 ms
8,028 KB
testcase_37 AC 59 ms
11,840 KB
testcase_38 AC 38 ms
8,480 KB
testcase_39 AC 10 ms
6,548 KB
testcase_40 AC 29 ms
7,516 KB
testcase_41 AC 15 ms
6,548 KB
testcase_42 AC 3 ms
6,548 KB
testcase_43 AC 6 ms
6,548 KB
testcase_44 AC 59 ms
11,864 KB
testcase_45 AC 58 ms
11,864 KB
testcase_46 AC 18 ms
6,548 KB
testcase_47 AC 19 ms
6,548 KB
testcase_48 AC 32 ms
7,756 KB
testcase_49 AC 48 ms
12,600 KB
testcase_50 AC 49 ms
12,600 KB
testcase_51 AC 50 ms
12,600 KB
testcase_52 AC 49 ms
12,600 KB
testcase_53 AC 49 ms
12,600 KB
testcase_54 AC 78 ms
12,600 KB
testcase_55 AC 66 ms
12,600 KB
testcase_56 AC 65 ms
12,600 KB
testcase_57 AC 65 ms
12,600 KB
testcase_58 AC 64 ms
12,600 KB
testcase_59 AC 66 ms
12,600 KB
testcase_60 AC 66 ms
12,600 KB
testcase_61 AC 65 ms
12,600 KB
testcase_62 AC 65 ms
12,600 KB
testcase_63 AC 66 ms
12,600 KB
testcase_64 AC 64 ms
12,600 KB
testcase_65 AC 65 ms
12,600 KB
testcase_66 AC 65 ms
12,600 KB
testcase_67 AC 65 ms
12,600 KB
testcase_68 AC 65 ms
12,600 KB
testcase_69 AC 57 ms
12,600 KB
testcase_70 AC 56 ms
12,600 KB
testcase_71 AC 56 ms
12,600 KB
testcase_72 AC 56 ms
12,600 KB
testcase_73 AC 56 ms
12,600 KB
testcase_74 AC 28 ms
7,956 KB
testcase_75 AC 57 ms
12,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define int ll
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define rng(i,c,n) for(int i=c;i<n;i++)
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) ((int) a.size())
#define vec(...) vector<__VA_ARGS__>
#define _4ab8goq ios::sync_with_stdio(0),cin.tie(0);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
void print(){cout<<'\n';}
template<class h,class...t>
void print(const h&v,const t&...u){cout<<v<<' ',print(u...);}

void slv(){
	int n,h;
	cin>>n>>h;

	vi a(n);
	rep(i,n){
		cin>>a[i];
	}

	vi b(n);
	rep(i,n){
		cin>>b[i];
	}

	vi ps_a;
	rep(i,n){
		ps_a.pb((sz(ps_a)?ps_a.back():0)+a[i]);
	}

	vi ps_bc;
	rep(i,n){
		ps_bc.pb((sz(ps_bc)?ps_bc.back():0)+i*b[i]);
	}

	vi ps_b;
	rep(i,n){
		ps_b.pb((sz(ps_b)?ps_b.back():0)+b[i]);
	}

	auto range_sum=[&](vi&ps,int l,int r)->int{
		return ps[r]-(!l?0:ps[l-1]);
	};

	int ans=0;
	rep(i,n){
		int l=0,r=i;
		int opt=-1;
		while(l<=r){
			int m=(l+r)/2;
			int now=range_sum(ps_bc,m,i);
			now-=(m-1)*range_sum(ps_b,m,i);
			if(now<=h){
				opt=m,r=m-1;
			}else{
				l=m+1;
			}
		}
		if(opt!=-1){
			ans=max(ans,range_sum(ps_a,opt,i));
		}
	}
	cout<<ans<<"\n";
}

signed main(){
_4ab8goq;
	slv();
}
0