結果
| 問題 | No.1148 土偶Ⅲ |
| ユーザー |
|
| 提出日時 | 2020-08-05 18:54:05 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 90 ms / 2,000 ms |
| コード長 | 432 bytes |
| 記録 | |
| コンパイル時間 | 507 ms |
| コンパイル使用メモリ | 82,252 KB |
| 実行使用メモリ | 88,448 KB |
| 最終ジャッジ日時 | 2024-09-17 08:53:37 |
| 合計ジャッジ時間 | 3,150 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
ソースコード
import sys
input = sys.stdin.readline
from collections import *
n, w = map(int, input().split())
a = [int(input()) for _ in range(n)]
ans = 0
r = 0
now = 0
cnt = defaultdict(int)
for l in range(n):
while r<n and now+a[r]<=w and cnt[a[r]]==0:
now += a[r]
cnt[a[r]] += 1
r += 1
ans = max(ans, r-l)
if l==r:
r += 1
else:
now -= a[l]
cnt[a[l]] -= 1
print(ans)