結果

問題 No.476 正しくない平均
ユーザー Elk
提出日時 2018-05-30 23:32:12
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 404 bytes
コンパイル時間 102 ms
コンパイル使用メモリ 22,784 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-30 08:26:33
合計ジャッジ時間 964 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |     scanf("%lld %lld\n", &N, &a);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
main.cpp:9:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |         scanf("%lld", &num[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

int main(){
    long long int N, a, i;
    long long int num[10], ave, sum = 0;

    scanf("%lld %lld\n", &N, &a);
    for(i = 0; i < N; i++){
        scanf("%lld", &num[i]);
        sum += num[i];
    }
    ave = sum/N;
    //printf("a = %lld ave = %lld\n", a, ave);
    if(a == ave && sum%N == 0){
        printf("YES\n");
    }else{
        printf("NO\n");
    }

    return 0;

}
0