Submission #282142

#TimeUsernameProblemLanguageResultExecution timeMemory
282142arnold518Interval Collection (CCO20_day2problem2)C++14
3 / 25
7037 ms840 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; int Q; multiset<pii> S; int main() { scanf("%d", &Q); for(int i=1; i<=Q; i++) { int l, r; char c; scanf(" %c%d%d", &c, &l, &r); if(c=='A') S.insert({l, r}); else S.erase(S.find({l, r})); int p=1e9, q=1e9; for(auto it : S) { for(auto jt : S) { int l1=max(it.first, jt.first), r1=min(it.second, jt.second); int l2=min(it.first, jt.first), r2=max(it.second, jt.second); if(p>max(r1-l1, 0)) p=max(r1-l1, 0), q=r2-l2; else if(p==max(r1-l1, 0) && q>r2-l2) q=r2-l2; } } printf("%d\n", q); } }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   13 |  scanf("%d", &Q);
      |  ~~~~~^~~~~~~~~~
Main.cpp:19:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   19 |   scanf(" %c%d%d", &c, &l, &r);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#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...