結果
問題 | No.2035 Tunnel |
ユーザー |
|
提出日時 | 2022-08-19 13:20:26 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 171 ms / 2,000 ms |
コード長 | 799 bytes |
コンパイル時間 | 287 ms |
コンパイル使用メモリ | 82,028 KB |
実行使用メモリ | 117,072 KB |
最終ジャッジ日時 | 2024-10-07 17:58:26 |
合計ジャッジ時間 | 5,871 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
import sysinput = sys.stdin.readlinesys.setrecursionlimit(10 ** 7)INF = float("INF")MOD = 10 ** 9 + 7MOD2 = 998244353from heapq import heappop, heappushimport mathfrom collections import Counter, dequefrom itertools import accumulate, combinations, combinations_with_replacement, permutationsfrom bisect import bisect_left, bisect_rightimport decimaln = int(input())s = list(map(lambda x : 1 if x == "#" else 0, list(input().rstrip())))ad = 0ad_buff = 0dbl = Falselast = n - 1for i in range(n)[::-1]:if s[i]:last = iad = max(0, ad - ad_buff)ad_buff = 0if s[i]:if dbl:ad += 1else:dbl = Trueelse:if dbl:dbl = Falseelse:ad_buff += 1print(n - last + ad)