Submission #309035

#TimeUsernameProblemLanguageResultExecution timeMemory
309035nikatamlianiInterval Collection (CCO20_day2problem2)C++14
3 / 25
7058 ms788 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 xp0 : m) { for(auto xp1 : m) { auto p0 = xp0, p1 = xp1; 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...