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 1648. Yachts

Problems !!! Help me!! WA #2
Posted by De5 22 Feb 2009 18:26
program verv;
var
   a : array [1 .. 20000] of Integer;
   d, d2, min, k, n, i, j : Longint;
begin
     k := 0;
     Readln (n, d);
     d2 := 0;

     for i := 1 to n do
     begin
          Read (a[i]);
          if ((d - a[i]) > 0) then
          begin
             min := d - a[i];
             for j := i + 1 to n do
                 Read (a[j]);
             Break;
          end;
     end;

     for i := 1 to n do
     begin
                if ((d + d2) - a[i]) > 0 then
                begin
                        if ((d + d2) - a[i]) < min then
                           min := (d + d2) - a[i];
                        d2 := d2 + (d - a[i]);
                        k := k + a[i];
                end
                else
                        k := k + d;
     end;
     Writeln (k, ' ', min);
end.
SHE DONT can AC !!!! Please help me

Edited by author 22.02.2009 18:27