HDU 4883 (BC #2 1001) tiankeng's restaurant (water)

Source: Internet
Author: User

Address: HDU 4883

Alas .. A kind of inertia has been developed recently .. When I first learned something like this, I wanted to use the algorithm I just learned... It turns out that this question is so simple .. At that time, I really thought too much ....

You only need to set a value on the point to be changed, whether to increase or decrease. Then, when the traversal is over, add or subtract this value...

The Code is as follows:

# Include <iostream> # include <stdio. h> # include <string. h> # include <stdlib. h> # include <math. h> # include <ctype. h >#include <queue >#include <map> # include <algorithm> using namespace STD; int A [11000], DP [11000]; int main () {int t, n, I, A1, B1, A2, B2, L, R, X, min1; scanf ("% d", & T); While (t --) {memset (A, 0, sizeof (a); memset (DP, 0, sizeof (DP); X = 0; min1 =-1; scanf ("% d", & N); for (I = 0; I <n; I ++) {scanf ("% d: % d ", & X, & A1, & B1, & A2, & B2); L = A1 * 60 + b1; r = a2 * 60 + B2; A [l] + = x; A [R]-= x;} X = A [0]; DP [0] = x; for (I = 1; I <= 1440; I ++) {DP [I] = DP [I-1] + A [I];} for (I = 0; I <= 1440; I ++) {If (min1 <DP [I]) min1 = DP [I];} printf ("% d \ n", min1);} return 0 ;}


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.