#include
#include
#include
#include
using namespace std;
Struct node {
Int Arrive_Time, Start_Time, Play_Time, Tag, HasServered;
Boolean operator & lt; (const node& N) {
Return Arrive_Time & lt; N.a. rrive_Time;
}
};
Bool CMP (const node& N1, const node& N2) {
Return n1. Start_Time & lt; N2 Start_Time;
}
{int round (int arrive, int start)
Int wait=start to arrive;
Int min=wait/60;
If (wait % 60 & gt;=30) + + min;
Return min;
}
Int main () {
Int N, h, m, s, K, m, index, open_Time=8 * 3600, close_Time=* 3600, 21 max_PlayTime=2 * 3600;
Cin & gt;> N;
VectorNodes (N);
for(int i=0; iThe scanf (" % d: % d: % d ", & amp; H, & amp; M, & amp; S);
Nodes [I] HasServered=0;
Nodes [I] Arrive_Time=3600 + m h * * 60 + s;
The scanf (" % d % d ", & amp; Nodes [I]. Play_Time, & amp; Nodes [I] Tag);
Nodes [I] Play_Time *=60;
If (nodes [I] Play_Time & gt; Max_PlayTime)
Nodes [I] Play_Time=max_PlayTime;
}
Sort (nodes. The begin (), the nodes. The end ());
The scanf (" % d % d ", & amp; K, & amp; M);
VectorTable_ServerPair Table_EmptyTime (K + 1), (K + 1, 0), isVIP_Table (K + 1, false);
for(int i=0; iThe scanf (" % d ", & amp; The index);
IsVIP_Table [index]=true;
}
for(int i=0; i<=K; + + I)
Table_EmptyTime [I]=open_Time;
For (int I=0, j; iIf (nodes [I] HasServered==1)
continue;
Int nextEmptyTable_Index=1, nextServeredPair_Index=I;
For (int k=2; K<=K; + + k) {
If (Table_EmptyTime [k]NextEmptyTable_Index=k;
}
If (isVIP_Table [nextEmptyTable_Index]) {//if the current vacant is VIP desk
For (j=I; JIf (nodes [j] Tag==1) {
I=I - 1;
NextServeredPair_Index=j;
break;
}
}
}
Else if (nodes [nextServeredPair_Index] Tag==1) {//if the member is a VIP, priority arranged for him to use the VIP table
For (j=1; J<=K; + + j) {
If (isVIP_Table [j] & amp; & Table_EmptyTime [j] <=nodes [nextServeredPair_Index] Arrive_Time) {
NextEmptyTable_Index=j;
break;
}
}
}
Nodes [nextServeredPair_Index] Start_Time=Max (Table_EmptyTime [nextEmptyTable_Index], nodes [nextServeredPair_Index] Arrive_Time);
If (nodes) [r]. NextServeredPair_Index Start_Time & lt; Close_Time)
+ + Table_ServerPair [nextEmptyTable_Index];
Nodes [nextServeredPair_Index] HasServered=1;
Table_EmptyTime [nextEmptyTable_Index]=nodes [nextServeredPair_Index] Start_Time + nodes [nextServeredPair_Index] Play_Time;
}
Sort (nodes. The begin (), the nodes. The end (), CMP);
for(int i=0; i02 02 printf (" % d: % d: % 2 d ", nodes [I] Arrive_Time/3600, nodes [I] Arrive_Time % 3600/60, nodes [I] Arrive_Time % 3600% 60);
02 02 printf (" % d: % d: % 2 d ", nodes [I] Start_Time/3600, nodes [I] Start_Time % 3600/60, nodes [I] Start_Time % 3600% 60);
//printf (" % d \ n ", round ((nodes [I] Start_Time - nodes [I] Arrive_Time)/60.0));
Printf (" % d \ n ", round (nodes [I] Arrive_Time, nodes [I] Start_Time));
}
for(int i=1; i<=K; + + I)
Printf (" % d % c, "Table_ServerPair [I], I==K? '\ n' : ');
return 0;
}
CodePudding user response:
Vertor tried to listCodePudding user response: