結果

問題 No.2694 The Early Bird Catches The Worm
ユーザー shobonvipshobonvip
提出日時 2024-03-23 04:04:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 187 ms / 2,000 ms
コード長 629 bytes
コンパイル時間 191 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 133,140 KB
最終ジャッジ日時 2024-03-23 04:04:18
合計ジャッジ時間 12,199 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 36 ms
53,456 KB
testcase_03 AC 35 ms
53,460 KB
testcase_04 AC 39 ms
53,460 KB
testcase_05 AC 38 ms
53,460 KB
testcase_06 AC 44 ms
59,444 KB
testcase_07 AC 37 ms
53,460 KB
testcase_08 AC 43 ms
59,444 KB
testcase_09 AC 38 ms
53,460 KB
testcase_10 AC 38 ms
53,460 KB
testcase_11 AC 37 ms
53,460 KB
testcase_12 AC 39 ms
53,460 KB
testcase_13 AC 38 ms
53,460 KB
testcase_14 AC 39 ms
53,460 KB
testcase_15 AC 39 ms
53,460 KB
testcase_16 AC 39 ms
53,460 KB
testcase_17 AC 39 ms
53,460 KB
testcase_18 AC 39 ms
53,460 KB
testcase_19 AC 38 ms
53,460 KB
testcase_20 AC 39 ms
53,460 KB
testcase_21 AC 38 ms
53,460 KB
testcase_22 AC 39 ms
53,460 KB
testcase_23 AC 39 ms
53,460 KB
testcase_24 AC 81 ms
90,060 KB
testcase_25 AC 84 ms
87,944 KB
testcase_26 AC 88 ms
92,760 KB
testcase_27 AC 116 ms
98,656 KB
testcase_28 AC 104 ms
97,988 KB
testcase_29 AC 66 ms
79,208 KB
testcase_30 AC 130 ms
103,956 KB
testcase_31 AC 108 ms
98,760 KB
testcase_32 AC 152 ms
104,360 KB
testcase_33 AC 134 ms
104,456 KB
testcase_34 AC 61 ms
70,508 KB
testcase_35 AC 102 ms
98,008 KB
testcase_36 AC 139 ms
98,664 KB
testcase_37 AC 137 ms
108,644 KB
testcase_38 AC 122 ms
97,752 KB
testcase_39 AC 67 ms
78,136 KB
testcase_40 AC 96 ms
98,724 KB
testcase_41 AC 88 ms
84,608 KB
testcase_42 AC 50 ms
64,288 KB
testcase_43 AC 57 ms
70,444 KB
testcase_44 AC 144 ms
108,000 KB
testcase_45 AC 137 ms
108,000 KB
testcase_46 AC 88 ms
90,012 KB
testcase_47 AC 84 ms
90,272 KB
testcase_48 AC 106 ms
97,988 KB
testcase_49 AC 148 ms
113,436 KB
testcase_50 AC 145 ms
113,436 KB
testcase_51 AC 139 ms
113,564 KB
testcase_52 AC 141 ms
113,436 KB
testcase_53 AC 143 ms
113,584 KB
testcase_54 AC 187 ms
133,008 KB
testcase_55 AC 174 ms
133,008 KB
testcase_56 AC 166 ms
133,008 KB
testcase_57 AC 160 ms
133,012 KB
testcase_58 AC 165 ms
133,012 KB
testcase_59 AC 162 ms
132,880 KB
testcase_60 AC 164 ms
133,008 KB
testcase_61 AC 160 ms
133,012 KB
testcase_62 AC 162 ms
133,004 KB
testcase_63 AC 157 ms
132,752 KB
testcase_64 AC 164 ms
133,008 KB
testcase_65 AC 159 ms
132,884 KB
testcase_66 AC 169 ms
133,140 KB
testcase_67 AC 164 ms
133,008 KB
testcase_68 AC 166 ms
133,008 KB
testcase_69 AC 143 ms
128,276 KB
testcase_70 AC 142 ms
128,276 KB
testcase_71 AC 143 ms
128,272 KB
testcase_72 AC 143 ms
128,272 KB
testcase_73 AC 145 ms
128,276 KB
testcase_74 AC 97 ms
103,520 KB
testcase_75 AC 141 ms
128,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,h=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
rui=[0]*(n+1)
for i in range(n):
	rui[i+1]=rui[i]+b[i]

right = 0
now_manzoku = 0
now_hirou = 0
ans = 0
for left in range(n):
	while right<n:
		if right<left:
			now_hirou+=(right-left+1)*b[right]
			now_manzoku+=a[right]
			right+=1
			continue
		if now_hirou>h:break
		now_hirou+=(right-left+1)*b[right]
		now_manzoku+=a[right]
		right+=1
		if now_hirou>h:
			right-=1
			now_manzoku-=a[right]
			now_hirou-=(right-left+1)*b[right]
			break
	ans=max(ans,now_manzoku)
	now_manzoku-=a[left]
	now_hirou-=rui[right]-rui[left]
print(ans)
0