結果

問題 No.2035 Tunnel
ユーザー ygd.ygd.
提出日時 2022-08-12 21:47:01
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 964 bytes
コンパイル時間 742 ms
コンパイル使用メモリ 11,800 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2023-10-24 09:25:35
合計ジャッジ時間 5,272 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,104 KB
testcase_01 AC 30 ms
10,104 KB
testcase_02 AC 29 ms
10,104 KB
testcase_03 AC 30 ms
10,104 KB
testcase_04 AC 29 ms
10,104 KB
testcase_05 AC 181 ms
10,464 KB
testcase_06 AC 179 ms
10,464 KB
testcase_07 AC 177 ms
10,464 KB
testcase_08 AC 64 ms
10,464 KB
testcase_09 AC 182 ms
10,464 KB
testcase_10 AC 175 ms
10,464 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 85 ms
10,224 KB
testcase_22 AC 88 ms
10,324 KB
testcase_23 AC 51 ms
10,196 KB
testcase_24 AC 106 ms
10,384 KB
testcase_25 AC 127 ms
10,468 KB
testcase_26 AC 120 ms
10,444 KB
testcase_27 AC 163 ms
10,464 KB
testcase_28 AC 90 ms
10,324 KB
testcase_29 WA -
testcase_30 AC 47 ms
10,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
#input = sys.stdin.readline
#input = sys.stdin.buffer.readline #文字列はダメ
#sys.setrecursionlimit(1000000)
#import bisect
#import itertools
#import random
#from heapq import heapify, heappop, heappush
#from collections import defaultdict 
#from collections import deque
#import copy
#import math
#from functools import lru_cache
#@lru_cache(maxsize=None)
#MOD = pow(10,9) + 7
#MOD = 998244353
#dx = [1,0,-1,0]
#dy = [0,1,0,-1]
#dx8 = [1,1,0,-1,-1,-1,0,1]
#dy8 = [0,1,1,1,0,-1,-1,-1]

def main():
    N = int(input())
    S = str(input())

    ans = N
    idx = 0
    while idx < N and S[idx] == '.':
        idx += 1
    ans -= idx

    if ans == 0:
        print(ans);exit()
    
    seq = 0
    lag = 0
    for i in range(idx,N):
        if S[i] == '#':
            lag += 1
        else:
            lag -= 1
        lag = max(lag, 0)
        seq = max(seq, lag)
    
    ans += seq - 1
    print(ans)



if __name__ == '__main__':
    main()
0