Submission #15528607


Source Code Expand

Copy
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        n: usize,
        k: usize,
        s: Chars,
    };
    let mut c = 0_i64;
    for (i, &s_i) in s.iter().enumerate().skip(1) {
        if s_i != s[i - 1] {
            c += 1;
        }
    }
    for _ in 0..k {
        c -= 2;
    }
    let ans = n as i64 - 1 - std::cmp::max(c, 0);
    println!("{}", ans);
}

Submission Info

Submission Time
Task D - Face Produces Unhappiness
User bouzuya
Language Rust (1.42.0)
Score 400
Code Size 396 Byte
Status
Exec Time 6 ms
Memory 2576 KB

Judge Result

Set Name Score / Max Score Test Cases
All 400 / 400 sample_01, sample_02, sample_03, testcase_01, testcase_02, testcase_03, testcase_04, testcase_05, testcase_06, testcase_07, testcase_08, testcase_09, testcase_10, testcase_11, testcase_12, testcase_13, testcase_14, testcase_15, testcase_16, testcase_17, testcase_18, testcase_19, testcase_20, testcase_21
Sample 0 / 0 sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
sample_01 6 ms 2108 KB
sample_02 2 ms 2128 KB
sample_03 1 ms 2004 KB
testcase_01 4 ms 2272 KB
testcase_02 3 ms 2484 KB
testcase_03 4 ms 2400 KB
testcase_04 2 ms 2448 KB
testcase_05 1 ms 2104 KB
testcase_06 2 ms 2576 KB
testcase_07 2 ms 2168 KB
testcase_08 3 ms 2532 KB
testcase_09 2 ms 2252 KB
testcase_10 2 ms 2468 KB
testcase_11 3 ms 2492 KB
testcase_12 1 ms 2008 KB
testcase_13 3 ms 2480 KB
testcase_14 3 ms 2444 KB
testcase_15 2 ms 2472 KB
testcase_16 2 ms 2480 KB
testcase_17 2 ms 2444 KB
testcase_18 2 ms 2468 KB
testcase_19 3 ms 2428 KB
testcase_20 1 ms 2124 KB
testcase_21 2 ms 2484 KB