結果

問題 No.1134 Deviation Score Ⅱ
ユーザー Mister
提出日時 2020-08-01 06:47:14
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 948 bytes
コンパイル時間 1,256 ms
コンパイル使用メモリ 85,464 KB
最終ジャッジ日時 2025-01-12 12:13:24
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <numeric>
#include <cmath>
#include <vector>

using ldouble = long double;
constexpr ldouble EPS = 1e-10;

void solve() {
    int n;
    std::cin >> n;

    std::vector<ldouble> xs(n);
    for (auto& x : xs) std::cin >> x;

    ldouble ave = std::accumulate(xs.begin(), xs.end(), 0.L) / n;
    ldouble sv = std::sqrt(std::accumulate(xs.begin(), xs.end(), 0.L,
                                           [&](ldouble acc, ldouble x) {
                                               return acc + (x - ave) * (x - ave);
                                           }) /
                           n);

    if (sv < EPS) {
        std::cout << 50 << "\n";
        return;
    }

    int m;
    std::cin >> m;
    ldouble x = xs[--m];

    ldouble ans = (x - ave) * 10 / sv + 50;
    std::cout << (int)ans << "\n";
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}
0