fork download
  1. Program vibingnetwork;
  2. uses Math;
  3. var N, T, K, i, ans, count, id :longint;
  4. a : array[1..200000] of longint;
  5. status : array[1..200000] of char;
  6. uscita : boolean;
  7. begin
  8. (*assign(input, 'input.txt'); reset(input);
  9.   assign(output, 'output.txt'); rewrite(output);*)
  10.  
  11. readln(N,T,K);
  12.  
  13. for i := 1 to T do
  14. begin
  15. read(a[i]);
  16. if a[i]>= ceil(N*67/100) then status[i]:='G'
  17. else status[i]:='B';
  18. end;
  19. readln;
  20. i:=1; count:=0; ans:=-1; id:=200001; uscita:=false;
  21. while ((i<=T) and (uscita=false)) do
  22. begin
  23. if status[i]='B' then begin i:=i+1; count:=0; id:=200001; end;
  24. if status[i]='G' then if i<id then id:=i;
  25. while status[i]='G' do
  26. begin
  27. count:=count+1;
  28. if count=k then begin ans:=id; uscita:=true; continue; end
  29. else i:=i+1;
  30. end;
  31.  
  32. end;
  33. writeln(ans);
  34. end.
  35.  
Success #stdin #stdout 0s 5320KB
stdin
4 5 3
3 2 3 3 3

stdout
3