Main » 2013 September 28 » [NOIP2012模拟赛No.4]监狱
11:08 AM [NOIP2012模拟赛No.4]监狱 |
set#include<cstdio> #include<cstdlib> #include<cstring> #include<set> #include<algorithm> #include<map> #include<vector> #include<queue> #include<iostream> #include<string> #define ittype multiset<int>::iterator #define FOR(i,a,b) for(i=(a);i<=(b);i++) #define ROF(i,a,b) for(i=(a);i>=(b);i--) typedef long long LL; using namespace std; multiset<int> S; int main() { int x,n,i; scanf("%d",&n); scanf("%d",&x);S.insert(x); int ans=2E9; FOR(i,2,n) { scanf("%d",&x); ittype it=S.insert(x),it2,it3; if (it!=S.begin()) {it2=it;it2--;ans=min(ans,x-(*it2));} it3=it;it3++; if (it3!=S.end()) ans=min(ans,(*it3)-x); printf("%d\n",ans); } } |
|
Total comments: 0 | |