TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.  You can perform the following operation on this integer sequence any number of times:  **Operation** : Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.  Let B_1, B_2, ..., B_N be the integer sequence after your operations.  Find the maximum possible value of B_1 + B_2 + ... + B_N.

Submission attempts (in order):
N=int(input())
A=list(map(int,input().split()))

A[0]=A[0]*(-1)
A[1]=A[1]*(-1)
sum=0

for a in A:
    if a>0:
        sum+=a

print(sum)

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

A[0]=A[0]-1
A[1]=A[1]-1
max=A[0]

for a in A:
    if a>max:
        max=a
print(max)

N=int(input())
A=list(map(int,input().split()))
l=[abs(i)  for i in A]
cnt=0
for i in A:
    if(i<0):
        cnt+=1
if cnt%2==0:
    print(sum(l))
else:
    print(sum(l)-2*min(l))


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.  You can perform the following operation on this integer sequence any number of times:  **Operation** : Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.  Let B_1, B_2, ..., B_N be the integer sequence after your operations.  Find the maximum possible value of B_1 + B_2 + ... + B_N.

Submission attempts (in order):
N = int(input())
A = list(map(int,input().split(' ')))
A.sort()

from fractions import gcd
from functools import reduce
import functools

def gcd(a,b):
    if a==0:
        return b 
    else:
        return gcd(b%a,a)
  
max_gcd = 0
loop_range = min(200,len(A))


for i in range(loop_range):
  if i < N:
    values = A[i+1:] + A[:i] 
  else:
    values = A[:-1]
  
  g = lambda a,b:a if b==0 else g(b,a%b)
  gcd = functools.reduce(lambda x,y:g(x,y),values)
  max_gcd = max(max_gcd,gcd)


A.sort(reverse=True)
for i in range(loop_range):
  if i < N:
    values = A[i+1:] + A[:i] 
  else:
    values = A[:-1]
  
  g = lambda a,b:a if b==0 else g(b,a%b)
  gcd = functools.reduce(lambda x,y:g(x,y),values)
  max_gcd = max(max_gcd,gcd)

print(max_gcd)

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




min_abs = 1000000000000
cnt_in_block = 0
cnt_blocks = 0
sum_all = 0


for i,a in enumerate(A):
  
  if a < 0:
    cnt_in_block += 1
  
  
  else:
    
    if i > 0 and A[i-1] < 0:
      if cnt_in_block % 2 != 0:
        cnt_blocks += 1
    
      
      cnt_in_block = 0
    
  tmp = abs(a)
  if min_abs > tmp:
    min_abs = tmp
  sum_all += abs(a)
  
  
  if N -1 == i and cnt_in_block > 0:
    if cnt_in_block % 2 != 0:
      cnt_blocks += 1

  
if cnt_blocks % 2 == 1:
  out = sum_all - 2*min_abs
else:
  out = sum_all
  
print(out)

Verdicts: Wrong Answer

Accepted
Problem: There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.  You can perform the following operation on this integer sequence any number of times:  **Operation** : Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.  Let B_1, B_2, ..., B_N be the integer sequence after your operations.  Find the maximum possible value of B_1 + B_2 + ... + B_N.

Submission attempts (in order):
n = int(input())
nums = list(map(int,input().split()))
cnt = 0
for num in nums:
  if num < 0:
    cnt += 1
    
if cnt % 2 == 0:
  ans = sum(nums)
else:
  ans = sum(nums) - min([abs(i) for i in nums])*2
print(ans)


n = int(input())
nums = list(map(int,input().split()))
cnt = 0
for num in nums:
  if num < 0:
    cnt += 1
    
abnums = [abs(i) for i in nums]
if cnt % 2 == 0:
  ans = sum(abnums)
else:
  ans = sum(abnums) - min(abnums)*2
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.  You can perform the following operation on this integer sequence any number of times:  **Operation** : Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.  Let B_1, B_2, ..., B_N be the integer sequence after your operations.  Find the maximum possible value of B_1 + B_2 + ... + B_N.

Submission attempts (in order):
def getNumNeg(L):
    return sum([i<0 for i in L])

def findmax(L):
    numNeg = getNumNeg(L)
    if numNeg % 2 == 0: # end-point: all positive
         while getNumNeg(L) != 0:
            i = L.index(min(L[:-1]))
            j = i + 1
            L[i] = L[i] * (-1)
            L[j] = L[j] * (-1)
        print(sum(L))
    else: # end-point: smallest abs(number) is negative
        absL = list(map(abs, L))
        stop = min(absL)*(-1)
        while (getNumNeg(L) != 1) or (min(L) != stop):
            i = L.index(min(L[:-1]))
            j = i + 1
            L[i] = L[i] * (-1)
            L[j] = L[j] * (-1)
        print(sum(L))

n = int(input())
a = list(map(int, input().split()))
findmax(a)


def getNumNeg(L):
    return sum([i<0 for i in L])
  
def findmax2(L):
    numNeg = getNumNeg(L)
    absL = list(map(abs, L))
    if numNeg % 2 == 0:
        print(sum(absL))
    else:
        print(sum(absL)-min(absL))
        
n = int(input())
a = list(map(abs, input().split()))
findmax2(a)

def getNumNeg(L):
    return sum([i<0 for i in L])

def findmax(L):
    numNeg = getNumNeg(L)
    print(numNeg)
    if numNeg % 2 == 0: # end-point: all positive
         while getNumNeg(L) != 0:
            i = L.index(min(L[:-1]))
            j = i + 1
            L[i] = L[i] * (-1)
            L[j] = L[j] * (-1)
        print(sum(L))
    else: # end-point: smallest abs(number) is negative
        absL = list(map(abs, L))
        stop = min(absL)*(-1)
        while (getNumNeg(L) != 1) or (min(L) != stop):
            i = L.index(min(L[:-1]))
            j = i + 1
            L[i] = L[i] * (-1)
            L[j] = L[j] * (-1)
        print(sum(L))

n = int(input())
a = list(map(int, input().split()))
findmax(a)

def getNumNeg(L):
  return sum([i<0 for i in L])
  
def findmax2(L):
  numNeg = getNumNeg(L)
  absL = list(map(abs, L))
  if numNeg % 2 == 0:
    print(sum(absL))
  else:
    print(sum(absL)-min(absL))
        
n = int(input())
a = list(map(abs, input().split()))
findmax2(a)


