結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
9,984 KB
testcase_01 AC 27 ms
9,984 KB
testcase_02 AC 27 ms
9,984 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 32 ms
10,112 KB
testcase_06 AC 33 ms
10,112 KB
testcase_07 AC 31 ms
10,112 KB
testcase_08 AC 30 ms
10,112 KB
testcase_09 AC 29 ms
10,112 KB
testcase_10 AC 29 ms
10,112 KB
testcase_11 AC 29 ms
10,112 KB
testcase_12 AC 29 ms
10,112 KB
testcase_13 AC 29 ms
10,112 KB
testcase_14 AC 29 ms
10,112 KB
testcase_15 AC 250 ms
31,928 KB
testcase_16 AC 225 ms
31,928 KB
testcase_17 AC 223 ms
31,928 KB
testcase_18 AC 225 ms
31,928 KB
testcase_19 AC 223 ms
31,928 KB
testcase_20 AC 247 ms
31,928 KB
testcase_21 AC 225 ms
31,928 KB
testcase_22 AC 225 ms
31,928 KB
testcase_23 AC 226 ms
31,928 KB
testcase_24 AC 226 ms
31,928 KB
testcase_25 AC 235 ms
31,928 KB
testcase_26 AC 226 ms
31,928 KB
testcase_27 AC 228 ms
31,928 KB
testcase_28 AC 228 ms
31,928 KB
testcase_29 AC 227 ms
31,928 KB
testcase_30 AC 234 ms
31,928 KB
testcase_31 AC 228 ms
31,928 KB
testcase_32 AC 229 ms
31,928 KB
testcase_33 AC 229 ms
31,928 KB
testcase_34 AC 225 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
		if s <= x:
			ans = max(s, ans)
		s -= 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