Problem Description
Problem Analysis
The first thing that comes to mind is that greedy “first to open, last to close” problem
Then on closer thought, they’re not exactly the same
And I finally figured out why that NYOJ provincial contest problem was wrong
Simulation is enough here
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
| #include<stdio.h>
int main() {
int T;
scanf("%d",&T);
while(T--) {
int n;
scanf("%d",&n);
int cnt[1500];
for(int i=0; i<1500; i++)
cnt[i]=0;
int x;
int sh,sm;
int eh,em;
for(int i=0; i<n; i++) {
scanf("%d %d:%d %d:%d",&x,&sh,&sm,&eh,&em);
sh=sh*60+sm;
eh=eh*60+em;
for(int j=sh; j<eh; j++) {
cnt[j]+=x;
}
}
int max=0;
for(int i=0; i<1500; i++)
if(cnt[i]>max)
max=cnt[i];
printf("%d\n",max);
}
return 0;
}
//与不AC贪心并不完全相同
|
Problem link: [HDU] [4883] TIANKENG’s restaurant