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