This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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(it->second - s);
if(it != S.begin()) R.erase(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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |