結果

問題 No.406 鴨等間隔の法則
ユーザー Maeda
提出日時 2025-03-18 10:38:32
言語 C
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 646 bytes
コンパイル時間 3,820 ms
コンパイル使用メモリ 25,600 KB
実行使用メモリ 7,324 KB
最終ジャッジ日時 2025-03-18 10:38:51
合計ジャッジ時間 11,074 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other TLE * 2 -- * 27
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:6:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |         scanf("%d",&n);
      |         ^~~~~~~~~~~~~~
main.c:9:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |                 scanf("%d",&duckList[i]);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <stdbool.h>

void main(void) {
	int n = 0;
	scanf("%d",&n);
	int duckList[n];
	for(int i = 0 ; i < n ; i++){
		scanf("%d",&duckList[i]);
	}
	bool duckFlg = true;
	for(int i = 0 ; i < n ; i++){
		for(int j = i ; j < n ; j++){
		 	if(duckList[i] < duckList[j]){
				int num = duckList[i];
				duckList[i] = duckList[j];
				duckList[j] = num;
		 	}
		}
	}
	int criteria = duckList[0] - duckList[1];
	if(criteria == 0){
		duckFlg = false;
	}else{
		for(int i = 1 ; i < n-1 ; i++){
			if(criteria != duckList[i] - duckList[i+1]){
				duckFlg = false;
			}
		}
	}
	if(duckFlg){
		printf("YES");
	}else{
		printf("NO");
	}
}
0