結果

問題 No.406 鴨等間隔の法則
ユーザー ykringum
提出日時 2019-04-26 00:07:09
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 459 bytes
コンパイル時間 130 ms
コンパイル使用メモリ 29,440 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-07 12:37:16
合計ジャッジ時間 1,789 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>

int comp(const void* a, const void* b) {
  return *(int*)a - *(int*)b;
}
int main(void) {
  int n, d, a, i, s[1000000];
  scanf("%d", &n);

  for( i = 0; i < n; i++ )
  scanf("%d", &s[i]);
  qsort(s, n, sizeof(int), comp);
  d = s[1] - s[0];

  for( i = 1; i < n - 1; i++ ) {
    a = s[i+1] - s[i];
    if( a == 0 || d != a) {
      printf("NO\n");
      return 0;
    }
    d = a;
  }
  printf("YES\n");
  return 0;
}
0