Title: hdu4883tiankeng's Restaurant
A restaurant provides you with the number of guests in each group, the arrival time, the departure time, and the minimum number of chairs required.
Solution: This question was originally intended to be covered by intervals, but it was not quite correct later. This seems to be a good option because it takes only 1440 of the time. one method is to mark the start time and end time of each interval as "people" or "people", and subtract the number of chairs. Then, during the enumeration time, maintain the maximum chair value during this process. You can also record the inbound and outbound time points, because the number of people at these time points is changing, and the maximum maintenance value is maintained, but remember not to add the repeated time points multiple times.
Code:
# Include <cstdio> # include <cstring> # include <algorithm> using namespace STD; const int n = 2005; int C [N]; int main () {int T; int num, H, M; int ans, N; scanf ("% d", & T); While (t --) {scanf ("% d", & N ); memset (C, 0, sizeof (c); For (INT I = 0; I <n; I ++) {scanf ("% d", & num ); scanf ("% d: % d", & H, & M); C [H * 60 + M] + = num; scanf ("% d: % d ", & H, & M); C [H * 60 + M]-= num;} int ans = 0; int TMP = 0; For (INT I = 0; I <n; I ++) {TMP + = C [I]; If (TMP> ans) ans = TMP;} printf ("% d \ n ", ans);} return 0 ;}
Hdu4883tiankeng's Restaurant