結果

問題 No.135 とりあえず1次元の問題
コンテスト
ユーザー RCCW
提出日時 2017-02-04 18:54:07
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 48 ms / 5,000 ms
コード長 482 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,509 ms
コンパイル使用メモリ 186,288 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2026-03-03 22:17:00
合計ジャッジ時間 2,602 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:15:11: warning: ignoring return value of 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = long long int; _Alloc = std::allocator<long long int>; size_type = long unsigned int]', declared with attribute 'nodiscard' [-Wunused-result]
   15 |     l.size();
      |     ~~~~~~^~
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/vector:68,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/queue:69,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/x86_64-pc-linux-gnu/bits/stdc++.h:160,
                 from main.cpp:1:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_vector.h:1117:7: note: declared here
 1117 |       size() const _GLIBCXX_NOEXCEPT
      |       ^~~~

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;

long long a,minv=1000003;
int main(void){
    cin>>a;
	vector<long long> l;
long long c;
	for (int i = 0; i < a; ++i) {
		cin>>c;
		l.push_back(c);
	}
	sort(l.begin(),l.end());
	l.erase(unique(l.begin(), l.end()), l.end());
    l.size();
/*    for (int i = 0; i < l.size(); ++i) {
		cout<<l[i]<<endl;
	}*/

	for (int i = 0; i < l.size()-1; ++i) {
		minv=min(abs(l[i+1]-l[i]),minv);
	}
	if(l.size()==1){minv=0;};
	cout<<minv<<endl;


}
0