結果

問題 No.2035 Tunnel
ユーザー neginagineginagi
提出日時 2022-08-19 13:20:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 199 ms / 2,000 ms
コード長 799 bytes
コンパイル時間 249 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 117,120 KB
最終ジャッジ日時 2024-04-16 18:25:18
合計ジャッジ時間 6,787 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 142 ms
87,168 KB
testcase_01 AC 143 ms
86,912 KB
testcase_02 AC 144 ms
86,784 KB
testcase_03 AC 143 ms
86,528 KB
testcase_04 AC 142 ms
86,784 KB
testcase_05 AC 191 ms
116,864 KB
testcase_06 AC 195 ms
116,992 KB
testcase_07 AC 192 ms
117,120 KB
testcase_08 AC 183 ms
116,992 KB
testcase_09 AC 182 ms
116,992 KB
testcase_10 AC 187 ms
116,864 KB
testcase_11 AC 191 ms
111,360 KB
testcase_12 AC 196 ms
114,432 KB
testcase_13 AC 161 ms
90,752 KB
testcase_14 AC 168 ms
96,000 KB
testcase_15 AC 191 ms
111,360 KB
testcase_16 AC 186 ms
106,496 KB
testcase_17 AC 159 ms
89,344 KB
testcase_18 AC 158 ms
90,240 KB
testcase_19 AC 166 ms
98,176 KB
testcase_20 AC 189 ms
110,976 KB
testcase_21 AC 171 ms
98,688 KB
testcase_22 AC 172 ms
98,816 KB
testcase_23 AC 163 ms
91,904 KB
testcase_24 AC 176 ms
102,912 KB
testcase_25 AC 181 ms
106,624 KB
testcase_26 AC 185 ms
104,960 KB
testcase_27 AC 199 ms
113,792 KB
testcase_28 AC 175 ms
100,224 KB
testcase_29 AC 162 ms
92,544 KB
testcase_30 AC 160 ms
91,776 KB
権限があれば一括ダウンロードができます

ソースコード

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
ad_buff = 0
dbl = False
last = n - 1
for i in range(n)[::-1]:
    if s[i]:
        last = i
        ad = max(0, ad - ad_buff)
        ad_buff = 0
    if s[i]:
        if dbl:
            ad += 1
        else:
            dbl = True
    else:
        if dbl:
            dbl = False
        else:
            ad_buff += 1
print(n - last + ad)
0