Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- using ll = long long;
- using ld = long double;
- using pii = pair<int, int>;
- using pdd = pair<ld, ld>;
- int __intend = 0;
- void nextIntend(){__intend++;}
- void prevIntend(){__intend--;}
- string getIntend(){
- string r;
- for (int i = 0; i < __intend; ++i){
- r += '\t';
- }
- return r;
- }
- template<typename T>
- void print(const char s[], bool intend, T & v){
- if (intend) cout << getIntend();
- cout << s << " = " << v << endl;
- }
- template<typename T, typename... TA>
- void print(const char s[], bool intend, T & v, TA&... args){
- if (intend) cout << getIntend();
- while(*s != ','){
- if (*s != ' ') cout << *s;
- s++;
- }
- while(*s == ',' || *s == ' ') s++;
- cout << " = " << v << " | ";
- print(s, false, args...);
- }
- #if _DEBUG
- #define de if (1)
- #define dbg(...) print(#__VA_ARGS__, 1, __VA_ARGS__)
- #else
- #define de if (0)
- #define dbg(...)
- #endif
- #define ho(x) #x << " = " << x << " | "
- #define gint getIntend
- #define nint nextIntend
- #define pint prevIntend
- void solve(){
- de cout << "Started app" << endl;
- de cout.flush();
- int n, w, l;
- cin >> n >> w >> l;
- de cout << "Readed n w l" << endl;
- de cout << ho(n) << ho(w) << ho(l) << endl;
- multiset<int> curBatary;
- curBatary.insert(0);
- curBatary.insert(l);
- vector<vector<int>> startBatary(w + 2);
- vector<vector<int>> endBatary(w + 2);
- vector<int> mxLen(l);
- mxLen[0] = l;
- priority_queue<pii, vector<pii>, less<pii>> curMax;
- curMax.push({l, 0});
- for (int i = 0; i < n; ++i){
- int x, a, b;
- cin >> x >> a >> b;
- b++; // to [a, b)
- startBatary[a].push_back(x);
- endBatary[b].push_back(x);
- }
- de cout << "Readed batary" << endl;
- for (int i = 0; i <= w; ++i){
- de cout << gint() << ho(i) << endl;
- nint();
- for (int x : endBatary[i]){
- de cout << gint() << "delete " << ho(x) << endl;
- auto it = curBatary.erase(curBatary.find(x));
- int rx = *it;
- int lx = *--it;
- mxLen[lx] = rx - lx;
- de cout << gint() << "on " << lx << " put " << mxLen[lx] << endl;
- curMax.push({mxLen[lx], lx});
- }
- for (int x : startBatary[i]){
- de cout << gint() << "add " << ho(x) << endl;
- auto it = curBatary.insert(x);
- int lx = *--it;
- int rx = *++++it;
- mxLen[lx] = x - lx;
- mxLen[x] = rx - x;
- de cout << gint() << "on " << lx << " put " << mxLen[lx] << endl;
- de cout << gint() << "on " << x << " put " << mxLen[x] << endl;
- curMax.push({mxLen[lx], lx});
- curMax.push({mxLen[x], x});
- }
- while(curMax.size() && mxLen[curMax.top().second] != curMax.top().first){
- de cout << gint() << "false " << ho(curMax.top().first) << ho(curMax.top().second) << endl;
- curMax.pop();
- }
- pint();
- cout << curMax.top().first << endl;
- }
- }
- const bool fastIO = true;
- const bool withTest = false;
- const bool fileIO = false;
- #define file "file"
- int main(){
- #if _STRESS
- const bool fileIO = false;
- #endif
- #if !_DEBUG
- if (fileIO){
- freopen(file".in", "r", stdin);
- freopen(file".out", "w", stdout);
- }
- #endif
- if (fastIO){
- cin.tie(0);
- cout.tie(0);
- ios_base::sync_with_stdio(0);
- }
- if (withTest){
- int t;
- cin >> t;
- while(t--) solve();
- }
- else solve();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement