結果

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

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <vector>
#include <algorithm>
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 = X[i + 1] - X[i];
		if(a && m > a) m = a;
	}
	printf("%d\n", m);
	return 0;
}
0