# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
986567 | activedeltorre | Interval Collection (CCO20_day2problem2) | C++14 | 7021 ms | 596 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 <iostream>
#include <vector>
using namespace std;
struct ura
{
int a,b;
};
vector<ura>vec;
int inter(int i,int j)
{
return max(0,min(vec[i].b,vec[j].b)-max(vec[i].a,vec[j].a));
}
int reun(int i,int j)
{
return max(vec[i].b,vec[j].b)-min(vec[i].a,vec[j].a);
}
int main()
{
int n,i,j,k,l,r,z;
cin>>n;
char tip;
for(i=1;i<=n;i++)
{
cin>>tip;
if(tip=='A')
{
cin>>l>>r;
vec.push_back({l,r});
}
else if(tip=='R')
{
cin>>l>>r;
for(j=0;j<vec.size();j++)
{
if(vec[j].a==l && vec[j].b==r)
{
vec.erase(vec.begin()+j);
break;
}
}
}
int minim=1e9,sol;
for(j=0;j<vec.size();j++)
{
for(z=j;z<vec.size();z++)
{
if(inter(z,j)<=minim)
{
minim=inter(z,j);
sol=reun(z,j);
}
}
}
cout<<sol<<'\n';
}
return 0;
}
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... |