def getNumNeg(L):
  return sum([i<0 for i in L])
  
def findmax2(L):
  numNeg = getNumNeg(L)
  absL = list(map(abs, L))
  if numNeg % 2 == 0:
    print(sum(absL))
  else:
    print(sum(absL)-2*min(absL))
        
n = int(input())
a = list(map(int, input().split()))
findmax2(a)


Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.  You can perform the following operation on this integer sequence any number of times:  **Operation** : Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.  Let B_1, B_2, ..., B_N be the integer sequence after your operations.  Find the maximum possible value of B_1 + B_2 + ... + B_N.

Submission attempts (in order):
import sys
from functools import lru_cache
sys.setrecursionlimit(10**7)
INF = 10 ** 18

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def II(): return int(sys.stdin.readline())

N = II()
A_li = LI()
N = len(A_li)

@lru_cache(maxsize=None)
def dp(i,j):
    print(i,j)
    if i == 0:
        if j == 0: return A_li[0]
        elif j == 1: return -A_li[0]
    else:
        if j == 0: return max(dp(i-1, 0) + A_li[i], dp(i-1, 1) - A_li[i])
        elif j == 1: return max(dp(i-1, 0) - A_li[i], dp(i-1, 1) + A_li[i])

print(dp(N-1,0))


import sys
from functools import lru_cache
sys.setrecursionlimit(10**7)
INF = 10 ** 18

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def II(): return int(sys.stdin.readline())

N = II()
A_li = LI()
N = len(A_li)

@lru_cache(maxsize=None)
def dp(i,j):
    if i == 0:
        if j == 0: return A_li[0]
        elif j == 1: return -A_li[0]
    else:
        if j == 0: return max(dp(i-1, 0) + A_li[i], dp(i-1, 1) - A_li[i])
        elif j == 1: return max(dp(i-1, 0) - A_li[i], dp(i-1, 1) + A_li[i])

print(dp(N-1,0))


Verdicts: Wrong Answer

Accepted
Problem: There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.  You can perform the following operation on this integer sequence any number of times:  **Operation** : Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.  Let B_1, B_2, ..., B_N be the integer sequence after your operations.  Find the maximum possible value of B_1 + B_2 + ... + B_N.

Submission attempts (in order):
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a = na()
c=0
for i in a:
    if i < 0:
        c+=1

b = [abs(i) for i in a]

if c%2 == 0:
    print(b)
    exit()

b.sort()
print(sum(b)-2*b[0])

import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a = na()
c=0
for i in a:
    if i < 0:
        c+=1

b = [abs(i) for i in a]

if c%2 == 0:
    print(sum(b))
    exit()

b.sort()
print(sum(b)-2*b[0])

Verdicts: Wrong Answer

Accepted
Problem: There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.  You can perform the following operation on this integer sequence any number of times:  **Operation** : Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.  Let B_1, B_2, ..., B_N be the integer sequence after your operations.  Find the maximum possible value of B_1 + B_2 + ... + B_N.

Submission attempts (in order):
n = int(input())
a = list(map(int, input().split()))

a.sort()
minus = n
for i in range(n):
  if a[i] >= 0:
    s = i
    break

a = list(map(abs, a))
a.sort()

if minus % 2 == 0:
  print(sum(a))
else:
  print(sum(a) - 2 * a[0])


n = int(input())
a = list(map(int, input().split()))

a.sort()
minus = n
for i in range(n):
  if a[i] >= 0:
    minus = i
    break

a = list(map(abs, a))
a.sort()

if minus % 2 == 0:
  print(sum(a))
else:
  print(sum(a) - 2 * a[0])


Verdicts: Wrong Answer

Accepted
Problem: There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.  You can perform the following operation on this integer sequence any number of times:  **Operation** : Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.  Let B_1, B_2, ..., B_N be the integer sequence after your operations.  Find the maximum possible value of B_1 + B_2 + ... + B_N.

Submission attempts (in order):

N = int(input())
A = list(map(int,input().split()))
# N=3
# A = [-10,5,-4]
ans = 0
minnum = abs(A[0])
for i in range(N):
    ans += abs(A[i])
    minnum = min(minnum,abs(A[i]))
    #print(minnum,ans)
ans -= minnum*2
print(ans)


N = int(input())
A = list(map(int,input().split()))
# N=3
# A = [-10,5,-4]
ans = 0
minnum = abs(A[0])
for i in range(N):
    ans += abs(A[i])
    minnum = min(minnum,abs(A[i]))
    #print(minnum,ans)
if N%2 == 1:
    ans -= minnum*2
print(ans)


N = int(input())
A = list(map(int,input().split()))
# N=3
# A = [-10,5,-4]
ans = 0
minnum = abs(A[0])
numminus = 0
for i in range(N):
    if A[i]<0:
        numminus+=1
    ans += abs(A[i])
    minnum = min(minnum,abs(A[i]))
    #print(minnum,ans)
if numminus%2 == 1:
    ans -= minnum*2
print(ans)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.  You can perform the following operation on this integer sequence any number of times:  **Operation** : Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.  Let B_1, B_2, ..., B_N be the integer sequence after your operations.  Find the maximum possible value of B_1 + B_2 + ... + B_N.

Submission attempts (in order):
import math
from functools import reduce
def mkt(a, b):
    while b:
        a, b = b, a % b
    return a
def gcd_list(numbers):
    return reduce(mkt, numbers)
n=int(input())
a=list(map(int,input().split()))
max=1
for i in range(n):
    q=gcd_list(a[:i]+a[i+1:])
    if q>max:
        max=q
print(max)

import math
n=int(input())
a=list(map(int,input().split()))
cnt=0
for i in range(n):
    if a[i]<0:
        a[i]=-a[i]
        cnt+=1
q=min(a)
if cnt%2==0:
    print(sum(a))
else:
    print(sum(a)-2*q)

Verdicts: Wrong Answer

Accepted
Problem: There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.  You can perform the following operation on this integer sequence any number of times:  **Operation** : Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.  Let B_1, B_2, ..., B_N be the integer sequence after your operations.  Find the maximum possible value of B_1 + B_2 + ... + B_N.

Submission attempts (in order):
n = int(input())
a = list(map(int,input().split()))
mi = 0
for i in range(a):
  if a[i] < 0:
    mi+=1
  a[i]= abs(a[i])
