結果

問題 No.2035 Tunnel
ユーザー taiga0629kyoprotaiga0629kyopro
提出日時 2022-08-12 21:36:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 76 ms / 2,000 ms
コード長 359 bytes
コンパイル時間 166 ms
コンパイル使用メモリ 81,800 KB
実行使用メモリ 102,292 KB
最終ジャッジ日時 2023-10-24 08:40:30
合計ジャッジ時間 2,982 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,476 KB
testcase_01 AC 37 ms
53,476 KB
testcase_02 AC 38 ms
53,476 KB
testcase_03 AC 38 ms
53,476 KB
testcase_04 AC 38 ms
53,476 KB
testcase_05 AC 73 ms
97,276 KB
testcase_06 AC 73 ms
97,280 KB
testcase_07 AC 76 ms
97,276 KB
testcase_08 AC 52 ms
77,424 KB
testcase_09 AC 53 ms
77,424 KB
testcase_10 AC 74 ms
102,292 KB
testcase_11 AC 64 ms
84,264 KB
testcase_12 AC 69 ms
88,888 KB
testcase_13 AC 48 ms
64,760 KB
testcase_14 AC 52 ms
67,608 KB
testcase_15 AC 67 ms
86,884 KB
testcase_16 AC 60 ms
79,120 KB
testcase_17 AC 45 ms
62,036 KB
testcase_18 AC 47 ms
62,536 KB
testcase_19 AC 54 ms
70,828 KB
testcase_20 AC 65 ms
84,376 KB
testcase_21 AC 55 ms
74,048 KB
testcase_22 AC 55 ms
74,152 KB
testcase_23 AC 49 ms
64,436 KB
testcase_24 AC 60 ms
78,020 KB
testcase_25 AC 62 ms
83,604 KB
testcase_26 AC 61 ms
82,004 KB
testcase_27 AC 70 ms
92,328 KB
testcase_28 AC 56 ms
75,080 KB
testcase_29 AC 49 ms
66,832 KB
testcase_30 AC 48 ms
63,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #


n=int(input())
s=list(input())
nod=[]
for i in range(n):
    if s[i]=="#":
        nod.append(i+1)
dp=[-1]*(n+3)
for ind in range(len(nod)-1,-1,-1):
    i=nod[ind]
    if ind==len(nod)-1:
        dp[i]=n-i+1
        continue
    j=nod[ind+1]
    t=dp[j]-1
    ni=i+t
    if ni<n-1:
        dp[i]=t+(n-ni+1)
    else:
        dp[i]=dp[j]+2
print(dp[nod[0]])
0