結果

問題 No.1148 土偶Ⅲ
ユーザー 37zigen37zigen
提出日時 2020-08-07 20:34:04
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 359 ms / 2,000 ms
コード長 289 bytes
コンパイル時間 172 ms
コンパイル使用メモリ 11,884 KB
実行使用メモリ 17,120 KB
最終ジャッジ日時 2023-10-24 22:52:41
合計ジャッジ時間 5,717 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,088 KB
testcase_01 AC 30 ms
10,088 KB
testcase_02 AC 29 ms
10,088 KB
testcase_03 AC 30 ms
10,088 KB
testcase_04 AC 28 ms
10,088 KB
testcase_05 AC 131 ms
12,928 KB
testcase_06 AC 341 ms
17,120 KB
testcase_07 AC 232 ms
16,032 KB
testcase_08 AC 301 ms
16,664 KB
testcase_09 AC 297 ms
16,664 KB
testcase_10 AC 142 ms
13,060 KB
testcase_11 AC 291 ms
16,688 KB
testcase_12 AC 46 ms
10,532 KB
testcase_13 AC 62 ms
10,968 KB
testcase_14 AC 54 ms
10,872 KB
testcase_15 AC 211 ms
15,828 KB
testcase_16 AC 98 ms
11,792 KB
testcase_17 AC 328 ms
16,988 KB
testcase_18 AC 38 ms
10,268 KB
testcase_19 AC 147 ms
13,120 KB
testcase_20 AC 183 ms
13,508 KB
testcase_21 AC 143 ms
13,056 KB
testcase_22 AC 48 ms
10,556 KB
testcase_23 AC 80 ms
10,200 KB
testcase_24 AC 109 ms
10,368 KB
testcase_25 AC 118 ms
10,372 KB
testcase_26 AC 359 ms
10,892 KB
testcase_27 AC 72 ms
10,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,w=map(int,input().split())
a=[int(input()) for _ in range(n)]
cnt={}
for v in a:
    cnt[v]=0
t=0
ans=0
sw=0
for s in range(n):
    while t<n and sw+a[t]<=w and cnt[a[t]]<=0:
        sw+=a[t]
        cnt[a[t]]+=1
        t+=1
    ans=max(ans,t-s)
    sw-=a[s]
    cnt[a[s]]-=1
print(ans)
0