if mi %2 == 1:
  print(sum(a)-min(a))
else:
  print(sum(a))

n = int(input())
a = list(map(int,input().split()))
mi = 0
for i in range(n):
  if a[i] < 0:
    mi+=1
  a[i]= abs(a[i])
if mi %2 == 1:
  print(sum(a)-2*min(a))
else:
  print(sum(a))

Verdicts: Runtime Error

Accepted
Problem: There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.  You can perform the following operation on this integer sequence any number of times:  **Operation** : Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.  Let B_1, B_2, ..., B_N be the integer sequence after your operations.  Find the maximum possible value of B_1 + B_2 + ... + B_N.

Submission attempts (in order):
n=int(input())
a=list(map(int,input().split()))
f=0
for i in range(n-1):
  if a[i]<=0 and a[i+1]<=0 and f==0:
    a[i]=a[i]*(-1)
    a[i+1]=a[i+1]*(-1)
    f=1
  elif a[i]*a[i+1]<=0:
    a[i]=max(a[i]+a[i+1],-a[i+1]-a[i])
    a[i+1]=0
    f=0
  else:
    f=0
s=0
for i in range(n):
  s=s+a[i]
print(s)


n=int(input())
a=list(map(int,input().split()))
f=0
for i in range(n-1):
  if a[i]<=0 and a[i+1]<=0 and f==0:
    a[i]=a[i]*(-1)
    a[i+1]=a[i+1]*(-1)
    f=1
  elif a[i]*a[i+1]<=0:
    

n=int(input())
a=list(map(int,input().split()))
sei=[0]*n
mai=0
zero=0
pr=0
for i in range(n):
  sei[i]=max(a[i],-a[i])
  pr+=sei[i]
  if a[i]<0:
    mai +=1
  elif a[i]==0:
    zero+=1
  else:
    pass

if mai%2==0 or zero >=1:
    print(pr)
else:
    print(pr-2*min(sei))


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.  You can perform the following operation on this integer sequence any number of times:  **Operation** : Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.  Let B_1, B_2, ..., B_N be the integer sequence after your operations.  Find the maximum possible value of B_1 + B_2 + ... + B_N.

Submission attempts (in order):
#include "bits/stdc++.h"

using namespace std;

int i;

int main(){
  int N, neg_cnt = 0;
  cin >> N;
  vector<int> A(N), B(N);
  for (i = 0; i < N; i++){
    cin >> A[i];
    if (A[i] < 0){
      neg_cnt++;
    }
  }
  for (i = 0; i < N; i++){
    B[i] = abs(A[i]);
  }
  int acm = 0;
  int min = *min_element(B.begin(), B.end());
  acm = accumulate(B.begin(), B.end(), 0);
  if (neg_cnt%2 == 0){
    cout << acm << endl;
  }else{
    cout << acm - 2*min << endl;
  }
}

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

neg_cnt = 0
for a in A:
  if a < 0:
    neg_cnt += 1

B = list(map(abs, A))
if neg_cnt%2 == 0:
  print(sum(B))
else:
  print(sum(B) - 2*min(B))

Verdicts: Runtime Error

Accepted
Problem: There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.  You can perform the following operation on this integer sequence any number of times:  **Operation** : Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.  Let B_1, B_2, ..., B_N be the integer sequence after your operations.  Find the maximum possible value of B_1 + B_2 + ... + B_N.

Submission attempts (in order):
n = int(input())
w = input().split(" ")

a = []
k = False
for i in range(n):
    a.append(int(w[i]))
    if a[i] < 0:
    	a[i] *= -1
        k= not(k)
    if i == 1:
        min = a[i]
    if a[i] < min:
        min = a[i]
2
sum = sum(a)
if k:
    sum -= min
print(sum)

n = int(input())
w = input().split(" ")

a = []
k = False
for i in range(n):
    a.append(int(w[i]))
    if a[i] < 0:
       a[i] *= -1
       k = not(k)
    if i == 1:
        min = a[i]
    if a[i] < min:
        min = a[i]
2
sum = sum(a)
if k:
    sum -= min
print(sum)


n = int(input())
w = input().split(' ')

a = []
k = False
for i in range(n):
    a.append(int(w[i]))
    if a[i] < 0:
       a[i] *= -1
       k = not(k)
    if i == 1:
        min = a[i]
    if a[i] < min:
        min = a[i]

sum = sum(a)
if k:
    sum -= min
print(sum)

n = int(input())
w = input().split(" ")

a = []
k = False
for i in range(n):
    a.append(int(w[i]))
    if a[i] < 0:
        a[i] *= -1
        k = not(k)
    if i == 1:
        min = a[i]
    if a[i] < min:
        min = a[i]

sum = sum(a)
if k:
    sum -= min
print(sum)

n = int(input())
w = input().split(" ")

a = []
k = False
z = False
for i in range(n):
    a.append(int(w[i]))
    if a[i] < 0:
        a[i] *= -1
        k = not (k)
    if a[i] == 0:
        z = True
    if i == 1:
        min = a[i]
    if a[i] < min:
        min = a[i]

sum = sum(a)
if k and not(z):
    sum -= min
print(sum)

n = int(input())
w = input().split(" ")

a = []
k = False
for i in range(n):
    a.append(int(w[i]))
    if a[i] < 0:
       a[i] *= -1
       k = not(k)
    if i == 1:
        min = a[i]
    if a[i] < min:
        min = a[i]
2
sum = sum(a)
if k:
    sum -= min
print(sum)

n = int(input())
w = input().split(" ")

a = []
k = False
for i in range(n):
    a.append(int(w[i]))
    if a[i] < 0:
        a[i] *= -1
        k = not(k)
    if i == 1:
        min = a[i]
    if a[i] < min:
        min = a[i]

sum = sum(a)
if k:
    sum -= min
print(sum)

n = int(input())
w = input().split(" ")

a = []
k = False
for i in range(n):
    a.append(int(w[i]))
    if a[i] < 0:
        a[i] *= -1
        k = not(k)
    if i == 1:
        min = a[i]
    if a[i] < min:
        min = a[i]

sum = sum(a)
if k:
    sum -= min
print(sum)

n = int(input())
w = input().split(" ")

a = []
m = 0
k = False
for i in range(n):
    a.append(int(w[i]))
    if a[i] < 0:
        a[i] *= -1
        k = not (k)
    if i == 0:
        m = a[i]
    if a[i] < m:
        m = a[i]

