結果
| 問題 | No.123 カードシャッフル | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2020-06-03 18:29:15 | 
| 言語 | Rust (1.83.0 + proconio) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 22 ms / 5,000 ms | 
| コード長 | 791 bytes | 
| コンパイル時間 | 12,980 ms | 
| コンパイル使用メモリ | 383,508 KB | 
| 実行使用メモリ | 6,824 KB | 
| 最終ジャッジ日時 | 2024-11-25 06:56:17 | 
| 合計ジャッジ時間 | 13,877 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 10 | 
ソースコード
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
fn main() {
  let nm:Vec<usize> = read_vec();
  let ops:Vec<usize> = read_vec();
  let mut sort = vec![None; nm[0]];
  for i in 0..nm[0] {
    sort[i] = Some(nm[0] - i);
  }
  for i in 0..ops.len() {
    let mut idx = 0;
    let mut count = 0;
    for j in 0..sort.len() {
      if sort[sort.len()-j-1].is_some() {
        count += 1;
        if count == ops[i] {
          idx = sort.len()-j-1;
          break;
        }
      }
    }
    let temp = sort[idx];
    sort[idx] = None;
    sort.push(temp);
  }
  println!("{}", sort[sort.len()-1].unwrap());
}
            
            
            
        