fork download
  1. program asola;
  2. { NOTE: it is recommended to use this even if you don't understand the following code }
  3.  
  4. const
  5. MAXN = 100000;
  6.  
  7. var
  8. K, L, N, T, i, test : LongInt;
  9. X : Array[0..MAXN-1] of LongInt;
  10. ans : AnsiString;
  11. rimanespazio : boolean;
  12. begin
  13. {
  14.   uncomment the two following lines if you want to read/write from files
  15.   assign(input, 'input.txt'); reset(input);
  16.   assign(output, 'output.txt'); rewrite(output);
  17. }
  18.  
  19. ReadLn(T);
  20. for test:=1 to T do begin
  21. ReadLn(N, L, K);
  22.  
  23. for i:=0 to N-1 do
  24. Read(X[i]);
  25. ReadLn();
  26.  
  27. ans := '';
  28.  
  29. { INSERT YOUR CODE HERE }
  30. if (X[0]>=K) or (L-(X[N-1]+K)>=K) then ans:='YES'
  31. else
  32. begin
  33. rimanespazio:=false; i:=1;
  34. while (rimanespazio=false) and (i<N) do
  35. begin
  36. if X[i]-(X[i-1]+K)>=K then begin rimanespazio:=true; continue; end;
  37. i:=i+1;
  38. end;
  39. if rimanespazio=true then ans:='YES'
  40. else ans:='NO' ;
  41. end;
  42. WriteLn(ans);
  43. end;
  44.  
  45. end.
  46.  
Success #stdin #stdout 0s 544KB
stdin
2
0 10 2

2 10 4
0 6
stdout
YES
NO