sum = sum(a)
if k:
    sum -= m*2
print(sum)


Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.  You can perform the following operation on this integer sequence any number of times:  **Operation** : Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.  Let B_1, B_2, ..., B_N be the integer sequence after your operations.  Find the maximum possible value of B_1 + B_2 + ... + B_N.

Submission attempts (in order):
N = int(input())
a_list = list(map(int, input().split()))

for i in range(N-2):
    if a_list[i] <0 and a_list[i+1] < 0:
       a_list[i] *= -1
       a_list[i+1] *= -1

for i in range(N-2):
    if a_list[i] + a_list[i+1] < 0:
       a_list[i] *= -1
       a_list[i+1] *= -1

ans = sum(a_list)

min_list = []
for i in range(N-1):
    if a_list[i] < 0:
        min_list.append(a_list[i])

if len(min_list) % 2 == 0:
    abc = sum(min_list)
    abc *= -1
    print(ans + 2*abc)

if len(min_list) % 2 == 1:
    abc.sort()
    min_list = min_list[:-1]
    abc = sum(min_list)
    abc *= -1
    print(ans + 2*abc) 


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

for i in range(N-1):
    if a_list[i] <0 and a_list[i+1] < 0:
       a_list[i] *= -1
       a_list[i+1] *= -1

for i in range(N-1):
    if a_list[i] + a_list[i+1] < 0:
       a_list[i] *= -1
       a_list[i+1] *= -1

ans = sum(a_list)

min_list = []
for i in range(N):
    if a_list[i] < 0:
        min_list.append(a_list[i])

if len(min_list) % 2 == 0:
    abc = sum(min_list)
    abc *= -1
    print(ans + 2*abc)

if len(min_list) % 2 == 1 and len(min_list) !=1 :
    abc.sort()
    min_list = min_list[:-1]
    abc = sum(min_list)
    abc *= -1
    print(ans + 2*abc)
else:
    print(ans)

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

for i in range(N-1):
    if a_list[i] <0 and a_list[i+1] < 0:
       a_list[i] *= -1
       a_list[i+1] *= -1

counter = 0
min_list = []
for i in range(N):
    if a_list[i] < 0:
        counter += 1
        min_list.append(a_list[i])

if counter % 2 == 0:
    abc = sum(min_list)
    abc *= -1
    ans = sum(a_list)
    print(ans + 2*abc)

if counter % 2 == 1:
    for i in range(N):
        if a_list[i] < 0:
            a_list[i] *= -1
    min_mun = min(a_list)
    ans = sum(a_list) - 2*min_mun
    print(ans)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.  You can perform the following operation on this integer sequence any number of times:  **Operation** : Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.  Let B_1, B_2, ..., B_N be the integer sequence after your operations.  Find the maximum possible value of B_1 + B_2 + ... + B_N.

Submission attempts (in order):
# -*- coding: utf-8 -*-
N = int(input())
A = list(map(int, input().split()))

dp = [[0] * 2 for _ in range(N)]
dp[0][0] = A[0] + A[1]
dp[0][1] = - A[0] - A[1]

for i in range(1, N - 1):
    bidx = i - 1
    nidx = i + 1
    for j in range(2):
        dp[i][0] = max(dp[bidx][0] + A[nidx],
                       dp[bidx][1] + A[nidx])
        dp[i][1] = max(dp[bidx][0] - 2 * A[i] - A[nidx],
                       dp[bidx][1] - 2 * A[i] - A[nidx])

print(max(dp[N - 2]))

# -*- coding: utf-8 -*-
N = int(input())
A = list(map(int, input().split()))

dp = [[0] * 2 for _ in range(N)]
dp[0][0] = A[0] + A[1]
dp[0][1] = - A[0] - A[1]

for i in range(1, N - 1):
    dp[i][0] = max(dp[i - 1][0] + A[i + 1],
                   dp[i - 1][1] + A[i + 1])
    dp[i][1] = max(dp[i - 1][0] - 2 * A[i] - A[i + 1],
                   dp[i - 1][1] + 2 * A[i] - A[i + 1])

print(max(dp[N - 2]))

Verdicts: Wrong Answer

Accepted
Problem: There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.  You can perform the following operation on this integer sequence any number of times:  **Operation** : Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.  Let B_1, B_2, ..., B_N be the integer sequence after your operations.  Find the maximum possible value of B_1 + B_2 + ... + B_N.

Submission attempts (in order):
n=int(input())
A=list(map(int,input().split()))
B=[abs(i) for i in A]
P=0
for i in A:
    if i<0:P +=1
    elif i==0:print(sum(B));exit()

print(B if P%2==0 else sum(B)-2*min(B))

n=int(input())
A=list(map(int,input().split()))
cnt,po=0,0
for i in range(n):
    if A[i]<0:po +=1
    A[i]=abs(A[i])
    cnt +=A[i]
print(cnt-2*min(A) if po%2==1 else cnt)

Verdicts: Wrong Answer

Accepted
Problem: There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.  You can perform the following operation on this integer sequence any number of times:  **Operation** : Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.  Let B_1, B_2, ..., B_N be the integer sequence after your operations.  Find the maximum possible value of B_1 + B_2 + ... + B_N.

Submission attempts (in order):
n=int(input())
a=list(map(int,input().split()))
mn=10**18
ng=0
for i in a:
  mn=min(mn,abs(i))
  if i<0:
    ng+=1
if ng%2==0:
  print(sum(a))
else:
  print(sum(a)-mn*2)

n=int(input())
a=list(map(int,input().split()))
mn=10**18
ng=0
sm=0
for i in a:
  sm+=abs(i)
  mn=min(mn,abs(i))
  if i<0:
    ng+=1
if ng%2==0:
  print(sm)
else:
  print(sm-mn*2)

Verdicts: Wrong Answer

Accepted
Problem: There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.  You can perform the following operation on this integer sequence any number of times:  **Operation** : Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.  Let B_1, B_2, ..., B_N be the integer sequence after your operations.  Find the maximum possible value of B_1 + B_2 + ... + B_N.

Submission attempts (in order):
n = int(input())
a = map(int, input().split()
abs_a = list(map(abs, a)))
print(sum(abs_a) if len([i for i in a if i < 0]) % 2 == 0 else sum(abs_a) - 2 * min(a))


