結果

問題 No.495 (^^*) Easy
コンテスト
ユーザー kachipan
提出日時 2023-06-30 14:55:30
言語 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
結果
WA  
実行時間 -
コード長 713 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 192 ms
コンパイル使用メモリ 42,068 KB
最終ジャッジ日時 2026-02-22 10:58:16
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#include <string.h>

int main()
{
	int num = 0;
	int point[2] = { 0 };
	int distance = 0;

	scanf("%d", &num);

	// 一番最初の座標をあらかじめ入れておく
	scanf("%d", &point[0]);

	// あらかじめいれておいた分を含めて1で初期化しておく
	for (int i = 1;i < num;i++)
	{
		int tmp = 0;
		scanf("%d", &point[1]);
		tmp = point[0] - point[1];
		tmp = abs(tmp);

		if (distance == 0 || (tmp < distance && tmp != 0))
		{
			distance = tmp;
		}
		// 次の座標と比べるために今回入力した値を1つ前の要素に格納
		point[0] = point[1];
	}

	printf("%d\n", distance);

	return 0;
}

0