#include #include using namespace std; int main() { int n; map points; cin >> n; for (int i = 0; i < n; i++) { int l, r; cin >> l >> r; points[l] += 1; points[r] -= 1; } int max = 0, current = 0; for (const auto& time_delta : points) { current += time_delta.second; if (current > max) { max = current; } } cout << max; return 0; }
#include #include using namespace std; int main() { int n; map points; cin >> n; for (int i = 0; i < n; i++) { int l, r; cin >> l >> r; points[l] += 1; points[r + 1] -= 1; } int max = 0, current = 0; for (const auto& time_delta : points) { current += time_delta.second; if (current > max) { max = current; } } cout << max; return 0; }
#include #include using namespace std;int main(){ uint32_t N, view_salut_count{}, view_max_count{}; map seq; //точки входа и выхода зрителей cin >> N; while (N--) { uint32_t start, stop; cin >> start >> stop; seq[start]++; //начало диапазаона : точка дает +1 зритель seq[stop]--; //конец диапазона : точка дает -1 зритель } for (auto& point : seq) //идем по всем точкам { view_salut_count += point.second; //в каждой точке количество зрителей уменьшается или увеличивается if (view_max_count < view_salut_count) view_max_count = view_salut_count; //нахождение масксимума } cout << "Salute was viewed " << view_max_count << " persons";}