結果
| 問題 |
No.2553 Holidays
|
| コンテスト | |
| ユーザー |
sasa8uyauya
|
| 提出日時 | 2025-02-23 10:20:30 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 702 bytes |
| コンパイル時間 | 226 ms |
| コンパイル使用メモリ | 82,540 KB |
| 実行使用メモリ | 76,912 KB |
| 最終ジャッジ日時 | 2025-02-23 10:20:36 |
| 合計ジャッジ時間 | 5,538 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 39 WA * 16 |
ソースコード
n,m=map(int,input().split())
s=input()
q=[[],[],[]]
i=0
while i<n:
if s[i]=="-":
l=i
r=i
while s[r]=="-":
r+=1
l-=1
if s[l]==s[r]=="o":
if (r-l-1)%2:
q[0]+=[r-l-1]
else:
q[1]+=[r-l-1]
elif s[l]==s[r]=="x":
q[2]+=[r-l-1]
else:
q[1]+=[r-l-1]
i=r+1
else:
i+=1
a=s.count("o")
q[0].sort()
for l in q[0]:
if m>=l//2:
a+=(l//2)*2+1
m-=l//2
else:
a+=m*2
m-=m
for l in q[1]:
if m>=l//2:
a+=(l//2)*2
m-=l//2
else:
a+=m*2
m-=m
q[2].sort()
for l in q[2][::-1]:
if m>0:
a+=1
m-=1
l-=1
if m>=l//2:
a+=(l//2)*2
m-=l//2
else:
a+=m*2
m-=m
print(a)
sasa8uyauya