結果
問題 | No.2694 The Early Bird Catches The Worm |
ユーザー |
|
提出日時 | 2024-03-22 22:00:49 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 55 ms / 2,000 ms |
コード長 | 867 bytes |
コンパイル時間 | 2,947 ms |
コンパイル使用メモリ | 248,484 KB |
実行使用メモリ | 7,936 KB |
最終ジャッジ日時 | 2024-09-30 11:32:04 |
合計ジャッジ時間 | 7,680 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 72 |
ソースコード
// #pragma GCC optimize("O3,unroll-loops")#include <bits/stdc++.h>// #include <x86intrin.h>using namespace std;#if __cplusplus >= 202002Lusing namespace numbers;#endifint 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;}/**/