Hdu4883tiankeng's Restaurant

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.