結果

問題 No.406 鴨等間隔の法則
ユーザー mosmos_21
提出日時 2016-10-15 17:37:45
言語 C90
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 416 bytes
コンパイル時間 285 ms
コンパイル使用メモリ 21,376 KB
実行使用メモリ 9,728 KB
最終ジャッジ日時 2024-11-07 06:29:18
合計ジャッジ時間 2,073 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21 WA * 8
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:8:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |   scanf("%ld", &n);
      |   ^~~~~~~~~~~~~~~~
main.c:9:20: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |   for(i=0;i<n;i++) scanf("%ld",&du[i]);
      |                    ^~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>
int comp(const void* a, const void* b){
  return *(int*)a - *(int*)b;
}
int main(){
  long int n,d,a,i,du[1000000];
  scanf("%ld", &n);
  for(i=0;i<n;i++) scanf("%ld",&du[i]);
  qsort(du,n,sizeof(int),comp);
  d = du[1]-du[0];
  for(i=2;i<n-1;i++){
    a=du[i+1]-du[i];
    if(a&&d!=a){
      printf("NO\n");
      return 0;
    }
    d=a;
  }
  printf("YES\n");
  return 0;
}
0