#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 |
1 |
Correct |
183 ms |
384 KB |
Output is correct |
2 |
Correct |
13 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
256 KB |
Output is correct |
4 |
Correct |
3 ms |
256 KB |
Output is correct |
5 |
Correct |
208 ms |
384 KB |
Output is correct |
6 |
Correct |
18 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
256 KB |
Output is correct |
8 |
Correct |
11 ms |
384 KB |
Output is correct |
9 |
Correct |
326 ms |
384 KB |
Output is correct |
10 |
Correct |
165 ms |
388 KB |
Output is correct |
11 |
Correct |
133 ms |
404 KB |
Output is correct |
12 |
Correct |
150 ms |
508 KB |
Output is correct |
13 |
Correct |
407 ms |
516 KB |
Output is correct |
14 |
Correct |
426 ms |
392 KB |
Output is correct |
15 |
Correct |
433 ms |
388 KB |
Output is correct |
16 |
Correct |
418 ms |
388 KB |
Output is correct |
17 |
Correct |
216 ms |
384 KB |
Output is correct |
18 |
Correct |
15 ms |
384 KB |
Output is correct |
19 |
Correct |
3 ms |
384 KB |
Output is correct |
20 |
Correct |
3 ms |
256 KB |
Output is correct |
21 |
Correct |
186 ms |
392 KB |
Output is correct |
22 |
Correct |
16 ms |
384 KB |
Output is correct |
23 |
Correct |
5 ms |
384 KB |
Output is correct |
24 |
Correct |
4 ms |
256 KB |
Output is correct |
25 |
Correct |
281 ms |
384 KB |
Output is correct |
26 |
Correct |
160 ms |
384 KB |
Output is correct |
27 |
Correct |
130 ms |
384 KB |
Output is correct |
28 |
Correct |
134 ms |
384 KB |
Output is correct |
29 |
Correct |
404 ms |
384 KB |
Output is correct |
30 |
Correct |
429 ms |
384 KB |
Output is correct |
31 |
Correct |
393 ms |
360 KB |
Output is correct |
32 |
Correct |
434 ms |
404 KB |
Output is correct |
33 |
Correct |
3 ms |
256 KB |
Output is correct |
34 |
Correct |
3 ms |
256 KB |
Output is correct |
35 |
Correct |
3 ms |
256 KB |
Output is correct |
36 |
Correct |
2 ms |
256 KB |
Output is correct |
37 |
Correct |
5 ms |
384 KB |
Output is correct |
38 |
Correct |
4 ms |
384 KB |
Output is correct |
39 |
Correct |
3 ms |
384 KB |
Output is correct |
40 |
Correct |
2 ms |
256 KB |
Output is correct |
41 |
Correct |
100 ms |
384 KB |
Output is correct |
42 |
Correct |
6 ms |
384 KB |
Output is correct |
43 |
Correct |
3 ms |
256 KB |
Output is correct |
44 |
Correct |
2 ms |
384 KB |
Output is correct |
45 |
Correct |
93 ms |
384 KB |
Output is correct |
46 |
Correct |
6 ms |
384 KB |
Output is correct |
47 |
Correct |
3 ms |
256 KB |
Output is correct |
48 |
Correct |
3 ms |
256 KB |
Output is correct |
49 |
Correct |
138 ms |
384 KB |
Output is correct |
50 |
Correct |
139 ms |
384 KB |
Output is correct |
51 |
Correct |
170 ms |
384 KB |
Output is correct |
52 |
Correct |
142 ms |
384 KB |
Output is correct |
53 |
Correct |
138 ms |
384 KB |
Output is correct |
54 |
Correct |
142 ms |
384 KB |
Output is correct |
55 |
Correct |
137 ms |
384 KB |
Output is correct |
56 |
Correct |
138 ms |
384 KB |
Output is correct |
57 |
Correct |
143 ms |
384 KB |
Output is correct |
58 |
Correct |
139 ms |
384 KB |
Output is correct |
59 |
Correct |
274 ms |
388 KB |
Output is correct |
60 |
Correct |
292 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
183 ms |
384 KB |
Output is correct |
2 |
Correct |
13 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
256 KB |
Output is correct |
4 |
Correct |
3 ms |
256 KB |
Output is correct |
5 |
Correct |
208 ms |
384 KB |
Output is correct |
6 |
Correct |
18 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
256 KB |
Output is correct |
8 |
Correct |
11 ms |
384 KB |
Output is correct |
9 |
Correct |
326 ms |
384 KB |
Output is correct |
10 |
Correct |
165 ms |
388 KB |
Output is correct |
11 |
Correct |
133 ms |
404 KB |
Output is correct |
12 |
Correct |
150 ms |
508 KB |
Output is correct |
13 |
Correct |
407 ms |
516 KB |
Output is correct |
14 |
Correct |
426 ms |
392 KB |
Output is correct |
15 |
Correct |
433 ms |
388 KB |
Output is correct |
16 |
Correct |
418 ms |
388 KB |
Output is correct |
17 |
Correct |
216 ms |
384 KB |
Output is correct |
18 |
Correct |
15 ms |
384 KB |
Output is correct |
19 |
Correct |
3 ms |
384 KB |
Output is correct |
20 |
Correct |
3 ms |
256 KB |
Output is correct |
21 |
Correct |
186 ms |
392 KB |
Output is correct |
22 |
Correct |
16 ms |
384 KB |
Output is correct |
23 |
Correct |
5 ms |
384 KB |
Output is correct |
24 |
Correct |
4 ms |
256 KB |
Output is correct |
25 |
Correct |
281 ms |
384 KB |
Output is correct |
26 |
Correct |
160 ms |
384 KB |
Output is correct |
27 |
Correct |
130 ms |
384 KB |
Output is correct |
28 |
Correct |
134 ms |
384 KB |
Output is correct |
29 |
Correct |
404 ms |
384 KB |
Output is correct |
30 |
Correct |
429 ms |
384 KB |
Output is correct |
31 |
Correct |
393 ms |
360 KB |
Output is correct |
32 |
Correct |
434 ms |
404 KB |
Output is correct |
33 |
Correct |
3 ms |
256 KB |
Output is correct |
34 |
Correct |
3 ms |
256 KB |
Output is correct |
35 |
Correct |
3 ms |
256 KB |
Output is correct |
36 |
Correct |
2 ms |
256 KB |
Output is correct |
37 |
Correct |
5 ms |
384 KB |
Output is correct |
38 |
Correct |
4 ms |
384 KB |
Output is correct |
39 |
Correct |
3 ms |
384 KB |
Output is correct |
40 |
Correct |
2 ms |
256 KB |
Output is correct |
41 |
Correct |
100 ms |
384 KB |
Output is correct |
42 |
Correct |
6 ms |
384 KB |
Output is correct |
43 |
Correct |
3 ms |
256 KB |
Output is correct |
44 |
Correct |
2 ms |
384 KB |
Output is correct |
45 |
Correct |
93 ms |
384 KB |
Output is correct |
46 |
Correct |
6 ms |
384 KB |
Output is correct |
47 |
Correct |
3 ms |
256 KB |
Output is correct |
48 |
Correct |
3 ms |
256 KB |
Output is correct |
49 |
Correct |
138 ms |
384 KB |
Output is correct |
50 |
Correct |
139 ms |
384 KB |
Output is correct |
51 |
Correct |
170 ms |
384 KB |
Output is correct |
52 |
Correct |
142 ms |
384 KB |
Output is correct |
53 |
Correct |
138 ms |
384 KB |
Output is correct |
54 |
Correct |
142 ms |
384 KB |
Output is correct |
55 |
Correct |
137 ms |
384 KB |
Output is correct |
56 |
Correct |
138 ms |
384 KB |
Output is correct |
57 |
Correct |
143 ms |
384 KB |
Output is correct |
58 |
Correct |
139 ms |
384 KB |
Output is correct |
59 |
Correct |
274 ms |
388 KB |
Output is correct |
60 |
Correct |
292 ms |
504 KB |
Output is correct |
61 |
Correct |
1 ms |
256 KB |
Output is correct |
62 |
Correct |
1 ms |
256 KB |
Output is correct |
63 |
Correct |
1 ms |
256 KB |
Output is correct |
64 |
Execution timed out |
7019 ms |
732 KB |
Time limit exceeded |
65 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
183 ms |
384 KB |
Output is correct |
2 |
Correct |
13 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
256 KB |
Output is correct |
4 |
Correct |
3 ms |
256 KB |
Output is correct |
5 |
Correct |
208 ms |
384 KB |
Output is correct |
6 |
Correct |
18 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
256 KB |
Output is correct |
8 |
Correct |
11 ms |
384 KB |
Output is correct |
9 |
Correct |
326 ms |
384 KB |
Output is correct |
10 |
Correct |
165 ms |
388 KB |
Output is correct |
11 |
Correct |
133 ms |
404 KB |
Output is correct |
12 |
Correct |
150 ms |
508 KB |
Output is correct |
13 |
Correct |
407 ms |
516 KB |
Output is correct |
14 |
Correct |
426 ms |
392 KB |
Output is correct |
15 |
Correct |
433 ms |
388 KB |
Output is correct |
16 |
Correct |
418 ms |
388 KB |
Output is correct |
17 |
Correct |
216 ms |
384 KB |
Output is correct |
18 |
Correct |
15 ms |
384 KB |
Output is correct |
19 |
Correct |
3 ms |
384 KB |
Output is correct |
20 |
Correct |
3 ms |
256 KB |
Output is correct |
21 |
Correct |
186 ms |
392 KB |
Output is correct |
22 |
Correct |
16 ms |
384 KB |
Output is correct |
23 |
Correct |
5 ms |
384 KB |
Output is correct |
24 |
Correct |
4 ms |
256 KB |
Output is correct |
25 |
Correct |
281 ms |
384 KB |
Output is correct |
26 |
Correct |
160 ms |
384 KB |
Output is correct |
27 |
Correct |
130 ms |
384 KB |
Output is correct |
28 |
Correct |
134 ms |
384 KB |
Output is correct |
29 |
Correct |
404 ms |
384 KB |
Output is correct |
30 |
Correct |
429 ms |
384 KB |
Output is correct |
31 |
Correct |
393 ms |
360 KB |
Output is correct |
32 |
Correct |
434 ms |
404 KB |
Output is correct |
33 |
Correct |
3 ms |
256 KB |
Output is correct |
34 |
Correct |
3 ms |
256 KB |
Output is correct |
35 |
Correct |
3 ms |
256 KB |
Output is correct |
36 |
Correct |
2 ms |
256 KB |
Output is correct |
37 |
Correct |
5 ms |
384 KB |
Output is correct |
38 |
Correct |
4 ms |
384 KB |
Output is correct |
39 |
Correct |
3 ms |
384 KB |
Output is correct |
40 |
Correct |
2 ms |
256 KB |
Output is correct |
41 |
Correct |
100 ms |
384 KB |
Output is correct |
42 |
Correct |
6 ms |
384 KB |
Output is correct |
43 |
Correct |
3 ms |
256 KB |
Output is correct |
44 |
Correct |
2 ms |
384 KB |
Output is correct |
45 |
Correct |
93 ms |
384 KB |
Output is correct |
46 |
Correct |
6 ms |
384 KB |
Output is correct |
47 |
Correct |
3 ms |
256 KB |
Output is correct |
48 |
Correct |
3 ms |
256 KB |
Output is correct |
49 |
Correct |
138 ms |
384 KB |
Output is correct |
50 |
Correct |
139 ms |
384 KB |
Output is correct |
51 |
Correct |
170 ms |
384 KB |
Output is correct |
52 |
Correct |
142 ms |
384 KB |
Output is correct |
53 |
Correct |
138 ms |
384 KB |
Output is correct |
54 |
Correct |
142 ms |
384 KB |
Output is correct |
55 |
Correct |
137 ms |
384 KB |
Output is correct |
56 |
Correct |
138 ms |
384 KB |
Output is correct |
57 |
Correct |
143 ms |
384 KB |
Output is correct |
58 |
Correct |
139 ms |
384 KB |
Output is correct |
59 |
Correct |
274 ms |
388 KB |
Output is correct |
60 |
Correct |
292 ms |
504 KB |
Output is correct |
61 |
Correct |
1 ms |
256 KB |
Output is correct |
62 |
Correct |
1 ms |
256 KB |
Output is correct |
63 |
Correct |
1 ms |
256 KB |
Output is correct |
64 |
Execution timed out |
7019 ms |
732 KB |
Time limit exceeded |
65 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
7058 ms |
788 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
183 ms |
384 KB |
Output is correct |
2 |
Correct |
13 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
256 KB |
Output is correct |
4 |
Correct |
3 ms |
256 KB |
Output is correct |
5 |
Correct |
208 ms |
384 KB |
Output is correct |
6 |
Correct |
18 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
256 KB |
Output is correct |
8 |
Correct |
11 ms |
384 KB |
Output is correct |
9 |
Correct |
326 ms |
384 KB |
Output is correct |
10 |
Correct |
165 ms |
388 KB |
Output is correct |
11 |
Correct |
133 ms |
404 KB |
Output is correct |
12 |
Correct |
150 ms |
508 KB |
Output is correct |
13 |
Correct |
407 ms |
516 KB |
Output is correct |
14 |
Correct |
426 ms |
392 KB |
Output is correct |
15 |
Correct |
433 ms |
388 KB |
Output is correct |
16 |
Correct |
418 ms |
388 KB |
Output is correct |
17 |
Correct |
216 ms |
384 KB |
Output is correct |
18 |
Correct |
15 ms |
384 KB |
Output is correct |
19 |
Correct |
3 ms |
384 KB |
Output is correct |
20 |
Correct |
3 ms |
256 KB |
Output is correct |
21 |
Correct |
186 ms |
392 KB |
Output is correct |
22 |
Correct |
16 ms |
384 KB |
Output is correct |
23 |
Correct |
5 ms |
384 KB |
Output is correct |
24 |
Correct |
4 ms |
256 KB |
Output is correct |
25 |
Correct |
281 ms |
384 KB |
Output is correct |
26 |
Correct |
160 ms |
384 KB |
Output is correct |
27 |
Correct |
130 ms |
384 KB |
Output is correct |
28 |
Correct |
134 ms |
384 KB |
Output is correct |
29 |
Correct |
404 ms |
384 KB |
Output is correct |
30 |
Correct |
429 ms |
384 KB |
Output is correct |
31 |
Correct |
393 ms |
360 KB |
Output is correct |
32 |
Correct |
434 ms |
404 KB |
Output is correct |
33 |
Correct |
3 ms |
256 KB |
Output is correct |
34 |
Correct |
3 ms |
256 KB |
Output is correct |
35 |
Correct |
3 ms |
256 KB |
Output is correct |
36 |
Correct |
2 ms |
256 KB |
Output is correct |
37 |
Correct |
5 ms |
384 KB |
Output is correct |
38 |
Correct |
4 ms |
384 KB |
Output is correct |
39 |
Correct |
3 ms |
384 KB |
Output is correct |
40 |
Correct |
2 ms |
256 KB |
Output is correct |
41 |
Correct |
100 ms |
384 KB |
Output is correct |
42 |
Correct |
6 ms |
384 KB |
Output is correct |
43 |
Correct |
3 ms |
256 KB |
Output is correct |
44 |
Correct |
2 ms |
384 KB |
Output is correct |
45 |
Correct |
93 ms |
384 KB |
Output is correct |
46 |
Correct |
6 ms |
384 KB |
Output is correct |
47 |
Correct |
3 ms |
256 KB |
Output is correct |
48 |
Correct |
3 ms |
256 KB |
Output is correct |
49 |
Correct |
138 ms |
384 KB |
Output is correct |
50 |
Correct |
139 ms |
384 KB |
Output is correct |
51 |
Correct |
170 ms |
384 KB |
Output is correct |
52 |
Correct |
142 ms |
384 KB |
Output is correct |
53 |
Correct |
138 ms |
384 KB |
Output is correct |
54 |
Correct |
142 ms |
384 KB |
Output is correct |
55 |
Correct |
137 ms |
384 KB |
Output is correct |
56 |
Correct |
138 ms |
384 KB |
Output is correct |
57 |
Correct |
143 ms |
384 KB |
Output is correct |
58 |
Correct |
139 ms |
384 KB |
Output is correct |
59 |
Correct |
274 ms |
388 KB |
Output is correct |
60 |
Correct |
292 ms |
504 KB |
Output is correct |
61 |
Correct |
1 ms |
256 KB |
Output is correct |
62 |
Correct |
1 ms |
256 KB |
Output is correct |
63 |
Correct |
1 ms |
256 KB |
Output is correct |
64 |
Execution timed out |
7019 ms |
732 KB |
Time limit exceeded |
65 |
Halted |
0 ms |
0 KB |
- |