# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
282142 | arnold518 | Interval Collection (CCO20_day2problem2) | C++14 | 7037 ms | 840 KiB |
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;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int Q;
multiset<pii> S;
int main()
{
scanf("%d", &Q);
for(int i=1; i<=Q; i++)
{
int l, r;
char c;
scanf(" %c%d%d", &c, &l, &r);
if(c=='A') S.insert({l, r});
else S.erase(S.find({l, r}));
int p=1e9, q=1e9;
for(auto it : S)
{
for(auto jt : S)
{
int l1=max(it.first, jt.first), r1=min(it.second, jt.second);
int l2=min(it.first, jt.first), r2=max(it.second, jt.second);
if(p>max(r1-l1, 0)) p=max(r1-l1, 0), q=r2-l2;
else if(p==max(r1-l1, 0) && q>r2-l2) q=r2-l2;
}
}
printf("%d\n", q);
}
}
Compilation message (stderr)
# | 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... |