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>
#define x first
#define y second
using namespace std;
int main() {
int q;
cin >> q;
multiset < pair < int, int > > m;
for(int i = 1; i <= q; ++i) {
int l, r;
char t;
cin >> t >> l >> r;
if(t == 'R') {
m.erase(m.find({l, r}));
} else {
m.insert({l, r});
}
int ans = 1e9, best = 1e9;
for(auto xp0 : m) {
for(auto xp1 : m) {
auto p0 = xp0, p1 = xp1;
if(p0.y < p1.y) swap(p0, p1);
int X = max(0, p1.y - p0.x);
int Y = p0.y - min(p0.x, p1.x);
if(ans == X) {
best = min(best, Y);
}
if(ans > X) {
ans = X;
best = Y;
}
}
}
cout << best << '\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... |