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