結果

問題 No.3324 ハイライト動画
コンテスト
ユーザー elphe
提出日時 2025-11-15 01:13:09
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 781 bytes
コンパイル時間 12,591 ms
コンパイル使用メモリ 400,192 KB
実行使用メモリ 17,708 KB
最終ジャッジ日時 2025-11-15 01:13:30
合計ジャッジ時間 14,918 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        _n: usize,
        m: usize,
        a: [u32; m],
    }
    println!("{}", output(solve(m, a)));
}

fn solve(m: usize, a: Vec<u32>) -> Vec<(u32, u32)> {
    let mut ans = Vec::with_capacity(m);
    for a in a {
        if let Some((s, l)) = ans.last_mut() {
            if a == *s + *l {
                *l += 1;
            } else {
                ans.push((a, 1));
            }
        } else {
            ans.push((a, 1));
        }
    }
    ans
}

fn output(ans: Vec<(u32, u32)>) -> String {
    ans.len().to_string()
        + "\n"
        + &ans
            .into_iter()
            .map(|(s, l)| s.to_string() + " " + &l.to_string())
            .collect::<Vec<_>>()
            .join("\n")
}
0