| 3 | using namespace::std; |
| 4 | |
| 5 | signed main(){ |
| 6 | ios_base::sync_with_stdio(false),cin.tie(nullptr); |
| 7 | |
| 8 | int x, n; cin >> x >> n; |
| 9 | set<int> lights{0,x}; |
| 10 | multiset<int>dist{x}; |
| 11 | |
| 12 | for(int i = 0; i < n; ++i){ |
| 13 | int pos; cin >> pos; |
| 14 | auto it1 = lights.upper_bound(pos); |
| 15 | auto it2 = it1; |
| 16 | --it2; |
| 17 | |
| 18 | dist.erase(dist.find(*it1 - *it2)); |
| 19 | dist.insert(pos - *it2); |
| 20 | dist.insert(*it1 - pos); |
| 21 | lights.insert(pos); |
| 22 | |
| 23 | auto ans = dist.end(); |
| 24 | --ans; |
| 25 | cout << *ans << " "; |
| 26 | } |
| 27 | return 0; |
| 28 | } |
| 29 | // if our max is on left side and element add on right no affect else affect |
| 30 | // 1 2 3 4 5 6 7 8 |
| 31 | // 3 |