結果
| 問題 | No.2694 The Early Bird Catches The Worm | 
| コンテスト | |
| ユーザー |  聪 | 
| 提出日時 | 2024-03-23 08:31:03 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 164 ms / 2,000 ms | 
| コード長 | 1,248 bytes | 
| コンパイル時間 | 920 ms | 
| コンパイル使用メモリ | 94,316 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-09-30 13:07:50 | 
| 合計ジャッジ時間 | 8,933 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 72 | 
ソースコード
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <map>
#include <unordered_map>
#include <queue>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <set>
#include <unordered_set>
#include <numeric>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define REP(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define FOR(i,a,b) for(int (i) = a; (i) < (b); ++(i))
int a[200010];
int b[200010];
int main ()
{
    int n, h;
    cin >> n >> h;
    REP(i,n) cin >> a[i];
    REP(i,n) cin >> b[i];
    int j = 0;
    ll hard = 0;
    ll best = 0;
    ll ans = 0;
    ll sum = 0;
    REP(i,n) {
        if (j < i) {
            j = i;
            hard = 0;
            best = 0;
            sum = 0;
        }
        while (j < n) {
            ll nxt = ll(j-i+1) * b[j];
            if (hard + nxt <= h) {
                hard += nxt;
                best += a[j];
                sum += b[j];
                ++j;
            } else break;
        }
        if (j > i) {
            ans = max(ans, best);
            sum -= b[i];
            hard -= b[i];
            hard -= sum;
            best -= a[i];
        }
    }
    cout << ans << endl;
}
            
            
            
        