結果

問題 No.1021 Children in Classrooms
ユーザー akakimidoriakakimidori
提出日時 2020-04-10 21:31:27
言語 Rust
(1.77.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 911 bytes
コンパイル時間 3,707 ms
コンパイル使用メモリ 151,596 KB
実行使用メモリ 6,264 KB
最終ジャッジ日時 2023-10-13 23:25:44
合計ジャッジ時間 2,802 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,352 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 26 ms
6,252 KB
testcase_10 AC 27 ms
6,252 KB
testcase_11 AC 26 ms
6,196 KB
testcase_12 AC 25 ms
6,192 KB
testcase_13 AC 26 ms
6,264 KB
testcase_14 AC 26 ms
6,252 KB
testcase_15 AC 19 ms
4,368 KB
testcase_16 AC 18 ms
4,348 KB
testcase_17 AC 19 ms
4,412 KB
testcase_18 AC 23 ms
5,492 KB
testcase_19 AC 4 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let _m: usize = it.next().unwrap().parse().unwrap();
    let mut q: std::collections::VecDeque<_> = (0..n).map(|_| it.next().unwrap().parse().unwrap()).collect();
    let s: Vec<char> = it.next().unwrap().chars().collect();
    for c in s {
        if c == 'L' {
            let v = q.pop_front().unwrap();
            q.push_back(0);
            *q.front_mut().unwrap() += v;
        } else {
            let v = q.pop_back().unwrap();
            q.push_front(0);
            *q.back_mut().unwrap() += v;
        }
    }
    let mut ans = String::new();
    for a in q {
        ans.push_str(&format!("{} ", a));
    }
    ans.pop();
    println!("{}", ans);
}

fn main() {
    run();
}
0