結果

問題 No.135 とりあえず1次元の問題
ユーザー kaffelunkaffelun
提出日時 2017-08-26 16:49:16
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 414 bytes
コンパイル時間 413 ms
コンパイル使用メモリ 48,760 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-23 17:13:46
合計ジャッジ時間 1,196 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
6,816 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 1 ms
6,812 KB
testcase_03 WA -
testcase_04 AC 1 ms
6,940 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1 ms
6,944 KB
testcase_08 WA -
testcase_09 AC 1 ms
6,940 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 1 ms
6,940 KB
testcase_13 AC 1 ms
6,940 KB
testcase_14 AC 1 ms
6,940 KB
testcase_15 AC 1 ms
6,940 KB
testcase_16 WA -
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 14 ms
6,944 KB
testcase_22 AC 19 ms
6,944 KB
evil01.txt AC 16 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:8:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |         scanf("%d", &N);
      |         ~~~~~^~~~~~~~~~
main.cpp:11:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |                 scanf("%d", &t);
      |                 ~~~~~^~~~~~~~~~
main.cpp:22:27: warning: ‘m’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   22 |                 if(a && m > a) m = a;
      |                         ~~^~~

ソースコード

diff #

#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int main() {
	int N, t;
	scanf("%d", &N);
	vector<int> X;
	for(int i = 0; i < N; i++) {
		scanf("%d", &t);
		X.push_back(t);
	}
	if(!N) {
		printf("0\n");
		return 0;
	}
	sort(X.begin(), X.end());
	int m;
	for(int i = 0; i < N - 1; i++) {
		int a = abs(X[i] - X[i + 1]);
		if(a && m > a) m = a;
	}
	printf("%d\n", m);
}
0