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 1184. Cable Master

Please help me. I get WA.
Posted by raxtinhac 5 Mar 2002 20:05
Here is my programme:

const    max    = 10000;

var      a                :array[1..max] of longint;

         n,k              :word;

         dau,cuoi,giua,
         kq               :longint;

         ok               :boolean;


procedure nhap;
var    i       :word;
       x       :real;
begin
  readln( n, k);

  for i := 1 to n do
  begin  readln( x);
         a[i] := trunc( x * 100);
  end;
end;


procedure cut;
var    doan     :longint;
       i        :word;
begin
  doan := 0;
  for i := 1 to n do
  begin
    doan := doan + a[i] div giua ;
    if doan >= k then break;
  end;

  ok :=  ( doan >= k );
  if ok and ( giua > kq ) then kq := giua;
end;


procedure solve;
begin
  dau := 1; cuoi := 10000000; kq := 0;

  repeat
    giua := ( dau + cuoi ) div 2;

    cut;

    if ok then dau  := giua + 1
          else cuoi := giua - 1;
  until dau > cuoi;
end;


procedure out;
var     x     :real;
begin
  x := kq;
  x := x / 100;
  writeln(x :0 :2);
end;


begin
  nhap;
  solve;
  out;
end.
Hmm
Posted by I have answers to all your questions :) 5 Mar 2002 20:56
use round instead of trunc please ;)
Thank you for your help!
Posted by raxtinhac 6 Mar 2002 07:10