結果

問題 No.406 鴨等間隔の法則
ユーザー r_k_816r_k_816
提出日時 2016-09-03 17:52:03
言語 C90
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 465 bytes
コンパイル時間 510 ms
コンパイル使用メモリ 21,248 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-04-24 20:40:39
合計ジャッジ時間 9,782 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 1 ms
5,248 KB
testcase_03 WA -
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:6:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |         scanf("%d",&n);
      |         ^~~~~~~~~~~~~~
main.c:10:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |                 scanf("%d",&data[i]);
      |                 ^~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>
void swap(int *a,int *b);

int main(void) {
	int n;
	scanf("%d",&n);
	int data[n];
	int i,j;
	for(i=0;i<n;i++){
		scanf("%d",&data[i]);
	}
	for(i=n-1;i>=0;i--){
		for(j=0;j<i;j++){
			if(data[j]>data[j+1])swap(&data[j],&data[j+1]);
		}
	}

	for(i=0;i<n-2;i++){
		if(data[i]-data[i+1]!=data[i+1]-data[i+2]){
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");

	return 0;
}


void swap(int *a,int *b){
	int temp;
	temp=*a;
	*a=*b;
	*b=temp;
}
0