結果

問題 No.135 とりあえず1次元の問題
ユーザー monburan_0401monburan_0401
提出日時 2018-09-05 12:44:26
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 1,260 bytes
コンパイル時間 425 ms
コンパイル使用メモリ 32,000 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-25 22:51:46
合計ジャッジ時間 1,884 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 0 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 12 ms
6,940 KB
testcase_22 WA -
evil01.txt WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

/*	数直線上の整数座標上に𝑁個の点がある。

その中から同じ座標ではない2点を選んで、その2点の距離を求める。
距離は、𝑖番目の点の座標を𝑋𝑖、𝑗番目の点の座標を𝑋𝑗とすると 、
絶対値|𝑋𝑖−𝑋𝑗|とする。

この時、最小の距離となる2点を選ぶとして、選んだ2点間の最小距離を求めてください。
条件にあう2点を選べなかったら0を出力してください。*/

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main(void){
	int N;
	int num[100000];
	int min;		//	求める最小値
	int L = 0;
	
	scanf("%d",&N);
	for(int i = 0; i < N; i++){
		scanf("%d",&num[i]);
		
/*		if(i == 0){
			min = num[0];
		} else if (min < num[i]){
			min = num[i] ;		//	最大値の値を入れておく。
		}
		//	printf("%d回目はmin = %d\n",i,min);		//	check
*/
	}
	// min *= 2;		//	num[2] = {0,100}を回避するため、倍にする。
	
	for(int j = 0; j < N-1; j++){
		for(int k = j; k < N; k++){
			min = abs(num[k] - num[j]);
			if( (L < min) && (L != 0) ){
				min = L;
			}
		}
	}
	
	for(int l = 0; l < N; l++){
		if(min == num[l] * 2){
			printf("0\n");
			return 0;
		}
	}
	
	printf("%d\n",min);
	
	return 0;
}
0