結果

問題 No.1134 Deviation Score Ⅱ
ユーザー magmag
提出日時 2020-08-10 21:57:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,046 bytes
コンパイル時間 1,771 ms
コンパイル使用メモリ 162,936 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-17 05:32:57
合計ジャッジ時間 3,390 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:40:6: warning: 'a' may be used uninitialized [-Wmaybe-uninitialized]
   40 |   ans=a;
      |   ~~~^~
main.cpp:29:19: note: 'a' was declared here
   29 |   long double dx2,a;
      |                   ^

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;
using ll=long long;
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
#define rep(i, n) rep2(i,0,n)

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int n,m;
  cin>>n;
  int x[n];
  rep(i,n)cin>>x[i];
  cin>>m;
  //平均値
  long double ave=0;
  rep(i,n)ave+=x[i];
  ave/=n;
  long double dxave=0,dx;
  //(1).全員の平均点との差の平方を求める
  rep(i,n){
    dx = x[i] - ave;
    dxave+=dx*dx;
  }
  //(2).(1)の平均の平方根を求める
  long double sq=sqrt(dxave);
  //ただし、(2) が 0 の時は、偏差値を 50 とする。(追記)
  int ans = 50,xm;
  long double dx2,a;
  dxave/=n;
  if(sq){
    xm = x[m - 1];
    dx = xm - ave;
    //(3).平均点との差に10をかけて(2)で割る。
    dx2 = dx * 10 / sq;
    a = floor( dx2 + ans );
    //(4).平均点より点数が高かった場合50に(3)を足し、そうでなければ(3)を引く
    if( dx2 + ans < 0 ) a = ceil( dx2 + ans );
  }
  ans=a;
  //偏差値
  cout<<ans<<endl;
}
0