HDOJ 4122 Alice's mooncake shop(二)

2014-11-24 09:25:42 · 作者: · 浏览: 7
d M = 0.
Output You should output one line for each test case: the minimum cost.

Sample Input
1 10
Jan 1 2000 9 10
5 2
20 
20 
20 
10 
10
8
7 
9 
5 
10
0 0

Sample Output
70
Hint
“Jan 1 2000 9 10” means in Jan 1st 2000 at 9 o'clock , there's a consumer ordering 10 mooncakes. 
Maybe you should use 64-bit signed integers. The answer will fit into a 64-bit signed integer.
 

Source 2011 Asia Fuzhou Regional Contest

#include 
   
    
#include 
    
      #include 
     
       #include 
      
        #include 
       
         #include 
        
          using namespace std; int N,M,S,T,cost,pos; long long int ANS; int day[2][13]={{0,31,59,90,120,151,181,212,243,273,304,334,365},{0,31,60,91,121,152,182,213,244,274,305,335,366}}; char month[13][5]={"xxx","Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov" , "Dec"}; int isrun(int x) { if(x==2000||x==2004||x==2008||x==2012||x==2016) return 1; else return 0; } struct ORDER { int nb,ti; }Or[3000]; struct Unitprice { int t,p; }; int getTime(char* m,int d,int y,int h) { int ret=0; for(int i=1;i<=12;i++) if(strcmp(m,month[i])==0) ret+=day[isrun(y)][i-1]; for(int i=2000;i
         
           dq; pos=0;ANS=0; for(int i=0;i
          
           =cost) dq.pop_back(); else break; } dq.push_back((Unitprice){i,cost}); while(!dq.empty()) { if((i-dq.front().t)>T) dq.pop_front(); else break; } while(pos