Test instructions
I'll give you the K-pieces, tell you the number of folding machines for washer dryers, and the time they handle a garment, requiring a garment to be dried immediately after washing and must be folded immediately after drying to ask for the minimum time required.
Ideas:
1. By Time Simulation
2. If washed clothes or dry clothes more than the next step, then from the beginning to postpone the washing time, greedy thought is also reflected here.
3. The key lies in how to deal with the drying of clothes, because the need to adjust the starting time of washing clothes, in fact, as long as the time to dry clothes to postpone processing can be, because even without adjusting the starting time of washing clothes, then the next time to dry clothes because the number of drying clothes is still occupied, So the starting time of washing clothes can be delayed sequentially.
4. Initially worried about the complexity of the problem, but after the delivery of the discovery time is not much ... This question is still in the thinking ...
#include<bits/stdc++.h>UsingNamespace Std;struct St{LongLong timeNum;int ID;St(LongLong A,LongLong b,int C){Time=a; ID=c; num=b;}};booloperator<(ConstSt &a,ConstSt &b){If(A. Time!=b. Time)Return a. Time<b. Time;Return a. ID>b. ID;}multiset<st>a;IntMain(){int k, N1, N2, N3, T1, T2, T3;scanf("%d%d%d%d%d%d%d", &k, &n1, &n2, &n3, &T1, &t2, &T3);LongLong A1, A2; A1=a2=0; A.Insert(St(T1, N1,1));While(k>0){StTmp=*a.Begin(); A.Erase(A.Begin());printf ("%d%lld%lld\n", tmp.id,tmp.time,tmp.num);If(TMP. ID==1){If(N2){A.Insert(St(TMP. Time+t2,Min((LongLong) N2Tmp. num),2)); A.Insert(St(TMP. Time+t1,Min((LongLong) N2Tmp. num),1));}If(TMP. num>n2){A.Insert(St(TMP. Time+1Tmp. num-n2,1));} n2-=Min((LongLong) N2Tmp. num);}ElseIf(TMP. ID==2){If(N3){A.Insert(St(TMP. Time+t3,Min((LongLong) N3Tmp. num),3));}If(TMP. num>n3){A.Insert(St(TMP. Time+1Tmp. num-n3,2));} n2+=Min((LongLong) N3Tmp. num); N3-=Min((LongLong) N3Tmp. num);}Else{k-=tmp. Num; N3+=tmp. Num; if(k<=0){printf("%i64d\ n", tmp. Time); return 0;} } }}< /c10>
Codeforces 452D [simulation] [greedy]