Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save jonathanagustin/ddc0961cf30091730823493a53baccb7 to your computer and use it in GitHub Desktop.

Select an option

Save jonathanagustin/ddc0961cf30091730823493a53baccb7 to your computer and use it in GitHub Desktop.
maximum occurred integer in n ranges
int main() {
int Q; cin >> Q;
map<long long, int> points;
for (int i = 0; i < Q; i++) {
long long l, r; cin >> l >> r;
points[l]++;
points[r + 1]--;
}
int best = 0, cur = 0;
for (pair<long long, int> x: points) {
cur += x.second;
best = max(best, cur);
}
cout << best << '\n';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment