Submission #5330342


Source Code Expand

Copy
parseInt(x) = parse(Int, x)

function main()
  N = readline() |> parseInt
  A = map(parseInt, split(readline()))

  # c = count(A .< 0)
  c = count(i -> i < 0, A)
  A_abs = map(abs, A)
  result = if c % 2 == 0
    sum(A_abs)
  else
    _, i = findmin(A_abs)
    sum(A_abs[1:i-1]) - A_abs[i] + sum(A_abs[i+1:end])
  end
  println(result)
end

main()

Submission Info

Submission Time
Task D - Flipping Signs
User yuntan_t
Language Julia (0.5.0)
Score 400
Code Size 366 Byte
Status
Exec Time 485 ms
Memory 124040 KB

Test Cases

Set Name Score / Max Score Test Cases
All 400 / 400 sample_01, sample_02, sample_03, testcase_01, testcase_02, testcase_03, testcase_04, testcase_05, testcase_06, testcase_07, testcase_08, testcase_09, testcase_10, testcase_11, testcase_12, testcase_13, testcase_14, testcase_15, testcase_16, testcase_17, testcase_18, testcase_19, testcase_20
Sample 0 / 0 sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
sample_01 430 ms 113204 KB
sample_02 440 ms 112372 KB
sample_03 445 ms 112476 KB
testcase_01 466 ms 120068 KB
testcase_02 449 ms 113996 KB
testcase_03 478 ms 122340 KB
testcase_04 434 ms 117284 KB
testcase_05 423 ms 113448 KB
testcase_06 460 ms 122116 KB
testcase_07 462 ms 116976 KB
testcase_08 469 ms 120996 KB
testcase_09 468 ms 118172 KB
testcase_10 480 ms 121384 KB
testcase_11 466 ms 117436 KB
testcase_12 453 ms 117184 KB
testcase_13 479 ms 121304 KB
testcase_14 480 ms 121976 KB
testcase_15 457 ms 120368 KB
testcase_16 457 ms 121348 KB
testcase_17 485 ms 124040 KB
testcase_18 435 ms 120064 KB
testcase_19 442 ms 112172 KB
testcase_20 460 ms 121088 KB