結果

問題 No.553 AlphaCoder Rating
ユーザー hatoohatoo
提出日時 2017-10-11 14:46:58
言語 Rust
(1.72.1)
結果
AC  
実行時間 1 ms / 1,500 ms
コード長 2,402 bytes
コンパイル時間 985 ms
コンパイル使用メモリ 144,684 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-10 23:03:52
合計ジャッジ時間 2,206 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }

    #[allow(dead_code)]
    pub fn get2<T: FromStr, U: FromStr>() -> (T, U)
    where
        <T as FromStr>::Err: Debug,
        <U as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    }
}


#[allow(unused_macros)]
macro_rules! debug {
    ($x: expr) => {
        println!("{}: {:?}", stringify!($x), $x)
    }
}

fn f_large(n: usize) -> f64 {
    (1..n + 1)
        .map(|k| (0.81f64).powi(k as i32))
        .sum::<f64>()
        .sqrt() / (1..n + 1).map(|k| (0.9f64).powi(k as i32)).sum::<f64>()
}

fn f(n: usize) -> f64 {
    let f_large_inf = (0.81f64 / 0.19).sqrt() / 9.0;
    (f_large(n) - f_large_inf) / (f_large(1) - f_large_inf) * 1200.0
}

fn g(x: f64) -> f64 {
    (2.0f64).powf(x / 800.0)
}

fn g_inv(y: f64) -> f64 {
    800.0 * y.ln() / (2.0f64).ln()
}

fn rating(perfs: &[f64]) -> f64 {
    let n = perfs.len();
    g_inv(
        (1..n + 1)
            .map(|i| g(perfs[i - 1]) * (0.9f64).powi(i as i32))
            .sum::<f64>() / (1..n + 1).map(|i| (0.9f64).powi(i as i32)).sum::<f64>(),
    ) - f(n)
}


fn main() {
    let n: usize = util::get();
    let perfs: Vec<f64> = (0..n).map(|_| util::get::<usize>() as f64).collect();

    println!("{}", rating(&perfs).round() as i64);
}
0