Submission #891578

# Submission time Handle Problem Language Result Execution time Memory
891578 2023-12-23T08:59:51 Z 1075508020060209tc Interval Collection (CCO20_day2problem2) C++14
3 / 25
7000 ms 1584 KB
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define int long long
int Q;
multiset<pair<int,int>>mst;
int n;
pair<int,int>ar[500005];
pair<int,int>interset(pair<int,int>a,pair<int,int>b){
pair<int,int>pr;
pr.first=max(a.first,b.first);
pr.second=min(a.second,b.second);
return pr;
}
bool cmp(pair<int,int>i,pair<int,int>j){
if(i.second<j.second){return 1;}
return 0;
}
int slv(int st,int d){
pair<int,int>pr={1,1e9};

for(int i=1;i<=n;i++){
    if(ar[i].first<st){continue;}
    pr=interset(pr,ar[i]);
    if(max(pr.second-pr.first,0ll)<=d){
        return ar[i].second-st;
    }
}
return 1e18;
}


void solve(){
n=0;
pair<int,int>pr={1,1e9};
for(auto it=mst.begin();it!=mst.end();it++){
    ar[++n]=(*it);
    pr=interset(pr,ar[n]);
}
int ans=1e18;
sort(ar+1,ar+n+1,cmp);
int d=max(pr.second-pr.first,0ll);
for(int i=1;i<=n;i++){
        ans=min(slv(ar[i].first,d),ans);
}
cout<<ans<<"\n";
}