n = int(input())
a = map(int, input().split())
print(sum(a) - 2 * min(a))


n = int(input())
a = list(map(int, input().split()))
abs_a = list(map(abs, a))
print(sum(abs_a) if len([i for i in a if i < 0]) % 2 == 0 else sum(abs_a) - 2 * min(abs_a))


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.  You can perform the following operation on this integer sequence any number of times:  **Operation** : Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.  Let B_1, B_2, ..., B_N be the integer sequence after your operations.  Find the maximum possible value of B_1 + B_2 + ... + B_N.

Submission attempts (in order):
def solve(n, a_list):
    total = [abs(item) for item in a_list]
    negative = [abs(item) for item in a_list if item < 0]
    print(negative)
    if len(negative) % 2 == 0:
        return sum([abs(item) for item in a_list])
    else:
        minimum = sorted(total)[0]
        return sum([abs(item) for item in a_list]) - 2 * minimum


def input_from_console():
    n = int(input())
    a = list(map(int, input().split()))
    return n, a


def main():
    n, a_list = input_from_console()
    print(solve(n, a_list))


if __name__ == "__main__":
    main()


def solve(n, a_list):
    total = [abs(item) for item in a_list]
    negative = [abs(item) for item in a_list if item < 0]
    
    if len(negative) % 2 == 0:
        return sum([abs(item) for item in a_list])
    else:
        minimum = sorted(total)[0]
        return sum([abs(item) for item in a_list]) - 2 * minimum


def input_from_console():
    n = int(input())
    a = list(map(int, input().split()))
    return n, a


def main():
    n, a_list = input_from_console()
    print(solve(n, a_list))


if __name__ == "__main__":
    main()

Verdicts: Wrong Answer

Accepted
Problem: There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.  You can perform the following operation on this integer sequence any number of times:  **Operation** : Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.  Let B_1, B_2, ..., B_N be the integer sequence after your operations.  Find the maximum possible value of B_1 + B_2 + ... + B_N.

Submission attempts (in order):
import sys
from fractions import gcd
input = sys.stdin.readline

def main():
    n=int(input())
    a=list(map(int,input().split()))
    f,b=[0]*(n+2),[0]*(n+2)
    f[1],b[n]=a[0],a[-1]
    for i in range(2,n+1):
        f[i],b[n-i+1]=gcd(a[i-1],f[i-1]),gcd(a[n-i],b[n-i+2])
    ans=0
    for i in range(1,n+1):
      ans=max(ans,gcd(f[i-1],b[i+1]))
    print(ans)
    
if __name__ == '__main__':
    main()

import sys
import fractions as fr
input = sys.stdin.readline

def main():
    n=int(input())
    a=list(map(int,input().split()))
    f,b=[0]*n,[0]*n
    for i in range(n):
      if i==0:
        f[i],b[n-i-1]=a[i],a[n-i-1]
      else:
        f[i],b[n-i-1]=fr.gcd(a[i],a[i-1]),fr.gcd(a[n-i-1],a[n-i])
    ans=max(b[1],f[-2])
    for i in range(1,n-1):
      ans=max(ans,fr.gcd(f[i-1],b[i+1]))
    print(ans)
    
if __name__ == '__main__':
    main()

import sys
input = sys.stdin.readline

def main():
    n=int(input())
    a=sorted(list(map(int,input().split())))
    mnum=0
    for i,x in enumerate(a):
        if x>=0:
            mnum=i
            break
    m,p=-a[i-1],a[i]
    if i%2==0:
        print(-sum(a[:i])+sum(a[i:]))
    else:
        print(-sum(a[:i])+sum(a[i:])-2*min(m,p))

if __name__ == '__main__':
    main()

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.  You can perform the following operation on this integer sequence any number of times:  **Operation** : Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.  Let B_1, B_2, ..., B_N be the integer sequence after your operations.  Find the maximum possible value of B_1 + B_2 + ... + B_N.

Submission attempts (in order):
n = int(input())
a = input().split()
mi = int(a[0])
ans =  0 
for i in range(n):
    ans = ans + abs(int(a[i]))
    if mi > int(a[i]):
        mi = int(a[i])
print(ans-2*mi)


n = int(input())
a = input().split()
mi = abs(int(a[0]))
ans =  0 
count = 0
for i in range(n):
    ans = ans + abs(int(a[i]))
    if mi > abs(int(a[i])):
        mi = abs(int(a[i]))
    if int(a[i])<0:
        count = count + 1
if count%2 ==0:
    print(ans)
else:
    print(ans-2*mi)


Verdicts: Wrong Answer

Accepted
Problem: There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.  You can perform the following operation on this integer sequence any number of times:  **Operation** : Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.  Let B_1, B_2, ..., B_N be the integer sequence after your operations.  Find the maximum possible value of B_1 + B_2 + ... + B_N.

Submission attempts (in order):
N = map(int, input().split())
A_list = list(map(int, input().split()))
A_sum = sum(A_list)
array1 = A_list[1:]
array2 = A_list[:-1]
array_add = max(list(map(lambda x,y: -(x+y), array1, array2)))*2
B_set =A_sum+ array_add
print(B_set)

import numpy
N = map(int, input().split())
A_list = list(map(int, input().split()))
set = numpy.abs(numpy.array(A_list))
A_abs_min = min(set)
A_abs_sum = sum(set)
n = sum(x<0 for x in A_list)%2  
if n == 1:
    ans = A_abs_sum-2*A_abs_min
else:
    ans =  A_abs_sum
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.  You can perform the following operation on this integer sequence any number of times:  **Operation** : Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.  Let B_1, B_2, ..., B_N be the integer sequence after your operations.  Find the maximum possible value of B_1 + B_2 + ... + B_N.

Submission attempts (in order):
N = int(input())
A_list = list(map(int, input().split()))

min_v = 10**9+1
cnt_min = 0
res = 0
for i, a in enumerate(A_list):
    print(i, a)
    if a < 0:
        cnt_min += 1
        a = -1 * a
    min_v = min(min_v, a)
    res += a

if cnt_min%2 == 1:
    res -= 2*min_v
print(res)

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

min_v = 10**9+1
cnt_min = 0
res = 0
for i, a in enumerate(A_list):
    if a < 0:
        cnt_min += 1
        a = -1 * a
    min_v = min(min_v, a)
    res += a

if cnt_min%2 == 1:
    res -= 2*min_v
