建立数组遍历求最大值即可
#include<bits/stdc++.h> using namespace std; int t[2020]; int main() { int T,n,a; char s1[10],s2[10]; scanf("%d",&T); for(int kase=1;kase<=T;kase++) { memset(t,0,sizeof(t)); scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%d%s%s",&a,s1,s2); int st=((s1[0]-'0')*10+s1[1]-'0')*60+(s1[3]-'0')*10+s1[4]-'0'; int ed=((s2[0]-'0')*10+s2[1]-'0')*60+(s2[3]-'0')*10+s2[4]-'0'; for(int j=st+1;j<=ed;j++) t[j]+=a; } int k=max_element(t+1,t+1501)-t; printf("%d\n",t[k]); } return 0; }
HDU 4883 TIANKENG’s restaurant,布布扣,bubuko.com
HDU 4883 TIANKENG’s restaurant
原文:http://blog.csdn.net/nenuxlp/article/details/38379399