結果
| 問題 |
No.553 AlphaCoder Rating
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-10-11 14:46:58 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 1,500 ms |
| コード長 | 2,402 bytes |
| コンパイル時間 | 12,629 ms |
| コンパイル使用メモリ | 400,904 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-17 09:38:54 |
| 合計ジャッジ時間 | 13,310 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
ソースコード
#[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);
}