結果
問題 | No.2694 The Early Bird Catches The Worm |
ユーザー | arad |
提出日時 | 2024-03-22 21:42:21 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 186 ms / 2,000 ms |
コード長 | 1,790 bytes |
コンパイル時間 | 5,403 ms |
コンパイル使用メモリ | 307,940 KB |
実行使用メモリ | 12,672 KB |
最終ジャッジ日時 | 2024-09-30 11:11:06 |
合計ジャッジ時間 | 13,838 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 3 ms
5,248 KB |
testcase_02 | AC | 2 ms
5,248 KB |
testcase_03 | AC | 1 ms
5,248 KB |
testcase_04 | AC | 2 ms
5,248 KB |
testcase_05 | AC | 2 ms
5,248 KB |
testcase_06 | AC | 3 ms
5,248 KB |
testcase_07 | AC | 2 ms
5,248 KB |
testcase_08 | AC | 3 ms
5,248 KB |
testcase_09 | AC | 2 ms
5,248 KB |
testcase_10 | AC | 3 ms
5,248 KB |
testcase_11 | AC | 2 ms
5,248 KB |
testcase_12 | AC | 2 ms
5,248 KB |
testcase_13 | AC | 2 ms
5,248 KB |
testcase_14 | AC | 2 ms
5,248 KB |
testcase_15 | AC | 2 ms
5,248 KB |
testcase_16 | AC | 3 ms
5,248 KB |
testcase_17 | AC | 2 ms
5,248 KB |
testcase_18 | AC | 3 ms
5,248 KB |
testcase_19 | AC | 1 ms
5,248 KB |
testcase_20 | AC | 2 ms
5,248 KB |
testcase_21 | AC | 3 ms
5,248 KB |
testcase_22 | AC | 3 ms
5,248 KB |
testcase_23 | AC | 2 ms
5,248 KB |
testcase_24 | AC | 50 ms
5,888 KB |
testcase_25 | AC | 43 ms
5,376 KB |
testcase_26 | AC | 56 ms
6,144 KB |
testcase_27 | AC | 78 ms
7,296 KB |
testcase_28 | AC | 82 ms
7,808 KB |
testcase_29 | AC | 27 ms
5,248 KB |
testcase_30 | AC | 130 ms
10,496 KB |
testcase_31 | AC | 75 ms
7,296 KB |
testcase_32 | AC | 149 ms
11,008 KB |
testcase_33 | AC | 136 ms
10,624 KB |
testcase_34 | AC | 8 ms
5,248 KB |
testcase_35 | AC | 69 ms
7,040 KB |
testcase_36 | AC | 94 ms
8,192 KB |
testcase_37 | AC | 155 ms
11,648 KB |
testcase_38 | AC | 99 ms
8,832 KB |
testcase_39 | AC | 24 ms
5,248 KB |
testcase_40 | AC | 75 ms
7,424 KB |
testcase_41 | AC | 36 ms
5,248 KB |
testcase_42 | AC | 5 ms
5,248 KB |
testcase_43 | AC | 14 ms
5,248 KB |
testcase_44 | AC | 153 ms
11,648 KB |
testcase_45 | AC | 145 ms
11,776 KB |
testcase_46 | AC | 47 ms
5,632 KB |
testcase_47 | AC | 48 ms
6,016 KB |
testcase_48 | AC | 89 ms
7,936 KB |
testcase_49 | AC | 98 ms
12,544 KB |
testcase_50 | AC | 98 ms
12,672 KB |
testcase_51 | AC | 98 ms
12,672 KB |
testcase_52 | AC | 98 ms
12,672 KB |
testcase_53 | AC | 99 ms
12,544 KB |
testcase_54 | AC | 179 ms
12,544 KB |
testcase_55 | AC | 180 ms
12,672 KB |
testcase_56 | AC | 176 ms
12,544 KB |
testcase_57 | AC | 186 ms
12,544 KB |
testcase_58 | AC | 170 ms
12,672 KB |
testcase_59 | AC | 183 ms
12,544 KB |
testcase_60 | AC | 181 ms
12,672 KB |
testcase_61 | AC | 183 ms
12,544 KB |
testcase_62 | AC | 184 ms
12,672 KB |
testcase_63 | AC | 181 ms
12,672 KB |
testcase_64 | AC | 168 ms
12,544 KB |
testcase_65 | AC | 180 ms
12,672 KB |
testcase_66 | AC | 178 ms
12,672 KB |
testcase_67 | AC | 171 ms
12,544 KB |
testcase_68 | AC | 168 ms
12,672 KB |
testcase_69 | AC | 138 ms
12,544 KB |
testcase_70 | AC | 138 ms
12,544 KB |
testcase_71 | AC | 139 ms
12,672 KB |
testcase_72 | AC | 137 ms
12,672 KB |
testcase_73 | AC | 138 ms
12,672 KB |
testcase_74 | AC | 69 ms
7,936 KB |
testcase_75 | AC | 138 ms
12,672 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; #include <atcoder/all> using namespace atcoder; using ll = long long; using VI = vector<int>; using VVI = vector<VI>; using VL = vector<ll>; using VVL = vector<VL>; using VD = vector<double>; using VVD = vector<VD>; using VS = vector<string>; using P = pair<ll,ll>; using VP = vector<P>; #define rep(i, n) for (ll i = 0; i < ll(n); i++) #define out(x) cout << x << endl #define dout(x) cout << fixed << setprecision(10) << x << endl #define all(a) (a).begin(),(a).end() #define rall(a) (a).rbegin(),(a).rend() #define sz(x) (int)(x.size()) #define re0 return 0 #define pcnt __builtin_popcountll template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } constexpr int inf = 1e9; constexpr ll INF = 1e18; //using mint = modint1000000007; using mint = modint998244353; int di[4] = {1,0,-1,0}; int dj[4] = {0,1,0,-1}; int main(){ ll n,h; cin >> n >> h; VL a(n),b(n),c(n); rep(i,n) cin >> a[i]; rep(i,n) cin >> b[i]; rep(i,n) c[i] = (i+1)*b[i]; VL cmla(n+1),cmlb(n+1),cmlc(n+1); rep(i,n) cmla[i+1] = cmla[i]+a[i]; rep(i,n) cmlb[i+1] = cmlb[i]+b[i]; rep(i,n) cmlc[i+1] = cmlc[i]+c[i]; ll ans = 0; rep(i,n){ if(h < b[i]) continue; auto get = [&](ll x){ ll res = cmlc[x]-cmlc[i]; res -= i*(cmlb[x]-cmlb[i]); return res; }; ll ok = i+1,ng = n+1; while(abs(ok-ng)>1){ ll mid = (ok+ng)/2; if(get(mid) <= h) ok = mid; else ng = mid; //cout << i << ' ' << mid << ' ' << get(mid) << endl; } chmax(ans,cmla[ok]-cmla[i]); } out(ans); }