print(res)

Verdicts: Wrong Answer

Accepted
Problem: There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.  You can perform the following operation on this integer sequence any number of times:  **Operation** : Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.  Let B_1, B_2, ..., B_N be the integer sequence after your operations.  Find the maximum possible value of B_1 + B_2 + ... + B_N.

Submission attempts (in order):
import numpy as np

n = int(input())
l = np.array([int(x) for x in input().split()])
ans = 0
if 0 in l:
  for i in range(n):
    ans += abs(l[i])
  sys.exit()
m = abs(l[0])
for i in range(n):
  if l[i] < 0:
    p += 1
  if m < abs(l[i])
for i in range(n):
  ans += abs(l[i])
if p % 2 == 0:
  print(ans)
else:
  print(ans - m*2)

import numpy as np
import sys
 
n = int(input())
l = np.array([int(x) for x in input().split()])
ans = 0
if 0 in l:
  for i in range(n):
    ans += abs(l[i])
  print(ans)
  sys.exit()
m = abs(l[0])
for i in range(n):
  if l[i] < 0:
    p += 1
  if m < abs(l[i]):
    m = abs(l[i])
for i in range(n):
  ans += abs(l[i])
if p % 2 == 0:
  print(ans)
else:
  print(ans - m*2)

import numpy as np
import sys
 
n = int(input())
l = np.array([int(x) for x in input().split()])
ans = 0
if 0 in l:
  for i in range(n):
    ans += abs(l[i])
  print(ans)
  sys.exit()
m = abs(l[0])
p = 0
for i in range(n):
  if l[i] < 0:
    p += 1
  if m > abs(l[i]):
    m = abs(l[i])
for i in range(n):
  ans += abs(l[i])
if p % 2 == 0:
  print(ans)
else:
  print(ans - m*2)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.  You can perform the following operation on this integer sequence any number of times:  **Operation** : Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.  Let B_1, B_2, ..., B_N be the integer sequence after your operations.  Find the maximum possible value of B_1 + B_2 + ... + B_N.

Submission attempts (in order):
n = int(input())
aa = list(map(int, input().split()))

min_abs = 10*10
negative_count = 0
ans = 0
for a in aa:
    if a<0: negative_count += 1
    min_abs = min(min_abs, abs(a))
    ans += abs(a)
    print(negative_count, ans, min_abs) 

if negative_count%2==1:
    ans -= min_abs*2
print(ans)


n = int(input())
aa = list(map(int, input().split()))
abs_aa = sorted([abs(a) for a in aa])
minus_count = sum([1 for a in aa if a < 0])
if minus_count % 2:
    abs_aa[0] *= -1
print(sum(abs_aa))

Verdicts: Wrong Answer

Accepted
Problem: There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.  You can perform the following operation on this integer sequence any number of times:  **Operation** : Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.  Let B_1, B_2, ..., B_N be the integer sequence after your operations.  Find the maximum possible value of B_1 + B_2 + ... + B_N.

Submission attempts (in order):
def d_flipping_signs_dp(N, A):
    dp = [[0] * 2 for _ in range(N + 1)]
    dp[0][0] = 0
    dp[0][1] = -float('inf')
    for i in range(N):
        dp[i + 1][0] = max(dp[i][0] + A[i], dp[i][1] - A[i])
        dp[i + 1][1] = max(dp[i][0] - A[i], dp[i][1] + A[i])
    return dp[N][0]

N = int(input())
A = [int(i) for i in input().split()]
print(d_flipping_signs(N, A))

def d_flipping_signs_dp(N, A):
    dp = [[0] * 2 for _ in range(N + 1)]
    dp[0][0] = 0
    dp[0][1] = -float('inf')
    for i in range(N):
        dp[i + 1][0] = max(dp[i][0] + A[i], dp[i][1] - A[i])
        dp[i + 1][1] = max(dp[i][0] - A[i], dp[i][1] + A[i])
    return dp[N][0]

N = int(input())
A = [int(i) for i in input().split()]
print(d_flipping_signs_dp(N, A))

Verdicts: Runtime Error

Accepted
Problem: There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.  You can perform the following operation on this integer sequence any number of times:  **Operation** : Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.  Let B_1, B_2, ..., B_N be the integer sequence after your operations.  Find the maximum possible value of B_1 + B_2 + ... + B_N.

Submission attempts (in order):
N = int(input())
A = list(map(int,input().split()))
B = list(map(abs,a))
C = [a for a in A if a < 0]

if len(C) % 2 == 0:
    print((sum(B)))
else:
    print((sum(B)-min(B)*2))

n = int(input())
a = list(map(int,input().split()))
b = list(map(abs,a))
c = list(a for a in A if a < 0)

if len(c) % 2 == 0:
    print(sum(b))
else:
    print(sum(b)-min(b)*2)

n = int(input())
A = list(map(int,input().split()))
b = list(map(abs,a))
c = [a for a in A if a < 0]

if len(c) % 2 == 0:
    print(sum(b))
else:
    print(sum(b)-min(b)*2)


N = int(input())
A = list(map(int, input().split()))
B = list(map(abs, A))
C = [a for a in A if a < 0]
if len(C) % 2 == 0:
    print((sum(B)))
else:
    print((sum(B) - min(B)*2))


Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.  You can perform the following operation on this integer sequence any number of times:  **Operation** : Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.  Let B_1, B_2, ..., B_N be the integer sequence after your operations.  Find the maximum possible value of B_1 + B_2 + ... + B_N.

Submission attempts (in order):
N = int(input())
A = [int(i) for i in input().split()]

count = 0

for i in range(N):
  if A[i] <=0:
    count = count + 1
    A[i] = A[i] * -1

if count%2 == 1:
  ans = sum(A)
else:
  ans = sum(A) - 2*min(A)

print(ans)


N = int(input())
A = [int(i) for i in input().split()]

count = 0
for i in range(N):
  if A[i] <=0:
    count = count + 1
    A[i] = A[i] * -1

if 0 in A:
  ans = sum(A)
else:
  if count%2 == 1:
    ans = sum(A)
  else:
    ans = sum(A) - 2*min(A)

print(ans)


N = int(input())
A = [int(i) for i in input().split()]

ans = sum(A)
for i in range(N):
  if A[i] < 0:
    if i != N-1:
      A[i] = A[i] * -1
      A[i+1] = A[i+1] * -1
      print(A)
  ans = max(ans, sum(A))

