結果
問題 |
No.716 距離
|
ユーザー |
![]() |
提出日時 | 2018-07-28 14:19:02 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,257 bytes |
コンパイル時間 | 1,248 ms |
コンパイル使用メモリ | 163,180 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-05 18:25:40 |
合計ジャッジ時間 | 2,321 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 40 |
ソースコード
#include "bits/stdc++.h" using namespace std; #define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i) #define rep(i,n) repi(i,0,n) #define all(x) (x).begin(),(x).end() #define tsort(v) sort((v).begin(), (v).end()) #define trev(v) tsort(v); reverse((v).begin(), (v).end()) #define siz(v) ((int)(v).size()) #define ers(v, n) (v).erase((v).begin() + n) #define vmin(v) *min_element(v.begin(), v.end()) #define vmax(v) *max_element(v.begin(), v.end()) #define el "\n" #define co(x) cout<<(x)<<el #define coc(c, a, b) if(c)co((a));else co((b)) #define YES(c) coc(c,"YES", "NO") #define Yes(c) coc(c,"Yes", "No") #define yes(c) coc(c,"yes", "no") #ifdef tqktmp_2 #define gc() getchar(); getchar() #else #define gc() 1 #endif typedef long long lint; lint dx[8] = { 0,1,1,1,0,-1,-1,-1 }, dy[8] = { 1,1,0,-1,-1,-1,0,1 }; template<class T>bool maxi(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; } template<class T>bool mini(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; } int main(){ cin.tie(0); ios::sync_with_stdio(0); lint n,in,mn=INT_MAX;cin>>n; vector<lint> a; rep(i,n){ cin>>in;a.push_back(in); } tsort(a); rep(i,n-1){ mini(mn, a[i+1]-a[i]); } co(mn);co(a[n-1]-a[0]); }