結果

問題 No.2601 Very Poor
ユーザー 👑 KA37RIKA37RI
提出日時 2024-01-16 11:30:47
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 514 bytes
コンパイル時間 177 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 31,928 KB
最終ジャッジ日時 2024-01-16 11:30:54
合計ジャッジ時間 6,618 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
9,984 KB
testcase_01 AC 26 ms
9,984 KB
testcase_02 AC 27 ms
9,984 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 29 ms
10,112 KB
testcase_06 AC 29 ms
10,112 KB
testcase_07 AC 29 ms
10,112 KB
testcase_08 AC 28 ms
10,112 KB
testcase_09 AC 28 ms
10,112 KB
testcase_10 AC 28 ms
10,112 KB
testcase_11 AC 28 ms
10,112 KB
testcase_12 AC 28 ms
10,112 KB
testcase_13 AC 29 ms
10,112 KB
testcase_14 AC 34 ms
10,112 KB
testcase_15 AC 236 ms
31,928 KB
testcase_16 AC 223 ms
31,928 KB
testcase_17 AC 223 ms
31,928 KB
testcase_18 AC 221 ms
31,928 KB
testcase_19 AC 234 ms
31,928 KB
testcase_20 AC 226 ms
31,928 KB
testcase_21 AC 223 ms
31,928 KB
testcase_22 AC 222 ms
31,928 KB
testcase_23 AC 226 ms
31,928 KB
testcase_24 AC 233 ms
31,928 KB
testcase_25 AC 224 ms
31,928 KB
testcase_26 AC 223 ms
31,928 KB
testcase_27 AC 223 ms
31,928 KB
testcase_28 AC 223 ms
31,928 KB
testcase_29 AC 224 ms
31,928 KB
testcase_30 AC 222 ms
31,928 KB
testcase_31 AC 225 ms
31,928 KB
testcase_32 AC 228 ms
31,928 KB
testcase_33 AC 223 ms
31,928 KB
testcase_34 AC 221 ms
31,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(n, x, a):
	if n == 1:
		return a[0] if a[0] <= x else 0
	ans = 0
	r = 1
	s = 0
	for l in range(1, n - 1):
		while r < n - 1 and s + a[r] <= x:
			s += a[r]
			r += 1
			# print(f"+{a[r]}")
		ans = max(s, ans)
		s -= a[l]
		# print(f"-{a[l]}")
	
	r = 0
	s = sum(a)
	for l in range(n):
		while r <= l and s + a[r] <= x:
			s += a[r]
			r += 1
		if s <= x:
			ans = max(s, ans)
		s -= a[l]
		
	return ans

n, x = [int(y) for y in input().split()]
a = [int(y) for y in input().split()]

print(solve(n, x, a))
0