結果

問題 No.406 鴨等間隔の法則
ユーザー mbanmban
提出日時 2016-08-09 22:33:12
言語 C90
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 652 bytes
コンパイル時間 355 ms
コンパイル使用メモリ 21,504 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-04-24 20:16:14
合計ジャッジ時間 9,009 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 AC 0 ms
5,248 KB
testcase_02 AC 0 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:8:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |         scanf("%d\n", &N);
      |         ^~~~~~~~~~~~~~~~~
main.c:11:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |                 scanf("%d", &x[i]);
      |                 ^~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>
#include<stdlib.h>

int N;
int *x;

int main() {
	scanf("%d\n", &N);
	x = (int *)malloc(sizeof(int)*N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &x[i]);
	}
	int i,j;
	for (i = N - 1; i >= 0; i--) {
		for (j = 0; j < i; j++) {
			if (x[j] > x[j + 1]) {
				int k = x[j];
				x[j] = x[j + 1];
				x[j + 1] = k;
			}
		}
	}
	for (int i = 0; i < N - 1; i++) {
		if (x[i] == x[i + 1]) {
			printf("NO\n");
			return 0;
		}
	}
	int width = x[1] - x[0];
	if (N == 2) {
		printf("YES\n");
		return 0;
	}
	for (int i = 2; i < N; i++) {
		if (x[i] - x[i - 1] != width) {
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}
0