結果
| 問題 |
No.1021 Children in Classrooms
|
| コンテスト | |
| ユーザー |
akakimidori
|
| 提出日時 | 2020-04-10 21:31:27 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 26 ms / 2,000 ms |
| コード長 | 911 bytes |
| コンパイル時間 | 14,376 ms |
| コンパイル使用メモリ | 377,412 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-15 19:17:42 |
| 合計ジャッジ時間 | 14,777 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
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();
}
akakimidori