結果
問題 | No.21 平均の差 |
ユーザー | rsk0315 |
提出日時 | 2020-03-15 21:50:52 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 271 bytes |
コンパイル時間 | 720 ms |
コンパイル使用メモリ | 56,596 KB |
最終ジャッジ日時 | 2025-01-09 07:09:31 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:7:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 7 | scanf("%zu %zu", &n, &k); | ~~~~~^~~~~~~~~~~~~~~~~~~ main.cpp:10:26: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | for (auto& ai: a) scanf("%d", &ai); | ~~~~~^~~~~~~~~~~
ソースコード
#include <cstdio> #include <algorithm> #include <vector> int main() { size_t n, k; scanf("%zu %zu", &n, &k); std::vector<int> a(n); for (auto& ai: a) scanf("%d", &ai); auto [it0, it1] = std::minmax_element(a.begin(), a.end()); printf("%d\n", *it1-*it0); }