Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define ULL unsigned long long
- using namespace std;
- int N;
- ULL L, x2;
- vector<ULL>v;
- set<ULL>s;
- set<ULL>::iterator up1, up2;
- multiset<ULL>ms;
- int main()
- {
- ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- int i=0, j;
- ULL a, b;
- cin>>L>>N;
- if(N<=1000)
- {
- v.push_back(0);
- v.push_back(L);
- for(i=1; i<=N; ++i)
- {
- cin>>x2;
- v.push_back(x2);
- sort(v.begin(), v.end());
- ULL maxl=0, diff;
- for(j=1; j<(int)v.size(); ++j)
- {
- diff=v[j]-v[j-1]+1;
- if(diff > maxl)
- maxl=diff;
- }
- cout<<maxl<<'\n';
- }
- return 0;
- }
- s.insert(0);
- s.insert(L);
- for(i=1; i<=N; ++i)
- {
- cin>>x2;
- s.insert(x2);
- up1 = s.lower_bound(x2);
- if(*up1==x2)
- --up1;
- a=(*up1);
- up2 = s.upper_bound(x2);
- if(*up2==x2)
- ++up2;
- b=(*up2);
- ULL seg=(b-a+1);
- ms.emplace(x2-a+1);
- ms.emplace(b-x2+1);
- auto itr=ms.find(seg);
- if(*itr==seg)
- ms.erase(itr);
- cout<<*(ms.rbegin())<<'\n';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement