結果

問題 No.1148 土偶Ⅲ
ユーザー 👑 rin204rin204
提出日時 2022-03-23 15:35:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 111 ms / 2,000 ms
コード長 354 bytes
コンパイル時間 251 ms
コンパイル使用メモリ 82,268 KB
実行使用メモリ 78,848 KB
最終ジャッジ日時 2024-04-19 23:32:32
合計ジャッジ時間 3,641 ms
ジャッジサーバーID
(参考情報)
judge6 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
52,096 KB
testcase_01 AC 33 ms
51,712 KB
testcase_02 AC 33 ms
51,584 KB
testcase_03 AC 33 ms
51,712 KB
testcase_04 AC 32 ms
52,352 KB
testcase_05 AC 81 ms
77,000 KB
testcase_06 AC 111 ms
78,592 KB
testcase_07 AC 88 ms
77,568 KB
testcase_08 AC 99 ms
77,952 KB
testcase_09 AC 94 ms
78,080 KB
testcase_10 AC 84 ms
77,184 KB
testcase_11 AC 93 ms
78,036 KB
testcase_12 AC 56 ms
68,352 KB
testcase_13 AC 75 ms
76,544 KB
testcase_14 AC 68 ms
74,368 KB
testcase_15 AC 85 ms
77,440 KB
testcase_16 AC 74 ms
76,928 KB
testcase_17 AC 104 ms
78,080 KB
testcase_18 AC 60 ms
70,400 KB
testcase_19 AC 86 ms
77,184 KB
testcase_20 AC 79 ms
77,424 KB
testcase_21 AC 71 ms
76,928 KB
testcase_22 AC 63 ms
72,064 KB
testcase_23 AC 67 ms
76,288 KB
testcase_24 AC 70 ms
76,544 KB
testcase_25 AC 73 ms
77,056 KB
testcase_26 AC 102 ms
78,848 KB
testcase_27 AC 64 ms
73,956 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, w = map(int, input().split())
A = [int(input()) for _ in range(n)] + [w + 1]
ans = 0
se = set()
r = 0
tot = 0
for l in range(n):
    while tot + A[r] <= w and A[r] not in se:
        se.add(A[r])
        tot += A[r]
        r += 1
    ans = max(ans, r - l)
    if l == r:
        r += 1
    else:
        se.remove(A[l])
        tot -= A[l]
print(ans)
0