Submission #10218315
Source Code Expand
var N,i:Longint; A:Array[1..100000]of Longint; ans,now,sum:int64; begin read(N); for i:=1 to N do read(A[i]); now:=0; sum:=0; for i:=1 to N do begin inc(sum,A[i]); if(i mod 2=1)and(sum<=0)then begin inc(now,1-sum); sum:=1; end else if(i mod 2=0)and(sum>=0)then begin inc(now,sum+1); sum:=-1; end; end; ans:=now; now:=0; sum:=0; for i:=1 to N do begin inc(sum,A[i]); if(i mod 2=0)and(sum<=0)then begin inc(now,1-sum); sum:=1; end else if(i mod 2=1)and(sum>=0)then begin inc(now,sum+1); sum:=-1; end; end; if ans>now then ans:=now; writeln(ans); end.
Submission Info
Submission Time | |
---|---|
Task | C - Sequence |
User | kotatsugame |
Language | Pascal (FPC 2.6.2) |
Score | 300 |
Code Size | 640 Byte |
Status | AC |
Exec Time | 21 ms |
Memory | 512 KB |
Compile Error
/usr/bin/ld.bfd: warning: ./link.res contains output sections; did you forget -T?
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00-00.txt, 00-01.txt, 00-02.txt |
All | 00-00.txt, 00-01.txt, 00-02.txt, 01-00.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00-00.txt | AC | 0 ms | 128 KB |
00-01.txt | AC | 0 ms | 128 KB |
00-02.txt | AC | 0 ms | 128 KB |
01-00.txt | AC | 21 ms | 512 KB |
01-01.txt | AC | 21 ms | 512 KB |
01-02.txt | AC | 20 ms | 512 KB |
01-03.txt | AC | 19 ms | 512 KB |
01-04.txt | AC | 18 ms | 384 KB |
01-05.txt | AC | 17 ms | 384 KB |
01-06.txt | AC | 20 ms | 512 KB |
01-07.txt | AC | 18 ms | 384 KB |
01-08.txt | AC | 21 ms | 512 KB |
01-09.txt | AC | 18 ms | 384 KB |
01-10.txt | AC | 15 ms | 384 KB |
01-11.txt | AC | 20 ms | 512 KB |
01-12.txt | AC | 21 ms | 512 KB |
01-13.txt | AC | 18 ms | 384 KB |
01-14.txt | AC | 21 ms | 512 KB |