結果

問題 No.135 とりあえず1次元の問題
ユーザー erieri
提出日時 2015-07-06 03:30:50
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 384 bytes
コンパイル時間 907 ms
コンパイル使用メモリ 64,900 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-11 02:16:03
合計ジャッジ時間 2,060 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
6,812 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 WA -
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 1 ms
6,944 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 1 ms
6,940 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 1 ms
6,940 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 32 ms
6,940 KB
testcase_22 AC 37 ms
6,944 KB
evil01.txt AC 33 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:19: warning: overflow in conversion from ‘long int’ to ‘int’ changes value from ‘9999999999’ to ‘1410065407’ [-Woverflow]
    7 |         int ans = 9999999999, n; cin >> n;
      |                   ^~~~~~~~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(void)
{
	int ans = 9999999999, n; cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; i++){
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	for (int i = 0; i < n-1; i++){
		if (v[i + 1] != v[i]){
			int tmp = v[i + 1] - v[i];
			if (tmp < ans){ ans = tmp; }
		}
	}
	cout << ans << endl;
	return 0;
}
0