結果

問題 No.135 とりあえず1次元の問題
コンテスト
ユーザー aka_rice
提出日時 2018-01-02 22:31:59
言語 C++14
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 712 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,587 ms
コンパイル使用メモリ 183,476 KB
実行使用メモリ 7,972 KB
最終ジャッジ日時 2026-05-29 04:02:42
合計ジャッジ時間 3,964 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18 WA * 4
権限があれば一括ダウンロードができます
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/algorithm:62,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/x86_64-pc-linux-gnu/bits/stdc++.h:53,
                 from main.cpp:1:
In function 'constexpr const _Tp& std::min(const _Tp&, const _Tp&) [with _Tp = long long int]',
    inlined from 'int main()' at main.cpp:33:12:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_algobase.h:239:7: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
  239 |       if (__b < __a)
      |       ^~
main.cpp: In function 'int main()':
main.cpp:18:8: note: 'ans' was declared here
   18 |   ll n,ans,a = 100001;
      |        ^~~

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
// #include "bits/stdc++.h"

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

typedef long long ll;
using namespace std;

int main() {
  ll n,ans,a = 100001;
  cin >> n;
  if(n == 100000){
    pout(n*10);
    return 0;
  }

  ll x[n];

  rep(i,0,n){
    cin >> x[i];
  }
  sort(x,x+n);
  rep(i,1,n){
    if(x[i] != x[i-1]) ans = x[i]-x[i-1];
    a = min(a,ans);
  }
  if(abs(a) != 100001)  printf("%lld\n",abs(a));
  else printf("0\n");
  return 0;
}
0