結果
問題 |
No.21 平均の差
|
ユーザー |
![]() |
提出日時 | 2017-11-02 00:10:09 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 550 bytes |
コンパイル時間 | 590 ms |
コンパイル使用メモリ | 66,712 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-22 14:52:14 |
合計ジャッジ時間 | 1,140 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 6 WA * 4 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:25:9: warning: ‘Min’ may be used uninitialized in this function [-Wmaybe-uninitialized] 25 | ans = Max - Min; | ~~~~^~~~~~~~~~~ main.cpp:25:9: warning: ‘Max’ may be used uninitialized in this function [-Wmaybe-uninitialized]
ソースコード
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main(){ int N, K; cin >> N >> K; vector<int> v; for(int i = 0; i < N; i++){ int a; cin >> a; v.push_back(a); } sort(v.begin(), v.end()); double Max, Min; double ans; if(N % 2 == 0 || N == 3){ Max = v[N-1]; Min = v[0]; }else if(N % 2 == 1 && N != 3){ Max = v[N-1]; Min = (v[0] + v[1]) / 2; } ans = Max - Min; cout << ans << endl; return 0; }