Submission #1961457


Source Code Expand

N = int(input())
A = list(map(int, input().split()))

def func(A, plus):
  total = 0
  ans = 0
  if plus:
    if A[0] <= 0:
      ans = abs(A[0])+1
      total = 1
  else:
    if A[0] >= 0:
      ans += abs(A[0])+1
      total = -1
  for a in A[1:]:
    t = total + a
    if total * t < 0:
      total = t
      continue
    ans += abs(t)+1
    total = -1 if total > 0 else 1
  return ans

print(min(func(A, True), func(A, False)))

Submission Info

Submission Time
Task C - Sequence
User espressivosubito
Language Python (3.4.3)
Score 0
Code Size 454 Byte
Status WA
Exec Time 85 ms
Memory 14468 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
WA × 3
AC × 9
WA × 9
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 WA 17 ms 3064 KB
00-01.txt WA 17 ms 3064 KB
00-02.txt WA 17 ms 3064 KB
01-00.txt WA 82 ms 14332 KB
01-01.txt AC 85 ms 14332 KB
01-02.txt AC 83 ms 13780 KB
01-03.txt AC 78 ms 13280 KB
01-04.txt AC 75 ms 13152 KB
01-05.txt AC 70 ms 11884 KB
01-06.txt AC 81 ms 13672 KB
01-07.txt WA 74 ms 12556 KB
01-08.txt WA 81 ms 14332 KB
01-09.txt AC 75 ms 12756 KB
01-10.txt WA 63 ms 11068 KB
01-11.txt WA 81 ms 13784 KB
01-12.txt AC 83 ms 14332 KB
01-13.txt AC 77 ms 13036 KB
01-14.txt WA 82 ms 14468 KB