Home > Back-end >  1026 Table "Tennis" (30 points) the last test points, not have considered roundup
1026 Table "Tennis" (30 points) the last test points, not have considered roundup

Time:09-27

As title, own the Debug for a long time did not find where is wrong, can only resort to the prawns are taught! first solve leaving WeChat or pay treasure payment code, just say!



 
#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;
Vector Nodes (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);
Vector Table_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 list

CodePudding user response:

reference 1st floor greex response:
vertor list instead tried?
haven't tried the list, it will have a relationship

CodePudding user response:

Do you solved? I also am the last one had not, have a day or two

CodePudding user response:

You have now?
If current is VIP table, visited the VIP in the queue cannot be visited, so it is ok to add a judgment

CodePudding user response:

reference 3/f, 79 c0 response:
do you solved? I also am the last one had not, for one or two days the

You see my reply

CodePudding user response:

 
#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;
Vector Nodes (N);
For (int I=0; i
  • Related