結果
| 問題 | No.1148 土偶Ⅲ |
| ユーザー |
|
| 提出日時 | 2020-08-05 18:54:05 |
| 言語 | PyPy3 (8.0.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 109 ms / 2,000 ms |
| + 264µs | |
| コード長 | 432 bytes |
| 記録 | |
| コンパイル時間 | 237 ms |
| コンパイル使用メモリ | 96,236 KB |
| 実行使用メモリ | 93,952 KB |
| 最終ジャッジ日時 | 2026-08-29 10:44:21 |
| 合計ジャッジ時間 | 4,784 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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)