print(ans)


N = int(input())
A = [int(i) for i in input().split()]

count = 0
for i in range(N):
  if A[i] <0:
    count = count + 1
    A[i] = A[i] * -1

if 0 in A:
  ans = sum(A)
else:
  if count%2 == 1:
    ans = sum(A)
  else:
    ans = sum(A) - 2*min(A)

print(ans)


N = int(input())
A = [int(i) for i in input().split()]

count = 0
for i in range(N):
  if A[i] <0:
    count = count + 1
    A[i] = A[i] * -1

if 0 in A:
  ans = sum(A)
else:
  if count%2 == 0:
    ans = sum(A)
  else:
    ans = sum(A) - 2*min(A)

print(ans)


Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.  You can perform the following operation on this integer sequence any number of times:  **Operation** : Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.  Let B_1, B_2, ..., B_N be the integer sequence after your operations.  Find the maximum possible value of B_1 + B_2 + ... + B_N.

Submission attempts (in order):
n=int(input())
a=list(map(int,input().split()))
cnt=0
zero=0
ans=0
mn=1000000001
for x in a:
  mn=min(mn,abs(x))
  if x<0:
    cnt+=1
    ans-=x
  else:
    ans+=x
  print(ans)
cnt%=2
if cnt==0:
  print(ans)
else:
  print(ans-mn*2)
  
  
  
  
  
#print(ans,cnt,mn)

n=int(input())
a=list(map(int,input().split()))
cnt=0
zero=0
ans=0
mn=1000000001
for x in a:
  mn=min(mn,abs(x))
  if x<0:
    cnt+=1
    ans-=x
  else:
    ans+=x
  #print(ans)
cnt%=2
if cnt==0:
  print(ans)
else:
  print(ans-mn*2)
  
  
  
  
  
#print(ans,cnt,mn)

Verdicts: Wrong Answer

Accepted
Problem: There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.  You can perform the following operation on this integer sequence any number of times:  **Operation** : Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.  Let B_1, B_2, ..., B_N be the integer sequence after your operations.  Find the maximum possible value of B_1 + B_2 + ... + B_N.

Submission attempts (in order):
input()
a = list(map(int, input().split()))
cnt = sum([i < 0 for i in a])
s = [abs(i) for i in a]
print(cnt)
if cnt % 2 == 0:
    print(sum(s))
else:
    print(sum(s) - min(s) * 2)

input()
a = list(map(int, input().split()))
cnt = sum([i < 0 for i in a])
s = [abs(i) for i in a]
if cnt % 2 == 0:
    print(sum(s))
else:
    print(sum(s) - min(s) * 2)

Verdicts: Wrong Answer

Accepted
Problem: There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.  You can perform the following operation on this integer sequence any number of times:  **Operation** : Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.  Let B_1, B_2, ..., B_N be the integer sequence after your operations.  Find the maximum possible value of B_1 + B_2 + ... + B_N.

Submission attempts (in order):
n = int(input())
num = list(map(int,input().split()))
numabs = [abs(i) for i in num]
cnt = 0    
negative = []        
for i in num :
    if i < 0 :
        cnt += 1
        negtive.append()

if cnt % 2 == 0 :
    print(sum(numabs))

if cnt % 2 == 1 :
    print(sum(numabs)-2*max(negative))

n = int(input())
num = list(map(int,input().split()))
numabs = [abs(i) for i in num]
cnt = 0    
negative = []        
for i in num :
    if i < 0 :
        cnt += 1
        negative.append()

if cnt % 2 == 0 :
    print(sum(numabs))

if cnt % 2 == 1 :
    print(sum(numabs)-2*max(negative))

n = int(input())
num = list(map(int,input().split()))
numabs = [abs(i) for i in num]
cnt = 0           
for i in num :
    if i < 0 :
        cnt += 1

if cnt % 2 == 0 :
    print(sum(numabs))

if cnt % 2 == 1 :
    print(sum(numabs) - 2*min(numabs))

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.  You can perform the following operation on this integer sequence any number of times:  **Operation** : Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.  Let B_1, B_2, ..., B_N be the integer sequence after your operations.  Find the maximum possible value of B_1 + B_2 + ... + B_N.

Submission attempts (in order):

num_count = int(input())


nums_list = list(map(int, input().split()))


convert_nums = [0] * num_count

max_num = 0

for num in nums_list:
    max_num += abs(num)

if num_count % 2 != 0:
    max_num -= min(list(map(abs, nums_list))) * 2

print(max_num)


num_count = int(input())


nums_list = list(map(int, input().split()))

max_num = 0
zero_count = 0
minus_count = 0

for num in nums_list:
    max_num += abs(num)

    if num == 0:
        zero_count += 1
    if num < 0:
        minus_count += 1

if zero_count == 0 and minus_count % 2 != 0:
    max_num -= min(list(map(abs, nums_list))) * 2

print(max_num)

Verdicts: Wrong Answer

Accepted
Problem: There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order.  You can perform the following operation on this integer sequence any number of times:  **Operation** : Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1.  Let B_1, B_2, ..., B_N be the integer sequence after your operations.  Find the maximum possible value of B_1 + B_2 + ... + B_N.

Submission attempts (in order):
n=int(input())
A=list(map(int,input().split()))
B=[0]*n
for i in range(n):
    B[i]=abs(A[i])
B.sort()
print(sum(B)-2*B[0])

n=int(input())
A=list(map(int,input().split()))
B=[0]*n
cnt=0
for i in range(n):
    if A[i]<0:
        cnt+=1
    B[i]=abs(A[i])
B.sort()
if cnt%2==0:
    print(sum(B))
else:
    print(sum(B)-2*B[0])

Verdicts: Wrong Answer

Accepted
Problem: There are N mountains ranging from east to west, and an ocean to the west.  At the top of each mountain, there is an inn. You have decided to choose where to stay from these inns.  The height of the i-th mountain from the west is H_i.  You can certainly see the ocean from the inn at the top of the westmost mountain.  For the inn at the top of the i-th mountain from the west (i = 2, 3, ..., N), you can see the ocean if and only if H_1 \leq H_i, H_2 \leq H_i, ..., and H_{i-1} \leq H_i.  From how many of these N inns can you see the ocean?

