Submission #631870

#TimeUsernameProblemLanguageResultExecution timeMemory
631870jhnah917Interval Collection (CCO20_day2problem2)C++14
4 / 25
541 ms48332 KiB
#include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; set<pair<int,int>> S; multiset<int> R; for(int i=1; i<=N; i++){ char op; int s, e; cin >> op >> s >> e; if(op == 'A'){ auto it = S.emplace(s, e).first; if(it != S.begin() && next(it) != S.end()){ R.erase(R.find(next(it)->second - prev(it)->first)); } if(it != S.begin()) R.insert(e - prev(it)->first); if(next(it) != S.end()) R.insert(next(it)->second - s); } else{ auto it = S.erase(S.find(make_pair(s, e))); if(it != S.end()) R.erase(R.find(it->second - s)); if(it != S.begin()) R.erase(R.find(e - prev(it)->first)); if(it != S.begin() && it != S.end()) R.insert(it->second - prev(it)->first); } if(R.empty()) cout << S.begin()->second - S.begin()->first << "\n"; else cout << *R.begin() << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...