signed main(){

cin>>Q;
while(Q--){
    char typ;
    cin>>typ;
    int l;int r;
    cin>>l>>r;
    if(typ=='A'){
        mst.insert({l,r});
    }else{
        mst.erase(mst.find({l,r}));
    }
    solve();
}



}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 756 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 8 ms 348 KB Output is correct
6 Correct 3 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 2 ms 344 KB Output is correct
9 Correct 10 ms 348 KB Output is correct
10 Correct 8 ms 348 KB Output is correct
11 Correct 6 ms 344 KB Output is correct
12 Correct 6 ms 448 KB Output is correct
13 Correct 12 ms 348 KB Output is correct
14 Correct 11 ms 344 KB Output is correct
15 Correct 14 ms 348 KB Output is correct
16 Correct 11 ms 472 KB Output is correct
17 Correct 8 ms 348 KB Output is correct
18 Correct 2 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 8 ms 348 KB Output is correct
22 Correct 3 ms 348 KB Output is correct
23 Correct 2 ms 444 KB Output is correct
24 Correct 2 ms 348 KB Output is correct
25 Correct 12 ms 348 KB Output is correct
26 Correct 7 ms 348 KB Output is correct
27 Correct 6 ms 348 KB Output is correct
28 Correct 6 ms 348 KB Output is correct
29 Correct 11 ms 440 KB Output is correct
30 Correct 11 ms 348 KB Output is correct
31 Correct 11 ms 480 KB Output is correct
32 Correct 12 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 356 KB Output is correct
36 Correct 1 ms 356 KB Output is correct
37 Correct 2 ms 356 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 1 ms 352 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 6 ms 348 KB Output is correct
42 Correct 2 ms 444 KB Output is correct
43 Correct 1 ms 444 KB Output is correct
44 Correct 1 ms 452 KB Output is correct
45 Correct 6 ms 500 KB Output is correct
46 Correct 2 ms 348 KB Output is correct
47 Correct 1 ms 348 KB Output is correct
48 Correct 1 ms 348 KB Output is correct
49 Correct 22 ms 348 KB Output is correct
50 Correct 22 ms 348 KB Output is correct
51 Correct 22 ms 348 KB Output is correct
52 Correct 22 ms 348 KB Output is correct
53 Correct 22 ms 348 KB Output is correct
54 Correct 22 ms 348 KB Output is correct
55 Correct 25 ms 604 KB Output is correct
56 Correct 25 ms 344 KB Output is correct
57 Correct 22 ms 344 KB Output is correct
58 Correct 22 ms 348 KB Output is correct
59 Correct 16 ms 344 KB Output is correct
60 Correct 17 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 756 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 8 ms 348 KB Output is correct
6 Correct 3 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 2 ms 344 KB Output is correct
9 Correct 10 ms 348 KB Output is correct
10 Correct 8 ms 348 KB Output is correct
11 Correct 6 ms 344 KB Output is correct
12 Correct 6 ms 448 KB Output is correct
13 Correct 12 ms 348 KB Output is correct
14 Correct 11 ms 344 KB Output is correct
15 Correct 14 ms 348 KB Output is correct
16 Correct 11 ms 472 KB Output is correct
17 Correct 8 ms 348 KB Output is correct
18 Correct 2 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 8 ms 348 KB Output is correct
22 Correct 3 ms 348 KB Output is correct
23 Correct 2 ms 444 KB Output is correct
24 Correct 2 ms 348 KB Output is correct
25 Correct 12 ms 348 KB Output is correct
26 Correct 7 ms 348 KB Output is correct
27 Correct 6 ms 348 KB Output is correct
28 Correct 6 ms 348 KB Output is correct
29 Correct 11 ms 440 KB Output is correct
30 Correct 11 ms 348 KB Output is correct
31 Correct 11 ms 480 KB Output is correct
32 Correct 12 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 356 KB Output is correct
36 Correct 1 ms 356 KB Output is correct
37 Correct 2 ms 356 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 1 ms 352 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 6 ms 348 KB Output is correct
42 Correct 2 ms 444 KB Output is correct
43 Correct 1 ms 444 KB Output is correct
44 Correct 1 ms 452 KB Output is correct
45 Correct 6 ms 500 KB Output is correct
46 Correct 2 ms 348 KB Output is correct
47 Correct 1 ms 348 KB Output is correct
48 Correct 1 ms 348 KB Output is correct
49 Correct 22 ms 348 KB Output is correct
50 Correct 22 ms 348 KB Output is correct
51 Correct 22 ms 348 KB Output is correct
52 Correct 22 ms 348 KB Output is correct
53 Correct 22 ms 348 KB Output is correct
54 Correct 22 ms 348 KB Output is correct
55 Correct 25 ms 604 KB Output is correct
56 Correct 25 ms 344 KB Output is correct
57 Correct 22 ms 344 KB Output is correct
58 Correct 22 ms 348 KB Output is correct
59 Correct 16 ms 344 KB Output is correct
60 Correct 17 ms 348 KB Output is correct
61 Correct 0 ms 348 KB Output is correct
62 Correct 0 ms 360 KB Output is correct
63 Correct 0 ms 348 KB Output is correct
64 Execution timed out 7066 ms 1584 KB Time limit exceeded
65 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 756 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 8 ms 348 KB Output is correct
6 Correct 3 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 2 ms 344 KB Output is correct
9 Correct 10 ms 348 KB Output is correct
10 Correct 8 ms 348 KB Output is correct
11 Correct 6 ms 344 KB Output is correct
12 Correct 6 ms 448 KB Output is correct
13 Correct 12 ms 348 KB Output is correct
14 Correct 11 ms 344 KB Output is correct
15 Correct 14 ms 348 KB Output is correct
16 Correct 11 ms 472 KB Output is correct
17 Correct 8 ms 348 KB Output is correct
18 Correct 2 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 8 ms 348 KB Output is correct
22 Correct 3 ms 348 KB Output is correct
23 Correct 2 ms 444 KB Output is correct
24 Correct 2 ms 348 KB Output is correct
25 Correct 12 ms 348 KB Output is correct
26 Correct 7 ms 348 KB Output is correct
27 Correct 6 ms 348 KB Output is correct
28 Correct 6 ms 348 KB Output is correct
29 Correct 11 ms 440 KB Output is correct
30 Correct 11 ms 348 KB Output is correct
31 Correct 11 ms 480 KB Output is correct
32 Correct 12 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 356 KB Output is correct
36 Correct 1 ms 356 KB Output is correct
37 Correct 2 ms 356 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 1 ms 352 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 6 ms 348 KB Output is correct
42 Correct 2 ms 444 KB Output is correct
43 Correct 1 ms 444 KB Output is correct
44 Correct 1 ms 452 KB Output is correct
45 Correct 6 ms 500 KB Output is correct
46 Correct 2 ms 348 KB Output is correct
47 Correct 1 ms 348 KB Output is correct
48 Correct 1 ms 348 KB Output is correct
49 Correct 22 ms 348 KB Output is correct
50 Correct 22 ms 348 KB Output is correct
51 Correct 22 ms 348 KB Output is correct
52 Correct 22 ms 348 KB Output is correct
53 Correct 22 ms 348 KB Output is correct
54 Correct 22 ms 348 KB Output is correct
55 Correct 25 ms 604 KB Output is correct
56 Correct 25 ms 344 KB Output is correct
57 Correct 22 ms 344 KB Output is correct
58 Correct 22 ms 348 KB Output is correct
59 Correct 16 ms 344 KB Output is correct
60 Correct 17 ms 348 KB Output is correct
61 Correct 0 ms 348 KB Output is correct
62 Correct 0 ms 360 KB Output is correct
63 Correct 0 ms 348 KB Output is correct
64 Execution timed out 7066 ms 1584 KB Time limit exceeded
65 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 7026 ms 976 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 756 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 8 ms 348 KB Output is correct
6 Correct 3 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 2 ms 344 KB Output is correct
9 Correct 10 ms 348 KB Output is correct
10 Correct 8 ms 348 KB Output is correct
11 Correct 6 ms 344 KB Output is correct
12 Correct 6 ms 448 KB Output is correct
13 Correct 12 ms 348 KB Output is correct
14 Correct 11 ms 344 KB Output is correct
15 Correct 14 ms 348 KB Output is correct
16 Correct 11 ms 472 KB Output is correct
17 Correct 8 ms 348 KB Output is correct
18 Correct 2 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 8 ms 348 KB Output is correct
22 Correct 3 ms 348 KB Output is correct
23 Correct 2 ms 444 KB Output is correct
24 Correct 2 ms 348 KB Output is correct
25 Correct 12 ms 348 KB Output is correct
26 Correct 7 ms 348 KB Output is correct
27 Correct 6 ms 348 KB Output is correct
28 Correct 6 ms 348 KB Output is correct
29 Correct 11 ms 440 KB Output is correct
30 Correct 11 ms 348 KB Output is correct
31 Correct 11 ms 480 KB Output is correct
32 Correct 12 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 356 KB Output is correct
36 Correct 1 ms 356 KB Output is correct
37 Correct 2 ms 356 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 1 ms 352 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 6 ms 348 KB Output is correct
42 Correct 2 ms 444 KB Output is correct
43 Correct 1 ms 444 KB Output is correct
44 Correct 1 ms 452 KB Output is correct
45 Correct 6 ms 500 KB Output is correct
46 Correct 2 ms 348 KB Output is correct
47 Correct 1 ms 348 KB Output is correct
48 Correct 1 ms 348 KB Output is correct
49 Correct 22 ms 348 KB Output is correct
50 Correct 22 ms 348 KB Output is correct
51 Correct 22 ms 348 KB Output is correct
52 Correct 22 ms 348 KB Output is correct
53 Correct 22 ms 348 KB Output is correct
54 Correct 22 ms 348 KB Output is correct
55 Correct 25 ms 604 KB Output is correct
56 Correct 25 ms 344 KB Output is correct
57 Correct 22 ms 344 KB Output is correct
58 Correct 22 ms 348 KB Output is correct
59 Correct 16 ms 344 KB Output is correct
60 Correct 17 ms 348 KB Output is correct
61 Correct 0 ms 348 KB Output is correct
62 Correct 0 ms 360 KB Output is correct
63 Correct 0 ms 348 KB Output is correct
64 Execution timed out 7066 ms 1584 KB Time limit exceeded
65 Halted 0 ms 0 KB -