結果

問題 No.2694 The Early Bird Catches The Worm
コンテスト
ユーザー Aeren
提出日時 2024-03-22 22:00:49
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 25 ms / 2,000 ms
+ 417µs
コード長 867 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,192 ms
コンパイル使用メモリ 335,432 KB
実行使用メモリ 8,192 KB
最終ジャッジ日時 2026-09-06 17:06:54
合計ジャッジ時間 8,767 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 72
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

// #pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
// #include <x86intrin.h>
using namespace std;
#if __cplusplus >= 202002L
using namespace numbers;
#endif



int main(){
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(ios::badbit | ios::failbit);
	int n, th;
	cin >> n >> th;
	vector<int> a(n), b(n);
	copy_n(istream_iterator<int>(cin), n, a.begin());
	copy_n(istream_iterator<int>(cin), n, b.begin());
	vector<long long> prefa(n + 1), prefb(n + 1);
	for(auto i = 0; i < n; ++ i){
		prefa[i + 1] = prefa[i] + a[i];
		prefb[i + 1] = prefb[i] + b[i];
	}
	long long fat = 0, res = 0;
	for(auto l = 0, r = 0; l < n; ++ l){
		while(r < l || r < n && fat + 1LL * b[r] * (r + 1 - l) <= th){
			fat += 1LL * b[r] * (r + 1 - l);
			++ r;
		}
		res = max(res, prefa[r] - prefa[l]);
		fat -= prefb[r] - prefb[l];
	}
	cout << res << "\n";
	return 0;
}

/*

*/
0