結果

問題 No.2035 Tunnel
ユーザー neginagi
提出日時 2022-08-19 13:16:02
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 741 bytes
コンパイル時間 232 ms
コンパイル使用メモリ 82,072 KB
実行使用メモリ 117,156 KB
最終ジャッジ日時 2024-10-07 17:53:12
合計ジャッジ時間 5,927 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
INF = float("INF")
MOD = 10 ** 9 + 7
MOD2 = 998244353
from heapq import heappop, heappush
import math
from collections import Counter, deque
from itertools import accumulate, combinations, combinations_with_replacement, permutations
from bisect import bisect_left, bisect_right
import decimal

n = int(input())
s = list(map(lambda x : 1 if x == "#" else 0, list(input().rstrip())))
ad = 0
dbl = False
last = n - 1
for i in range(n)[::-1]:
    if s[i]:
        last = i
    if s[i]:
        if dbl:
            ad += 1
        else:
            dbl = True
    else:
        if dbl:
            dbl = False
        else:
            ad = max(0, ad - 1)
print(n - last + ad)
0