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 ;}