結果

問題 No.1724 [Cherry 3rd Tune A] Lápiz labial de Sonia
ユーザー StrorkisStrorkis
提出日時 2021-10-29 22:43:05
言語 Rust
(1.77.0)
結果
AC  
実行時間 68 ms / 2,000 ms
コード長 2,159 bytes
コンパイル時間 1,063 ms
コンパイル使用メモリ 167,808 KB
実行使用メモリ 9,472 KB
最終ジャッジ日時 2024-04-16 15:32:16
合計ジャッジ時間 8,816 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 0 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 35 ms
5,888 KB
testcase_17 AC 65 ms
9,216 KB
testcase_18 AC 48 ms
7,424 KB
testcase_19 AC 19 ms
5,376 KB
testcase_20 AC 21 ms
5,376 KB
testcase_21 AC 68 ms
9,344 KB
testcase_22 AC 68 ms
9,344 KB
testcase_23 AC 67 ms
9,344 KB
testcase_24 AC 68 ms
9,472 KB
testcase_25 AC 67 ms
9,344 KB
testcase_26 AC 67 ms
9,376 KB
testcase_27 AC 67 ms
9,472 KB
testcase_28 AC 68 ms
9,344 KB
testcase_29 AC 68 ms
9,316 KB
testcase_30 AC 68 ms
9,344 KB
testcase_31 AC 66 ms
9,344 KB
testcase_32 AC 56 ms
9,472 KB
testcase_33 AC 56 ms
9,472 KB
testcase_34 AC 58 ms
9,216 KB
testcase_35 AC 58 ms
9,344 KB
testcase_36 AC 1 ms
5,376 KB
testcase_37 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

pub mod io {
    pub fn scan<R: std::io::BufRead>(r: &mut R) -> Vec<u8> {
        let mut res = Vec::new();
        loop {
            let buf = match r.fill_buf() {
                Ok(buf) => buf,
                Err(e) if e.kind() == std::io::ErrorKind::Interrupted => continue,
                Err(e) => panic!("{}", e), 
            };
            let (done, used, buf) = match buf.iter().position(u8::is_ascii_whitespace) {
                Some(i) => (i > 0 || res.len() > 0, i + 1, &buf[..i]),
                None => (buf.is_empty(), buf.len(), buf),
            };
            res.extend_from_slice(buf);
            r.consume(used);
            if done { return res; }
        }
    }

    #[macro_export]
    macro_rules! scan {
        ($r:expr, [$t:tt; $n:expr]) => ((0..$n).map(|_| scan!($r, $t)).collect::<Vec<_>>());
        ($r:expr, [$t:tt]) => (scan!($r, [$t; scan!($r, usize)]));
        ($r:expr, ($($t:tt),*)) => (($(scan!($r, $t)),*));
        ($r:expr, Usize1) => (scan!($r, usize) - 1);
        ($r:expr, String) => (String::from_utf8(scan!($r, Bytes)).unwrap());
        ($r:expr, Bytes) => (io::scan($r));
        ($r:expr, $t:ty) => (scan!($r, String).parse::<$t>().unwrap());
    }

    #[macro_export]
    macro_rules! input {
        ($r:expr, $($($v:ident)* : $t:tt),* $(,)?) => {
            $(let $($v)* = scan!($r, $t);)*
        };
    }
}


fn run<R: std::io::BufRead, W: std::io::Write>(reader: &mut R, writer: &mut W) {
    input! {
        reader,
        n: usize, k: usize,
        a: [i64; n],
        b: [i64; n],
    }

    let mut v: Vec<_> = {
        a.iter()
            .zip(b.iter())
            .enumerate()
            .map(|(i, (a, b))| (a - b, i))
            .collect()
    };
    v.sort();

    let mut ans = vec![b'B'; n];
    for (_, i) in v.into_iter().rev().take(k) {
        ans[i] = b'A';
    }
    writer.write_all(&ans).ok();
    writer.write_all(b"\n").ok();
}

fn main() {
    let (stdin, stdout) = (std::io::stdin(), std::io::stdout());
    let ref mut reader = std::io::BufReader::new(stdin.lock());
    let ref mut writer = std::io::BufWriter::new(stdout.lock());
    run(reader, writer);
}
0