ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1995. Illegal spices

Felix_Mate Help! I can't find error // Problem 1995. Illegal spices 4 Feb 2017 23:36
My code:
const nmax=111111;
var
 a:array[1..nmax] of int64;
 n,k,p:longint;
 i,cnt,cntmax,max:longint;
 sum:int64;

BEGIN
 readln(n,k);
 read(p);

 for i:=1 to n-k do a[i]:=1;

 sum:=n-k;
 cnt:=n-k;
 cntmax:=1;
 max:=2;

 for i:=n-k+1 to n do begin
  if(100*cnt<p*(i-1)) then begin
   inc(max);
   inc(cnt,cntmax-1);
   cntmax:=1;
  end
  else inc(cntmax);

  a[i]:=max;
  inc(sum,max);
 end;

 writeln(sum);
 for i:=1 to n do write(a[i],' ');
END.