結果
| 問題 |
No.406 鴨等間隔の法則
|
| コンテスト | |
| ユーザー |
funakoshi
|
| 提出日時 | 2019-08-20 13:53:30 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 26 ms / 2,000 ms |
| コード長 | 833 bytes |
| コンパイル時間 | 487 ms |
| コンパイル使用メモリ | 29,952 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-07 12:42:13 |
| 合計ジャッジ時間 | 1,668 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
int swap(const void* a, const void* b);
int main(void)
{
int kamo;
bool samedistance = true;
scanf("%d",&kamo);
int kamozahyou[kamo];
for(int i=0;i<kamo;i++)
{
scanf("%d",&kamozahyou[i]);
}
qsort(kamozahyou, kamo, sizeof(int), swap);
int sa = kamozahyou[0]-kamozahyou[1];
for(int i=0;i<kamo-1;i++)
{
if(sa!=kamozahyou[i]-kamozahyou[i+1])
{
samedistance=false;
break;
}
else if (sa==0)
{
samedistance=false;
break;
}
}
if(samedistance==true)
{
printf("YES");
}
else
{
printf("NO");
}
}
int swap(const void* a, const void* b)
{
return *(int*)b - *(int*)a;
}
funakoshi