結果
| 問題 | No.123 カードシャッフル |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-02-01 11:50:15 |
| 言語 | Rust (1.93.0 + proconio + num + itertools) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 5,000 ms |
| コード長 | 769 bytes |
| 記録 | |
| コンパイル時間 | 1,548 ms |
| コンパイル使用メモリ | 202,568 KB |
| 実行使用メモリ | 7,968 KB |
| 最終ジャッジ日時 | 2026-02-01 11:50:22 |
| 合計ジャッジ時間 | 3,688 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 10 |
ソースコード
fn main() {
let stdin = std::io::read_to_string(std::io::stdin()).unwrap();
let mut stdin = stdin.split_ascii_whitespace();
let n: u8 = stdin.next().unwrap().parse().unwrap();
let m: usize = stdin.next().unwrap().parse().unwrap();
let a: Vec<u8> = (0..m)
.map(|_| stdin.next().unwrap().parse().unwrap())
.collect();
println!("{}", output(solve(n, a)));
}
fn solve(n: u8, a: Vec<u8>) -> u8 {
let mut cards = (1..=n).collect::<std::collections::VecDeque<_>>();
a.into_iter().for_each(|a| {
let c = cards
.drain(((a - 1) as usize)..=((a - 1) as usize))
.next()
.unwrap();
cards.push_front(c);
});
*cards.front().unwrap()
}
fn output(ans: u8) -> u8 {
ans
}