結果

問題 No.571 3人兄弟(その2)
ユーザー aimyaimy
提出日時 2017-10-06 22:33:40
言語 Rust
(1.77.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 968 bytes
コンパイル時間 1,039 ms
コンパイル使用メモリ 151,876 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-10 17:17:55
合計ジャッジ時間 1,788 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,384 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
  let vec: Vec<(i32,i32)> = read_tuples(3);
  
  let abc = ["A","B","C"];
  let mut vec = vec.iter().map(|&(h,w)|(-h,w)).zip(abc.iter()).collect::<Vec<_>>();
  vec.sort();
  let ans = vec.iter().map(|&(_,c)|c).collect::<Vec<_>>();
  
  print_vec(&ans, "\n");
}

fn read_tuple<T1: std::str::FromStr, T2: std::str::FromStr>() -> (T1, T2) {
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).ok();
  let mut it = buf.trim().split_whitespace();
  let x = it.next().unwrap().parse::<T1>().ok().unwrap();
  let y = it.next().unwrap().parse::<T2>().ok().unwrap();
  (x, y)
}

fn read_tuples<T1: std::str::FromStr, T2: std::str::FromStr>(n: usize) -> Vec<(T1, T2)> {
  let mut vec: Vec<(T1, T2)> = vec![];
  for _ in 0 .. n {
    vec.push(read_tuple());
  }
  vec
}

fn print_vec<T: std::string::ToString>(vec: &Vec<T>, sep: &str) {
  let out = vec.iter().map(|e| e.to_string()).collect::<Vec<_>>().as_slice().join(sep);
  println!("{}", out);
}
0