結果

問題 No.135 とりあえず1次元の問題
ユーザー HiroakiSoftwareHiroakiSoftware
提出日時 2015-01-26 01:02:09
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,144 bytes
コンパイル時間 434 ms
コンパイル使用メモリ 26,740 KB
実行使用メモリ 5,272 KB
最終ジャッジ日時 2023-08-31 01:28:09
合計ジャッジ時間 18,232 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,380 KB
testcase_06 WA -
testcase_07 AC 2 ms
4,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 1 ms
4,384 KB
testcase_11 AC 2 ms
4,376 KB
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 11 ms
4,380 KB
testcase_22 WA -
evil01.txt AC 4,238 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>



int *pX = nullptr;
int N = 0;


int GetDiff ( int idx1 , int idx2 );


int main ( void ) {

	int BufNums;


	scanf ( "%d" , &BufNums );

	pX = new int [ BufNums ];
	N = 0;
	int Current;
	bool bExistNumber;

	for ( int i = 0; i < BufNums; i++ ) {
		scanf ( "%d" , &Current);
		bExistNumber = false;

		for ( int j = 0; j < N; j++ ) {
			if ( Current == *( pX + j ) ) {
				bExistNumber = true;
				break;
			}
		}

		if ( bExistNumber == false ) {
			*( pX + N ) = Current;
			N++;
		}
	}



	if ( N != 1 ) {

		int MinNum;
		int buf;
		for ( int i = 0; i < (N-1); i++ ) {

			MinNum = i;
			for ( int j = i+1; j < N; j++ ) {
				if ( *( pX + i )  > *( pX + j ) ) MinNum = j;
			}

			buf = *( pX + i );
			*( pX + i ) = *( pX + MinNum );
			*( pX + MinNum ) = buf;
		}

		int diff = 0 , diffbuf;
		
		diff = *( pX + 0 ) - *( pX +  1 );
		if ( diff < 0 )diff *= -1;

		for ( int i = 1; i < N - 1; i++ ) {
			diffbuf = *( pX + i ) - *( pX + i + 1 );
			if ( diffbuf < 0 )diffbuf *= -1;
			if ( diff > diffbuf ) diff = diffbuf;
		}


		printf ( "%d\n" , diff );
	} else {
		printf ( "0\n" );

	}


	delete []pX;

	return 0;
}
0