結果
問題 | No.447 ゆきこーだーの雨と雪 (2) |
ユーザー | tanzaku |
提出日時 | 2017-02-17 00:51:12 |
言語 | Rust (1.77.0 + proconio) |
結果 |
AC
|
実行時間 | 13 ms / 2,000 ms |
コード長 | 2,769 bytes |
コンパイル時間 | 11,975 ms |
コンパイル使用メモリ | 385,420 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-09 13:09:59 |
合計ジャッジ時間 | 13,713 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,248 KB |
testcase_02 | AC | 1 ms
5,248 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 7 ms
5,376 KB |
testcase_06 | AC | 10 ms
5,376 KB |
testcase_07 | AC | 5 ms
5,376 KB |
testcase_08 | AC | 6 ms
5,376 KB |
testcase_09 | AC | 9 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 3 ms
5,376 KB |
testcase_12 | AC | 4 ms
5,376 KB |
testcase_13 | AC | 9 ms
5,376 KB |
testcase_14 | AC | 12 ms
5,376 KB |
testcase_15 | AC | 3 ms
5,376 KB |
testcase_16 | AC | 3 ms
5,376 KB |
testcase_17 | AC | 3 ms
5,376 KB |
testcase_18 | AC | 2 ms
5,376 KB |
testcase_19 | AC | 13 ms
5,376 KB |
testcase_20 | AC | 11 ms
5,376 KB |
testcase_21 | AC | 3 ms
5,376 KB |
testcase_22 | AC | 2 ms
5,376 KB |
testcase_23 | AC | 3 ms
5,376 KB |
testcase_24 | AC | 8 ms
5,376 KB |
testcase_25 | AC | 10 ms
5,376 KB |
testcase_26 | AC | 5 ms
5,376 KB |
testcase_27 | AC | 5 ms
5,376 KB |
コンパイルメッセージ
warning: variable does not need to be mutable --> src/main.rs:81:13 | 81 | let mut competitor = competitors.get_mut(&name).unwrap(); | ----^^^^^^^^^^ | | | help: remove this `mut` | = note: `#[warn(unused_mut)]` on by default
ソースコード
// use std::cmp; use std::cmp::Ordering; use std::collections::HashMap; fn get_line() -> Vec<String> { let stdin = std::io::stdin(); let mut s = String::new(); loop { stdin.read_line(&mut s).ok(); let s = s.trim(); if s.len() != 0 { // println!("show: {}", s); return s.split_whitespace().map(|s| s.into()).collect(); } } } struct Competitor { name: String, score: Vec<i32>, sum_score: i32, update_time: i32, } impl Competitor { fn new(name: &str, n: usize) -> Competitor { Competitor { name: name.into(), score: vec![0; n], // score: Vec::with_capacity(n), sum_score: 0, update_time: 0, } } } // http://stackoverflow.com/questions/29884402/how-do-i-implement-ord-for-a-struct impl Ord for Competitor { fn cmp(&self, rhs: &Self) -> Ordering { let cmp = self.sum_score.cmp(&rhs.sum_score); if cmp == Ordering::Equal { rhs.update_time.cmp(&self.update_time) } else { cmp } } } impl PartialOrd for Competitor { fn partial_cmp(&self, rhs: &Self) -> Option<Ordering> { Some(self.cmp(rhs)) } } impl PartialEq for Competitor { fn eq(&self, rhs: &Self) -> bool { self.sum_score == rhs.sum_score } } impl Eq for Competitor { } fn main() { let n: usize = get_line()[0].parse().unwrap(); let levels: Vec<f64> = get_line().iter().map(|l| l.parse().unwrap()).collect(); assert_eq!(n, levels.len()); let t: i32 = get_line()[0].parse().unwrap(); let mut accepted: Vec<f64> = vec![0.0; n]; // let mut accepted: [i32; n]; let mut competitors = HashMap::new(); for times in 0..t { let words = get_line(); let name = words[0].to_string(); let p = (words[1].chars().nth(0).unwrap() as usize) - ('A' as usize); if !competitors.contains_key(&name) { competitors.insert(name.to_string(), Competitor::new(&name, n)); } accepted[p] += 1.0; let lv = levels[p]; let solve_score = (50.0 * lv + 50.0 * lv / (0.8 + 0.2 * accepted[p])).floor() as i32; let mut competitor = competitors.get_mut(&name).unwrap(); competitor.score[p] = solve_score; competitor.sum_score += solve_score; competitor.update_time = times; } let mut competitors_vec: Vec<_> = competitors.values().collect(); competitors_vec.sort(); competitors_vec.reverse(); for i in 0..competitors_vec.len() { let c = competitors_vec[i]; print!("{} {}", i+1, c.name); for i in 0..n { print!(" {}", c.score[i]); } println!(" {}", c.sum_score); } }