Submission attempts (in order):
n = int(input())
h = list(map(int,input().split(' ')))
ans = 1
i = 1
h0 = h[0]
while i < n:
    if h[i] > h0:
        ans += 1
        h0 = h[i]
    i += 1
print(ans)

n = int(input())
h = list(map(int,input().split(' ')))
ans = 1
i = 1
h0 = h[0]
while i < n:
    if h[i] > h0:
        ans += 1
        h0 = h[i]
    i += 1
print(ans)

n = int(input())
h = list(map(int,input().split(' ')))
ans = 1
i = 1
h0 = h[0]
while i < n:
    if h[i] > h0:
        ans += 1
        h0 = h[i]
    i += 1
print(ans)

n = int(input())
h = list(map(int,input().split(' ')))
ans = 1
i = 1
h0 = h[0]
while i < n:
    if h[i] > h0:
        ans += 1
        h0 = h[i]
    i += 1
print(ans)

n = int(input())
h = list(map(int,input().split(' ')))
ans = 1
i = 1
h0 = h[0]
while i < n:
    if h[i] >= h0:
        ans += 1
        h0 = h[i]
    i += 1
print(ans)

n = int(input())
h = list(map(int,input().split(' ')))
ans = 1
i = 1
h0 = h[0]
while i < n:
    if h[i] >= h0:
        ans += 1
        h0 = h[i]
    i += 1
print(ans)

n = int(input())
h = list(map(int,input().split(' ')))
ans = 1
i = 1
h0 = h[0]
while i < n:
    if h[i] >= h0:
        ans += 1
        h0 = h[i]
    i += 1
print(ans)

n = int(input())
h = list(map(int,input().split(' ')))
ans = 1
i = 1
h0 = h[0]
while i < n:
    if h[i] >= h0:
        ans += 1
        h0 = h[i]
    i += 1
print(ans)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted

Accepted

Accepted

Accepted
Problem: There are N mountains ranging from east to west, and an ocean to the west.  At the top of each mountain, there is an inn. You have decided to choose where to stay from these inns.  The height of the i-th mountain from the west is H_i.  You can certainly see the ocean from the inn at the top of the westmost mountain.  For the inn at the top of the i-th mountain from the west (i = 2, 3, ..., N), you can see the ocean if and only if H_1 \leq H_i, H_2 \leq H_i, ..., and H_{i-1} \leq H_i.  From how many of these N inns can you see the ocean?

Submission attempts (in order):
n=int(input())
m=list(map(int,input().split()))
ans=0

for i in range(n+1):
  if m[0] <= m[i]:
    ans += 1
print(ans)

n=int(input())
m=list(map(int,input().split()))
ans=0

for i in range(n+1):
  if m[0] <= m[i]:
    ans += 1
print(ans)

n=int(input())
m=list(map(int,input().split()))
ans=0

for i in range(n+1):
  if m[0] <= m[i]:
    ans += 1
print(ans)

n=int(input())
m=list(map(int,input().split()))
ans=0

for i in range(n+1):
  if m[0] <= m[i]:
    ans += 1
print(ans)

n=int(input())
m=list(map(int,input().split()))
ans=1

for i in range(1,n):
  if max(m[:i]) <= m[i]:
    ans += 1
print(ans)

n=int(input())
m=list(map(int,input().split()))
ans=1

for i in range(1,n):
  if max(m[:i]) <= m[i]:
    ans += 1
print(ans)

n=int(input())
m=list(map(int,input().split()))
ans=1

for i in range(1,n):
  if max(m[:i]) <= m[i]:
    ans += 1
print(ans)

n=int(input())
m=list(map(int,input().split()))
ans=1

for i in range(1,n):
  if max(m[:i]) <= m[i]:
    ans += 1
print(ans)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted

Accepted

Accepted

Accepted
Problem: There are N mountains ranging from east to west, and an ocean to the west.  At the top of each mountain, there is an inn. You have decided to choose where to stay from these inns.  The height of the i-th mountain from the west is H_i.  You can certainly see the ocean from the inn at the top of the westmost mountain.  For the inn at the top of the i-th mountain from the west (i = 2, 3, ..., N), you can see the ocean if and only if H_1 \leq H_i, H_2 \leq H_i, ..., and H_{i-1} \leq H_i.  From how many of these N inns can you see the ocean?

Submission attempts (in order):
n=int(input())
h=list(map(int,input()))
ans=1
for i in range(1,n):
  if max(h[:i])<h[i]:
    ans+=1
print(ans)

n=int(input())
h=list(map(int,input()))
ans=1
for i in range(1,n):
  if max(h[:i])<h[i]:
    ans+=1
print(ans)

n=int(input())
h=list(map(int,input().split()))
ans=1
for i in range(1,n):
  if max(h[:i])<h[i]:
    ans+=1
print(ans)

n=int(input())
h=list(map(int,input().split()))
ans=1
for i in range(1,n):
  if max(h[:i])<h[i]:
    ans+=1
print(ans)

n=int(input())
h=list(map(int,input()))
ans=1
for i in range(1,n):
  if max(h[:i])<h[i]:
    ans+=1
print(ans)

n=int(input())
h=list(map(int,input()))
ans=1
for i in range(1,n):
  if max(h[:i])<h[i]:
    ans+=1
print(ans)

n=int(input())
h=list(map(int,input().split()))
ans=1
for i in range(1,n):
  if max(h[:i])<h[i]:
    ans+=1
print(ans)

n=int(input())
h=list(map(int,input().split()))
ans=1
for i in range(1,n):
  if max(h[:i])<h[i]:
    ans+=1
print(ans)

n=int(input())
h=list(map(int,input().split()))
ans=1
for i in range(1,n):
  if max(h[:i])<=h[i]:
    ans+=1
print(ans)

n=int(input())
h=list(map(int,input().split()))
ans=1
for i in range(1,n):
  if max(h[:i])<=h[i]:
    ans+=1
print(ans)

n=int(input())
h=list(map(int,input().split()))
ans=1
for i in range(1,n):
  if max(h[:i])<=h[i]:
    ans+=1
print(ans)

n=int(input())
h=list(map(int,input().split()))
ans=1
for i in range(1,n):
  if max(h[:i])<=h[i]:
    ans+=1
print(ans)

Verdicts: Runtime Error

Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

Runtime Error

Wrong Answer

Wrong Answer

Accepted

Accepted

Accepted

Accepted