結果
問題 | No.135 とりあえず1次元の問題 |
ユーザー |
![]() |
提出日時 | 2018-03-01 22:50:02 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 46 ms / 5,000 ms |
コード長 | 764 bytes |
コンパイル時間 | 782 ms |
コンパイル使用メモリ | 76,000 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-26 00:57:21 |
合計ジャッジ時間 | 2,241 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
ソースコード
// No.135 とりあえず1次元の問題 // https://yukicoder.me/problems/no/135 // #include <iostream> #include <algorithm> #include <queue> using namespace std; int main() { unsigned int N; cin >> N; priority_queue<int> pq; for (auto i = 0; i < N; ++i) { int t; cin >> t; pq.push(t); } const int MIN_DIFF_INIT = 999999999; int min_diff = MIN_DIFF_INIT; int prev = pq.top(); pq.pop(); while (!pq.empty()) { int current = pq.top(); pq.pop(); if (current != prev) { min_diff = min(prev - current, min_diff); prev = current; } } if (min_diff != MIN_DIFF_INIT) cout << min_diff << endl; else cout << 0 << endl; }