#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 p0 : m) {
for(auto p1 : m) {
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 |
1 |
Incorrect |
155 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
155 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
155 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
7032 ms |
816 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
155 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |