Home > Back-end >  CCF xiaoming, school leaders help see where there is a problem
CCF xiaoming, school leaders help see where there is a problem

Time:10-04

Submit scores only 60, and 40% of the test cases pass, really don't know where there is a problem, to a bosses to see which test cases appear problem, or see the following post title and code,

#include
#include
#include
#include
# define N (int) 1 e5 + 5

Int r, y, g;
Int judge (int a, b int, int) c;
Int judge (int a, b int, int) c///a is a traffic light label and no traffic light s [] [0]
{//s/b is time [] [1]
int i;///c is the total available result
C -=b;
If (a==1)///when the order is red, green, yellow when
{
For (I=2;; I++)
{
If (I % 3==1)
C -=r;
Else if (I % 3==2)
C -=g;
The else
C -=y;
If (c & lt; 0)
break;
}
If (I % 3==1)
The return of abs (c);
Else if (I % 3==2)
return 0;
The else
Return the abs + r (c);
}
Else if (a==2)///when the order is yellow, red, green when
{
For (I=2;; I++)
{
If (I % 3==1)
C -=y;
Else if (I % 3==2)
C -=r;
The else
C -=g;
If (c & lt; 0)
break;
}
If (I % 3==1)
Return the abs + r (c);
Else if (I % 3==2)
The return of abs (c);
The else
return 0;
}
The else///when the order is green, yellow, red when
{
For (I=2;; I++)
{
If (I % 3==1)
C -=g;
Else if (I % 3==2)
C -=y;
The else
C -=r;
If (c & lt; 0)
break;
}
If (I % 3==1)
return 0;
Else if (I % 3==2)
Return the abs + r (c);
The else
The return of abs (c);
}
}
Int main ()
{
Int s [N], [2], N, the result=0;
Int I, j;
Memset (s, 0, sizeof (s));
The scanf (" % d % d % d ", & amp; R, & amp; Y, & amp; G);
The scanf (" % d ", & amp; N);
for (i=0; I & lt; N; I++)
For (j=0; J & lt; 2; J++)
The scanf (" % d ", & amp; S [I] [j]);
for (i=0; I & lt; N; I++)
{
If (s [I] [0]==0)
The result +=s [I] [1];
The else
Result +=judge (s [0], [I] 's [I] [1], the result);
}
Printf (" % d ", result);
return 0;
}
  • Related