結果
| 問題 |
No.406 鴨等間隔の法則
|
| ユーザー |
mudbdb
|
| 提出日時 | 2016-08-05 23:00:21 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
AC
|
| 実行時間 | 26 ms / 2,000 ms |
| コード長 | 553 bytes |
| コンパイル時間 | 151 ms |
| コンパイル使用メモリ | 21,376 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-07 11:25:44 |
| 合計ジャッジ時間 | 1,503 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:10:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
10 | scanf("%d",&N);
| ^~~~~~~~~~~~~~
main.c:13:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
13 | scanf("%d",X+i);
| ^~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
#include <stdlib.h>
int cmp(const void *a, const void *b) {
return *(int*)a - *(int*)b;
}
int main() {
int N;
int *X;
int i;
scanf("%d",&N);
X = (int*)malloc(sizeof(int)*N);
for (i=0; i<N; i++) {
scanf("%d",X+i);
}
qsort(X, N, sizeof(int), cmp);
int d = X[1] - X[0];
int f = 0;
if (d != 0) {
for (i=2; i<N; i++) {
if (d != (X[i]-X[i-1])) {
f = 1;
break;
}
}
} else {
f = 1;
}
if (f == 0) {
printf("YES\n");
} else {
printf("NO\n");
}
return 0;
}
mudbdb