結果
問題 |
No.135 とりあえず1次元の問題
|
ユーザー |
![]() |
提出日時 | 2016-04-03 22:48:23 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 702 bytes |
コンパイル時間 | 1,105 ms |
コンパイル使用メモリ | 68,000 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2025-01-03 14:32:00 |
合計ジャッジ時間 | 6,802 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 21 WA * 1 |
ソースコード
#include <vector> #include <climits> #include <algorithm> #include <iostream> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int num, val, ans = INT_MAX - 101; int lower, upper; vector<int> lst { INT_MIN + 100, INT_MAX - 100 }; vector<int>::iterator itIn, itRef; cin >> num; while(num) { --num; cin >> val; itIn = find_if(lst.begin(), lst.end(), [=](int l){ return val < l; }); itRef = lst.insert(itIn, val); lower = *(itRef + 0) - *(itRef - 1); upper = *(itRef + 1) - *(itRef + 0); if(lower == 0) { lst.erase(itRef); continue; } if(lower > 0) { ans = min(min(lower, upper), ans); } } cout << ans << endl; return 0; }