Submission #308988

#TimeUsernameProblemLanguageResultExecution timeMemory
308988nikatamlianiInterval Collection (CCO20_day2problem2)C++14
0 / 25
7032 ms816 KiB
#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 p0 : m) { for(auto p1 : m) { 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...