結果
問題 | No.1148 土偶Ⅲ |
ユーザー |
![]() |
提出日時 | 2020-08-05 20:30:43 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 365 ms / 2,000 ms |
コード長 | 340 bytes |
コンパイル時間 | 86 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 17,892 KB |
最終ジャッジ日時 | 2024-09-17 10:59:03 |
合計ジャッジ時間 | 4,905 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
ソースコード
N, W = map(int, input().split())A = [ int(input()) for i in range(N) ]cnts = {}for i in range(N):cnts[A[i]] = 0R = 0S = 0ans = 0for i in range(N):while R < N and S + A[R] <= W and cnts[A[R]] == 0:cnts[A[R]] += 1S += A[R]R += 1ans = max(ans, R - i)if R > i:cnts[A[i]] -= 1S -= A[i]else:R = i + 1print(ans)