結果

問題 No.135 とりあえず1次元の問題
コンテスト
ユーザー regulus
提出日時 2017-11-22 18:48:17
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
TLE  
実行時間 -
コード長 669 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 279 ms
コンパイル使用メモリ 39,652 KB
最終ジャッジ日時 2026-02-22 00:33:26
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 2
other TLE * 1 -- * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <stdio.h>

#define F(i,n) for(int i = 0;i < n;i++)
#define N 1000001
void x(const int a[],int a_c[],int n){for(int i = 0;i < n;i++) a_c[i] = a[i];}
int y(const int a[],int n){int min,nb;min = a[0]; nb = 0;for(int i = 0;i < n;i++){if(min > a[i]) {min = a[i];	nb = i;}}return(nb);}
void z(const int a[],int b[],int n){int nb;int tmp[n];x(a,tmp,n);for(int i = 0;i < n;i++){nb = y(tmp,n);b[i] = tmp[nb];tmp[nb] = N;}}

int main(void){
	int n,t,r=N;
	scanf("%d",&n);
	int a[n];
	F(i,n)scanf("%d",&a[i]);
	z(a,a,n);
	F(i,n){
		if(i==n-1)break;
		t=a[i]-a[i+1];
		if(t!=0){
			if(t<0)t*=-1;
			if(r>t){
				r=t;
			}
		}
	}
	if(r==N)r=0;
	printf("%d",r);
	return 0;
}
0