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




stdout
-1