Submission #631870

# Submission time Handle Problem Language Result Execution time Memory
631870 2022-08-19T03:43:15 Z jhnah917 Interval Collection (CCO20_day2problem2) C++14
4 / 25
541 ms 48332 KB
#include <bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    set<pair<int,int>> S;
    multiset<int> R;
    for(int i=1; i<=N; i++){
        char op; int s, e; cin >> op >> s >> e;
        if(op == 'A'){
            auto it = S.emplace(s, e).first;
            if(it != S.begin() && next(it) != S.end()){
                R.erase(R.find(next(it)->second - prev(it)->first));
            }
            if(it != S.begin()) R.insert(e - prev(it)->first);
            if(next(it) != S.end()) R.insert(next(it)->second - s);
        }
        else{
            auto it = S.erase(S.find(make_pair(s, e)));
            if(it != S.end()) R.erase(R.find(it->second - s));
            if(it != S.begin()) R.erase(R.find(e - prev(it)->first));
            if(it != S.begin() && it != S.end()) R.insert(it->second - prev(it)->first);
        }
        if(R.empty()) cout << S.begin()->second - S.begin()->first << "\n";
        else cout << *R.begin() << "\n";
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 464 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 464 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 464 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 161 ms 19540 KB Output is correct
2 Correct 130 ms 19596 KB Output is correct
3 Correct 321 ms 38652 KB Output is correct
4 Correct 268 ms 38748 KB Output is correct
5 Correct 421 ms 48272 KB Output is correct
6 Correct 334 ms 48332 KB Output is correct
7 Correct 494 ms 9452 KB Output is correct
8 Correct 375 ms 7752 KB Output is correct
9 Correct 348 ms 7340 KB Output is correct
10 Correct 516 ms 11060 KB Output is correct
11 Correct 369 ms 7628 KB Output is correct
12 Correct 344 ms 7360 KB Output is correct
13 Correct 541 ms 11960 KB Output is correct
14 Correct 378 ms 7648 KB Output is correct
15 Correct 349 ms 7468 KB Output is correct
16 Correct 249 ms 8708 KB Output is correct
17 Correct 249 ms 8740 KB Output is correct
18 Correct 251 ms 8552 KB Output is correct
19 Correct 249 ms 8580 KB Output is correct
20 Correct 254 ms 8588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 464 KB Output isn't correct
2 Halted 0 ms 0 KB -