結果

問題 No.2553 Holidays
ユーザー hato336
提出日時 2023-11-25 14:48:26
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,182 bytes
コンパイル時間 422 ms
コンパイル使用メモリ 82,260 KB
実行使用メモリ 100,004 KB
最終ジャッジ日時 2024-09-26 10:47:41
合計ジャッジ時間 12,301 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10 WA * 45
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections,sys,math,functools,operator,itertools,bisect,heapq,decimal,string,time,random
#sys.setrecursionlimit(10**9)
#sys.set_int_max_str_digits(0)

#alist = list(map(int,input().split()))
#alist = []
#
n,m = map(int,input().split())
#for i in range(n):
#    alist.append(list(map(int,input().split())))
s = list(input())
ans = s.count('o')
temp = []
no = 0
s.append(['x'])
for i in range(n+1):
    if s[i] != 'x':
        temp.append(s[i])
        continue
    else:
        for j in range(1,len(temp)-1):
            if temp[j-1] == 'o' and temp[j] == '-' and temp[j+1] == 'o':
                temp[j] = 'o'
                ans += 1
        for j in range(2,len(temp)):
            if temp[j-2] == 'o' and temp[j-1] == '-' and temp[j] == '-' and m:
                m -= 1
                ans += 2
                temp[j-1] == 'o'
                temp[j] = 'o'
        for j in reversed(range(len(temp)-2)):
            if temp[j+2] == 'o' and temp[j+1] == '-' and temp[j] == '-' and m:
                m -= 1
                ans += 2
                temp[j+1] == 'o'
                temp[j] = 'o'
        no += temp.count('-')
        temp.clear()
print(ans + min(no,m))
0