結果
| 問題 |
No.2553 Holidays
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-09-15 15:22:05 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 896 bytes |
| コンパイル時間 | 208 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 78,336 KB |
| 最終ジャッジ日時 | 2024-09-15 15:22:11 |
| 合計ジャッジ時間 | 5,700 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 WA * 27 |
ソースコード
n, m = map(int, input().split())
S = input()
S = "x" + S + "x"
ans = S.count("o")
S = S.split("o")
A = []
two = 0
one = 0
B = []
for T in S:
if "x" not in T:
le = len(T)
if le == 1:
ans += 1
elif le % 2 == 1:
A.append(le // 2)
else:
two += le // 2
else:
row = T.split("x")
for i in range(len(row)):
le = len(row[i])
if le == 0:
continue
if i == 0 or i == len(row) - 1:
two += le // 2
if le % 2 == 1:
one += 1
else:
B.append(le)
C = []
A.sort()
for a in A:
C += [2] * (a // 2 - 1)
C += [3]
C += [2] * two
B.sort()
for b in B:
C += [1]
if b % 2 == 0:
b -= 1
one += 1
C += [2] * (b // 2)
C += [1] * one
ans += sum(C[:m])
print(ans)