結果

問題 No.135 とりあえず1次元の問題
ユーザー LV3zJigVW57oPGyLV3zJigVW57oPGy
提出日時 2022-11-18 18:27:30
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 411 bytes
コンパイル時間 1,794 ms
コンパイル使用メモリ 164,440 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-20 04:07:47
合計ジャッジ時間 2,796 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
4,368 KB
testcase_01 AC 1 ms
4,368 KB
testcase_02 AC 2 ms
4,368 KB
testcase_03 WA -
testcase_04 AC 1 ms
4,368 KB
testcase_05 AC 2 ms
4,368 KB
testcase_06 AC 2 ms
4,368 KB
testcase_07 AC 2 ms
4,368 KB
testcase_08 AC 2 ms
4,368 KB
testcase_09 AC 1 ms
4,368 KB
testcase_10 AC 2 ms
4,368 KB
testcase_11 AC 2 ms
4,368 KB
testcase_12 AC 2 ms
4,368 KB
testcase_13 AC 1 ms
4,368 KB
testcase_14 AC 2 ms
4,368 KB
testcase_15 AC 2 ms
4,368 KB
testcase_16 AC 2 ms
4,368 KB
testcase_17 AC 2 ms
4,368 KB
testcase_18 AC 2 ms
4,368 KB
testcase_19 AC 2 ms
4,368 KB
testcase_20 AC 2 ms
4,368 KB
testcase_21 AC 37 ms
4,368 KB
testcase_22 AC 40 ms
4,368 KB
evil01.txt AC 37 ms
4,368 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:16:11: warning: ‘count’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   16 |   cout << count;
      |           ^~~~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int a;
    cin >> a;
    int count;
    vector<int> vec(a);
    for(int i=0;i<a;i++) cin >> vec.at(i);
    sort(vec.begin(),vec.end());
    vec.erase(unique(vec.begin(),vec.end()),vec.end());
    for(int i=1;i<vec.size();i++){
      if(i==1) count = vec.at(i)-vec.at(i-1);
        count = min(count,vec.at(i)-vec.at(i-1));
    }
  cout << count;
}
0