30 lines
704 B
C++
30 lines
704 B
C++
//
|
|
// Created by darian on 07.06.24.
|
|
//
|
|
|
|
#include <bits/stdc++.h>
|
|
using namespace std;
|
|
using ll = long long;
|
|
|
|
int main() {
|
|
ll x; cin >> x;
|
|
int n; cin >> n;
|
|
map<ll, int> distances;
|
|
distances[x] = 1;
|
|
set<pair<ll, ll>> lines = {{0, x}};
|
|
|
|
for (int i{}; i < n; i++) {
|
|
ll t; cin >> t;
|
|
auto it = lines.lower_bound({t, t});
|
|
--it;
|
|
auto p = *it;
|
|
lines.erase(p);
|
|
lines.insert({p.first, t});
|
|
lines.insert({t, p.second});
|
|
if (distances[p.second - p.first] == 1) distances.erase(p.second - p.first);
|
|
distances[t - p.first]++;
|
|
distances[p.second - t]++;
|
|
cout << (*distances.rbegin()).first << endl;
|
|
}
|
|
|
|
} |