結果
| 問題 | No.1148 土偶Ⅲ |
| ユーザー |
|
| 提出日時 | 2020-08-05 18:54:05 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 71 ms / 2,000 ms |
| コード長 | 432 bytes |
| 記録 | |
| コンパイル時間 | 573 ms |
| コンパイル使用メモリ | 85,504 KB |
| 実行使用メモリ | 93,312 KB |
| 最終ジャッジ日時 | 2026-04-06 05:05:03 |
| 合計ジャッジ時間 | 3,221 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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)