Files
exercises/_others/others_test_cpp.cpp
T
2026-10-16 10:21:53 +08:00

49 lines
1.1 KiB
C++

#include <algorithm>
#include <array>
#include <iostream>
#include <vector>
constexpr int MAX_N = 1001, MAX_T = 1001;
struct Attendee {
int enter_time = 0, exit_time = 0;
};
int get_max_attendees_amount(std::vector<Attendee> attendees_schedule) {
std::array<int, MAX_T> bucket{};
for (const auto [enter_time, exit_time] : attendees_schedule) {
for (int t = enter_time; t < exit_time; t++) {
bucket[t]++;
}
}
return *std::max_element(bucket.begin(), bucket.end());
}
int main() {
std::iostream::sync_with_stdio(false);
std::cin.tie(nullptr);
std::vector<Attendee> attendees;
char temp_comma;
int x;
while (true) {
std::cin >> x >> temp_comma;
attendees.push_back({x, -1});
if (temp_comma != ',') {
std::cin.unget();
break;
}
}
for (int i = 0; i < attendees.size() - 1; i++) {
std::cin >> attendees[i].exit_time >> temp_comma;
}
std::cin >> attendees[attendees.size() - 1].exit_time;
std::cout << attendees.size() << ' ' << get_max_attendees_amount(attendees) << std::endl;
return 0;
}