結果

問題 No.2553 Holidays
ユーザー KudeKude
提出日時 2023-11-25 14:15:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 88 ms / 2,000 ms
コード長 938 bytes
コンパイル時間 319 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 77,060 KB
最終ジャッジ日時 2023-11-25 14:16:01
合計ジャッジ時間 5,099 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
75,772 KB
testcase_01 AC 77 ms
75,664 KB
testcase_02 AC 76 ms
75,796 KB
testcase_03 AC 80 ms
75,784 KB
testcase_04 AC 75 ms
75,792 KB
testcase_05 AC 45 ms
61,500 KB
testcase_06 AC 42 ms
55,584 KB
testcase_07 AC 46 ms
61,500 KB
testcase_08 AC 45 ms
61,496 KB
testcase_09 AC 53 ms
61,500 KB
testcase_10 AC 79 ms
76,936 KB
testcase_11 AC 79 ms
76,924 KB
testcase_12 AC 76 ms
76,924 KB
testcase_13 AC 83 ms
77,060 KB
testcase_14 AC 82 ms
76,916 KB
testcase_15 AC 49 ms
64,264 KB
testcase_16 AC 52 ms
66,352 KB
testcase_17 AC 49 ms
64,264 KB
testcase_18 AC 49 ms
64,260 KB
testcase_19 AC 54 ms
66,360 KB
testcase_20 AC 47 ms
61,952 KB
testcase_21 AC 47 ms
61,952 KB
testcase_22 AC 46 ms
61,824 KB
testcase_23 AC 53 ms
61,952 KB
testcase_24 AC 46 ms
61,952 KB
testcase_25 AC 88 ms
75,672 KB
testcase_26 AC 67 ms
72,592 KB
testcase_27 AC 71 ms
73,880 KB
testcase_28 AC 69 ms
73,492 KB
testcase_29 AC 75 ms
72,596 KB
testcase_30 AC 38 ms
53,460 KB
testcase_31 AC 37 ms
53,460 KB
testcase_32 AC 37 ms
53,460 KB
testcase_33 AC 37 ms
53,460 KB
testcase_34 AC 36 ms
53,460 KB
testcase_35 AC 38 ms
53,460 KB
testcase_36 AC 37 ms
53,460 KB
testcase_37 AC 37 ms
53,460 KB
testcase_38 AC 37 ms
53,460 KB
testcase_39 AC 37 ms
53,460 KB
testcase_40 AC 37 ms
53,460 KB
testcase_41 AC 37 ms
53,460 KB
testcase_42 AC 37 ms
53,460 KB
testcase_43 AC 37 ms
53,460 KB
testcase_44 AC 37 ms
53,460 KB
testcase_45 AC 37 ms
53,460 KB
testcase_46 AC 37 ms
53,460 KB
testcase_47 AC 37 ms
53,460 KB
testcase_48 AC 38 ms
53,460 KB
testcase_49 AC 37 ms
53,460 KB
testcase_50 AC 37 ms
53,460 KB
testcase_51 AC 37 ms
53,460 KB
testcase_52 AC 37 ms
53,460 KB
testcase_53 AC 37 ms
53,460 KB
testcase_54 AC 37 ms
53,460 KB
testcase_55 AC 38 ms
53,460 KB
testcase_56 AC 37 ms
53,460 KB
testcase_57 AC 37 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())
ans = 0
d2 = []
g2 = 0
d1 = []
g1 = 0
for s in input().split('x'):
    ans += s.count('o')
    seg = s.split('o')
    if len(seg) == 1:
        l = len(seg[0])
        if l:
            d1.append(l)
    else:
        for l in map(len, [seg[0], seg[-1]]):
            if l % 2 == 0:
                g2 += l // 2
            else:
                g2 += l // 2
                g1 += 1
        for l in map(len, seg[1:-1]):
            if l % 2 == 0:
                g2 += l // 2
            else:
                d2.append(l)
d2.sort()
d1.sort(reverse=True)
for l in d2:
    if m >= l // 2:
        ans += l
        m -= l // 2
    else:
        ans += 2 * m
        m = 0
t = min(m, g2)
ans += 2 * t
m -= t
for l in d1:
    if not m:
        break
    ans += 1
    m -= 1
    l -= 1
    while m and l >= 2:
        m -= 1
        ans += 2
        l -= 2
    g1 += l
t = min(m, g1)
ans += t
m -= t
print(ans)
0