結果

問題 No.21 平均の差
ユーザー Syuutaro
提出日時 2018-03-13 22:43:45
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 295 bytes
コンパイル時間 341 ms
コンパイル使用メモリ 36,684 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-24 04:54:57
合計ジャッジ時間 1,035 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:6:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |     scanf("%d",&N);
      |     ~~~~~^~~~~~~~~
main.cpp:7:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |     scanf("%d",&K);
      |     ~~~~~^~~~~~~~~
main.cpp:11:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |         scanf("%d",&n[i]);
      |         ~~~~~^~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <algorithm>
int N,K;
int main(){
    //input
    scanf("%d",&N);
    scanf("%d",&K);

    int n[N];
    for (int i = 0;i < N;i++){
        scanf("%d",&n[i]);
    }

    //sort array n
    std::sort(n,n+N);

    //ouput
    printf("%d\n",n[N-1]-n[0]);

    return 0;
}
0