結果

問題 No.2073 Concon Substrings (Swap Version)
ユーザー phspls
提出日時 2022-10-16 12:34:33
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 731 bytes
コンパイル時間 12,361 ms
コンパイル使用メモリ 384,148 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-27 08:48:50
合計ジャッジ時間 14,530 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).ok();
    let n: usize = n.trim().parse().unwrap();
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let s = s.trim().chars().collect::<Vec<_>>();

    let mut cnts = vec![vec![0usize; 3]; 3];
    for i in 0..3*n {
        match s[i] {
            'c' => { cnts[0][i%3] += 1; },
            'o' => { cnts[1][i%3] += 1; },
            'n' => { cnts[2][i%3] += 1; },
            _ => {},
        }
    }
    let result = (0..3).map(|i| cnts[0][i%3].min(cnts[1][(i+1)%3]).min(cnts[2][(i+2)%3])).sum::<usize>();
    let result = if result == n && cnts[0][0] < n { result-1 } else { result };
    println!("{}", result);
}
0