結果
問題 |
No.716 距離
|
ユーザー |
|
提出日時 | 2018-09-20 21:53:39 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 564 bytes |
コンパイル時間 | 536 ms |
コンパイル使用メモリ | 71,952 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-18 08:36:51 |
合計ジャッジ時間 | 1,438 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 40 |
ソースコード
#include<iostream> #include<string> #include<vector> #include<algorithm> using namespace std; int main() { int n; vector<int> a; bool flag=false; cin >> n; for (int i = 0;i < n;i++) { int buf; cin >> buf; a.push_back(buf); } for (int i = 0;i < a.size()-1;i++) { if (a[i] == a[i + 1])flag = true; } if (flag)cout << 0 << endl; else { int ans=1000000000; for (int i = 0;i < a.size()-1;i++) { int buf = abs(a[i+1]-a[i]); ans = min(ans,buf); } cout << ans << endl; } cout << abs(a[a.size() - 1] - a[0]) << endl; return 0; }