結果

問題 No.135 とりあえず1次元の問題
ユーザー Maeda
提出日時 2025-03-18 16:50:48
言語 C
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 549 bytes
コンパイル時間 357 ms
コンパイル使用メモリ 25,856 KB
実行使用メモリ 9,116 KB
最終ジャッジ日時 2025-03-18 16:51:01
合計ジャッジ時間 13,267 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 2
other TLE * 1 -- * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
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",&numList[i]);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <string.h>

void main(void) {
	int n = 0;
	scanf("%d",&n);
	int numList[n];
	for(int i = 0; i < n ; i ++){
		scanf("%d",&numList[i]);
	}
	for(int i = 0; i < n ;i++){
		for(int j = i; j < n ;j++){
			if(numList[i] < numList[j]){
				int num = numList[i];
				numList[i] = numList[j];
				numList[j] = num;
			}
		}
	}
	int min = 100000;
	for(int i = 0; i < n-1 ; i ++){
		if(numList[i] == numList[i+1]){
			continue;
		}
		if(numList[i] -numList[i+1] < min){
			min = numList[i] -numList[i+1];
		}
	}
	printf("%d",min);
}
0