标签:代码 min char s wait cst search miss suitable out
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 2960 | Accepted: 929 |
Description
Input
Output
Sample Input
1 1 1 10:40 1 10:50 2 11:00 4 # 1 1 1 10:40 1 10:50 2 11:00 2 # 1 2 1 10:30 1 10:40 3 10:50 2 11:00 1 11:20 5 # 0 0 0
Sample Output
7 3 12
Source
#include<iostream> #include<cstring> #include<cstdio> #include<queue> #include<algorithm> using namespace std; inline int read(){ int x=0,f=1;char c=getchar(); for(;!isdigit(c);c=getchar()) if(c==‘-‘) f=-1; for(;isdigit(c);c=getchar()) x=x*10+c-‘0‘; return x*f; } int A,B,C; int le1[101],le2[101],le3[101]; int HH,MM,P; int k[4]; char s[7]; int main(){ k[1]=read(),k[2]=read(),k[3]=read(); while(k[1]!=0||k[2]!=0||k[3]!=0){ int res=0; memset(le1,0,sizeof(le1)); memset(le2,0,sizeof(le2)); memset(le3,0,sizeof(le3)); while(1){ cin>>s; if(s[0]==‘#‘) break; HH=0; int tmp=1,e=1; for(tmp=0;s[tmp]!=‘:‘;tmp++) ; for(int i=tmp-1;i>=0;i--) HH+=((s[i]-‘0‘)*e),e*=10; MM=0,e=1; for(int i=strlen(s)-1;i>tmp;i--) MM+=((s[i]-‘0‘)*e),e*=10; int T=(HH-7)*60+MM; //cout<<T<<endl; P=read(); P++; if(P/2==1&&k[1]){ P--; sort(le1,le1+k[1]); if(le1[0]-T<=30){ // cout<<"true"<<endl; res+=P; if(le1[0]>=T) le1[0]+=30; else le1[0]=T+30; } } else if(P/2==2&&k[2]){ P--; sort(le2,le2+k[2]); if(le2[0]-T<=30){ //cout<<"true2"<<endl; res+=P; if(le2[0]>=T) le2[0]+=30; else le2[0]=T+30; } } else if(P/2==3&&k[3]){ P--; sort(le3,le3+k[3]); if(le3[0]-T<=30){ //cout<<"true3"<<endl; res+=P; if(le3[0]>=T) le3[0]+=30; else le3[0]=T+30; } } } printf("%d\n",res); k[1]=read(),k[2]=read(),k[3]=read(); } } /* 1 3 2 09:45 3 09:46 5 09:59 4 10:00 1 10:01 3 10:20 3 10:30 2 11:20 5 11:40 1 12:00 3 12:10 2 14:20 5 15:00 3 15:20 6 15:40 5 17:30 2 19:00 6 19:40 4 20:03 4 20:05 4 21:40 2 21:44 1 22:00 1 # */
标签:代码 min char s wait cst search miss suitable out
原文地址:http://www.cnblogs.com/wxjor/p/7044824.html