Created
June 5, 2020 16:02
-
-
Save jonathanagustin/ddc0961cf30091730823493a53baccb7 to your computer and use it in GitHub Desktop.
maximum occurred integer in n ranges
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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