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 1787. Turn for MEGA

WA 10
Posted by Alexandr 16 Nov 2014 20:21
/// What's wrong?
var a,b,c,i,s:integer;
m:array[1..1000000] of integer;
begin
s:=0;
read(a);
read(b);
for i:=1 to b do
begin
read(m[i]);
if(m[i]>a) then
s:=s+m[i]-a
else
begin
if s>m[i]+a then
s:=s-m[i]-a
else
s:=0;
end;
end;
if s<0 then writeln(0)
else writeln(s);
end.