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 1964. Chinese Dialects

WA#13 FreePascal
Posted by Desire 2 Nov 2013 04:20
Here is my code. What is wrong? Help, please!

var m,n:int64;
k,i:0..20;
a:array[1..20] of int64;

begin
  read(n,k);
  for i:=1 to k do
  read(a[i]);
  for i:=2 to k do
  if a[i]<a[i-1] then
  begin
      m:=a[i];
      a[i]:=a[i-1];
      a[i-1]:=m
  end;
  m:=n-(n-a[1])-(n-a[2]);
  if m<=0 then write(0) else write(m);
end.

Edited by author 02.11.2013 04:21
Re: WA#13 FreePascal
Posted by Ivan Metelev 29 Nov 2014 18:51
You must only write((a1+a2+...+ak)-n)
That's all))
Good luck!
Re: WA#13 FreePascal
Posted by Sergey 14 Jan 2016 04:03
no, right answer is ((a1+a2+...+ak)-n * (k-1))