Problem:


Score : 200 points

Problem Statement

You are given an integer sequence A of length N.
Find the maximum absolute difference of two elements (with different indices) in A.

Constraints

2 \leq N \leq 100

1 \leq A_i \leq 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 A_2 ... A_N

Output

Print the maximum absolute difference of two elements (with different indices) in A.

Sample Input 1

4
1 4 6 3

Sample Output 1

5

The maximum absolute difference of two elements is A_3-A_1=6-1=5.

Sample Input 2

2
1000000000 1

Sample Output 2

999999999

Sample Input 3

5
1 1 1 1 1

Sample Output 3

0



Sample input:
4
1 4 6 3


Sample output:
5

Submission status: Wrong Answer

Solution code:
n=int(input("input N ,")) #Nを入力
lista=input("input A ,").split() #Aを入力
p=int(lista[0])#p最小値
q=int(lista[0])#q最大値
for i in range(1,n):
    k=int(lista[i])
    if k<=p:
        p=k
    elif k>=q:
        q=k
print(int(q)-int(p))

Submission status: Wrong Answer

Solution code:
count=input()
list=input().rstrip().split(" ")
list_1=[int(s) for s in list]
sa=(max(list_1)-min(list_1))

Submission status: Wrong Answer

Solution code:
count=input()
list=input().rstrip().split(" ")
list_1=[int(s) for s in list]
list2= sorted(list_1)
sa=(max(list2)-min(list2))

Submission status: Wrong Answer

Solution code:
count=input()
list=input().rstrip().split(" ")
list2= sorted(list)
sa=(int(list2[0])-int(list2[int(count)-1]))
if sa<0:
  print(-1*int(sa))
else:
  print(int(sa))

Submission status: Wrong Answer

Solution code:
count=input()
list=input().rstrip().split(" ")
list2= sorted(list)
sa=(int(list2[0])-int(list2[int(count)-1]))
if sa<0:
  print(-1*int(sa))
else:
  print(sa)

Submission status: Wrong Answer

Solution code:
count=input()
list=input().rstrip().split(" ")
sa = int(list[0])-int(list[1])
for i in range(len(list)):
  if sa<(int(list[i-1])-int(list[i])):
    sa=(int(list[i-1])-int(list[i]))
if sa<0:
  print(-1*sa)
else:
  print(sa)

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split(" ")))

min_v=1
max_v=1

for i in range(n):
  if min_v > l[i]:
    min_v=l[i]
  if max_v < l[i]:
    max_v=l[i]
print(max_v-min_v)

Submission status: Wrong Answer

Solution code:
N = int(input())
nums = list(map(int,input().split(' ')))

max = 0
min = 1000000000

for i in nums:
    if i>max:
        max = i
    elif i<min:
        min = i
    
print(max-min)

Submission status: Wrong Answer

Solution code:
N = int(input())
nums = list(map(int,input().split(' ')))

max = 0
min = 0

for i in nums:
    if i>max:
        max = i
    elif i<min:
        min = i
    
print(max-min)

Submission status: Wrong Answer

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

max_num = 1
min_num = 10**9

for i in range(n):
    if max_num < a[i]:
        max_num = a[i]
    elif min_num > a[i]:
        min_num = a[i]

print(max_num-min_num)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

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

ans = 0
for i in range(len(a)-1):
    ans = max(ans, abs(a[i]-a[i+1]))

print(ans)

Submission status: Wrong Answer

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

pre_a=a[0]
max_diff=0
for aa in a[1:]:
  d=abs(pre_a-aa)
  max_diff=max(max_diff,d)
print(max_diff)

Submission status: Wrong Answer

Solution code:
s = input()
n = int(s)

arrays = []

v = input().split()
for i in range(n):
    arrays.append(v[i])

arrays.sort()

a = int(arrays[0])

b = int(arrays.pop())

answer = abs(b - a)

print(answer)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))

mx_diff = 0
for i in range(1, N):
    if abs(a[i-1]-a[i]) > mx_diff:
        mx_diff = abs(a[i-1]-a[i])
print(mx_diff)

Submission status: Wrong Answer

Solution code:
N = int(input())
MM = input().split()
maxi =  1
mini = 10**9
for i in MM:
  if int(i) >maxi:
    maxi = int(i)
  elif int(i) < mini :
    mini = int(i)
ans = abs(maxi -mini)
print(ans)

Submission status: Wrong Answer

Solution code:
li=list(map(int,input().split()))
print(max(li)-min(li))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
print(a)
print(a[n-1]-a[0])

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a1 = sorted(a)
print(a1[-1] -a[0])

Submission status: Wrong Answer

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

Max=0
Min=10**9

for i in range(n):
    print(i)
    if(Max<a[i]):
        Max=a[i]
    if(Min>a[i]):
        Min=a[i]

print(abs(Max-Min))

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
max=0

for i in range(1,N-1):
  for j in range(i+1,N):
    if abs(A[i]-A[j])>=max:
      max=abs(A[i]-A[j])
print(max)

Submission status: Wrong Answer

Solution code:
s = list(map(int, input().split()))
print(max(s) - min(s))

Submission status: Wrong Answer

Solution code:
N = input()
list = sorted(map(int, input().split()))
print(list[-1] - list[-2])

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(input().split())
j = max(A)
k = min(A)
print(abs(int(j) - int(k)))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int , input().split()))
ans = 0
prev = a[0]
for ai in a:
    ans = max(ans, abs(prev - ai))
    prev = ai
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
max = 0
for i in range(len(a)):
    for j in range(i+1, len(a)):
        print(i,j)
        if abs(a[i] - a[j]) > max:
            max = abs(a[i] - a[j])
print(max)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
max = 0
for i in range(len(a)+1):
  for j in range(i+1, len(a)):
    print(i, j)
    if max < abs(a[i] - a[j]):
      max = abs(a[i] - a[j])
print(max)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
max = 0
for i in range(len(a)):
  for j in range(i+1, len(a)-i):
    if max < abs(a[i] - a[j]):
      max = abs(a[i] - a[j])
print(max)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
d=[]
import itertools
for v in itertools.combinations(a,2):
    #print(v)
    d.append(abs(v[0]-v[1]))
print(min(d))

Submission status: Wrong Answer

Solution code:
def actual(N, a_list):
    num_min = 1
    num_max = 1

    for i in a_list:
        if i < num_min:
            num_min = i
        else:
            num_max = i

    return num_max - num_min

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

print(actual(N, a_list))

Submission status: Wrong Answer

Solution code:
def actual(N, a_list):
    num_min = 1
    num_max = 1

    for i in a_list:
        if i < num_min:
            num_min = i
        if i > num_max:
            num_max = i

    return num_max - num_min

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

print(actual(N, a_list))

Submission status: Wrong Answer

Solution code:
N=input()
a=input().split()
a=[int(x) for x in a]
print(a)
t=0
for i in range(len(a)-1):
    for j in range(i+1, len(a)):
        if abs(a[i]-a[j])>t:
            t=abs(a[i]-a[j])
        
print(t)

Submission status: Wrong Answer

Solution code:
N=input()
a=input().split()
a=[int(x) for x in a]
print(a)
t=0
for i in range(len(a)):
    for j in range(i+1, len(a)):
        if abs(a[i]-a[j])>t:
            t=abs(a[i]-a[j])
        
print(t)

Submission status: Wrong Answer

Solution code:
n = list(map(int,input().split()))
maxi = max(n)
mini = min(n)
print(maxi - mini)

Submission status: Wrong Answer

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

max = 0
for i in range(n):
  if i != 0:
    for j in range(i - 1):
      max1 = abs(a[i] - a[j])
      if max1 > max:
        max = max1

print(max)

Submission status: Wrong Answer

Solution code:
_ = input()
a = sorted(map(int, input().split()))
print(a[0]-a[-1])

Submission status: Wrong Answer

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

lis = []
for i in range(len(A)):
  for j in range(len(A)):
    lis.append(abs(A[i]-A[j]))

max(lis)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
ans=0

for i in range(0,N):
  for j in range(i,N):
    ans = max(abs(i-j),ans)
    
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=input().split()

print(int(max(a))-int(min(a)))

Submission status: Wrong Answer

Solution code:
input()
min = 101
max = 0
list = list(map(int,input().split()))
for i in list:
    if min > i:
        min = i
    if max < i:
        max = i
print(max - min)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(input().split())

print(int(max(A))-int(min(A)))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
maxi = 0
for i in range(N-1):
  maxi = max(maxi,A[i]-A[i+1])
print(maxi)

Submission status: Wrong Answer

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

for i in a:
    if i < 0:
        i *= -1

a.sort()
print(a[0]-a[-1])

Submission status: Wrong Answer

Solution code:
a=list(map(int,input().split()))
print(max(a)-min(a))

Submission status: Wrong Answer

Solution code:
n = input()
A = list(input().split())
A.sort()
print(int(A[-1])-int(A[0]))

Submission status: Wrong Answer

Solution code:
N = int(input())
lst = [int(n) for n in input().split(" ")]
val_max = 1
val_min = 10**9
for i in lst:
  if val_max < i:
    val_max = i
  elif val_min > i:
    val_min = i
    
print(val_max-val_min)

Submission status: Wrong Answer

Solution code:
N = int(input())
lst = [int(n) for n in input().split(" ")]
val_max = 1
val_min = 10**9
for i in range(0,N-1):
  if val_max < lst[i]:
    val_max = lst[i]
  elif val_min > lst[i]:
    val_min = lst[i]
    
print(val_max-val_min)

Submission status: Wrong Answer

Solution code:
N = int(input())
lst = [int(n) for n in input().split(" ")]
val_max = 1
val_min = 10**9
for i in range(0,N):
  if val_max < lst[i]:
    val_max = lst[i]
  elif val_min > lst[i]:
    val_min = lst[i]
    
print(val_max-val_min)

Submission status: Wrong Answer

Solution code:
N = int(input())
lst = [int(n) for n in input().split(" ")]
val_max = 0
val_min = 0
for i in range(0,N):
  if val_max < lst[i]:
    val_max = lst[i]
  elif val_min > lst[i]:
    val_min = lst[i]
print(val_max-val_min)

Submission status: Wrong Answer

Solution code:
N = int(input())
lst = [int(n) for n in input().split(" ")]
val_max = 0
val_min = 0
for i in range(0,N):
  if val_max < i:
    val_max = i
  elif val_min > i:
    val_min = i
print(val_max-val_min)

Submission status: Wrong Answer

Solution code:
try:
    N = int(input())
    a = list(map(int, input().split()))
    max = 1
    min = 1
    for i in range(N):
    #    print(a[a_-1])
    #    print(type(a[a_-1]))
        if max<a[i]:
            max = a[i]
        if min>a[i]:
            min = a[i]
    print(max-min)
except EOFError:
    pass

Submission status: Wrong Answer

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

maxi = A[0]
mini = A[0]
for i in range(N-1):
    if A[i] < A[i+1]:
        maxi = A[i+1]
    if A[i] > A[i+1]:
        mini = A[i+1]
print(maxi-mini)

Submission status: Wrong Answer

Solution code:
a=sorted(list(map(int,input().split())))
print(a[len(a)-1]-a[0])

Submission status: Wrong Answer

Solution code:
N = int(input())
A = input().split()
A_max = int(max(A))
A_min = int(min(A))
A_div = A_max - A_min
print("{}".format(A_div))

Submission status: Wrong Answer

Solution code:
A = list(map(int, input().split()))
print(max(A)-min(A))

Submission status: Wrong Answer

Solution code:
n=int(input())
ln=[int(n) for n in map(int,input().split())]
print(max(ln)-max(ln))

Submission status: Wrong Answer

Solution code:
l = sorted(list(map(int, input().split())))
ans = l[-1] - l[0]
print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import combinations

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

combs = combinations(A, 2)

ret = 0
for comb in combs:
    if abs(comb[0] - 1) > ret:
        ret = abs(comb[0] - 1)

print(ret)

Submission status: Wrong Answer

Solution code:
a = [input() for i in range(2)]
b = a[1].split()
print(int(max(b))-int(min(b)))

Submission status: Wrong Answer

Solution code:
a = [input() for i in range(2)]
b = a[1].split(" ")
print(int(max(b))-int(min(b)))

Submission status: Wrong Answer

Solution code:
a = list(map(int, input().split()))
print(max(a)-min(a))

Submission status: Wrong Answer

Solution code:
n = int(input().strip())
arry = list(map(int,input().strip().split()))

min = arry[1]
max = arry[1]

print  (len(arry))

for i in range(len(arry)):
  if arry[i] < min:
    min = arry[i]
  if arry[i] > max:
    max = arry[i]

print (max-min)

Submission status: Wrong Answer

Solution code:
"""
author : halo2halo
date : 25,Oct,2019
"""

import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

N = int(readline().rstrip())
lis = list(map(int, readline().rstrip().split()))
sorted(lis)

print(lis[-1]-lis[0])

Submission status: Wrong Answer

Solution code:
n=int(input())
li=input().split()
li.sort()
print(int(li[n-1])-int(li[0]))

Submission status: Wrong Answer

Solution code:
n = int(input())
li = list(map(int,input().split()))
M = 0
for i in range(n):
        for j in range(i,n - i):
                a = abs(li[i] - li[j])
                if a > M:
                        M = a
print(M)

Submission status: Wrong Answer

Solution code:
n = int(input())
li = list(map(int,input().split()))
M = 0
for i in range(len(li)):
        for j in range(i,len(li) - i):
                a = abs(li[i] - li[j])
                if a > M:
                        M = a
print(M)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

A_s = set(A)
A.sort()
A.reverse()

a1 = A[0]
a2 = A[1]


print(a1-a2)

Submission status: Wrong Answer

Solution code:
N = int(input())
Nlist = input().split()

wMax = 1
wMin = 1
for value in Nlist:
    if int(value) > wMax:
        wMax = int(value)
    if int(value )< wMin:
        wMin = int(value)

print(abs(wMax - wMin))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(1, n):
    ans = max(abs(a[i] - a[i - 1]), ans)
print(ans)

Submission status: Wrong Answer

Solution code:
s = sorted(map(int,input().split()))
print(s[-1]-s[0])

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
from collections import  Counter
import statistics
import math
stdin = sys.stdin

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

n = ni()
a_li = na()
for i in range(n):
    a_li[i] = a_li[i] - (i + 1)
m1 = statistics.median_high(a_li)
#m2 = statistics.median_high(a_li)
ans1 = 0
#ans2 = 0
for i in range(n):
    ans1 += abs(a_li[i] - m1)
    #ans2 += abs(a_li[i] - m2)
print(ans1)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=map(int,input().split())
ans=0
for i in a:
    for s in a:
        x=abs(s-i)
        if x>ans:
            ans=x
print(ans)

Submission status: Wrong Answer

Solution code:
n,a=open(0);s=sorted(map(int,a.split()));print(s[-1]-s[1])

Submission status: Wrong Answer

Solution code:
N = list(map(float, input().split()))

print(int(abs(max(N) - min(N))))

Submission status: Wrong Answer

Solution code:
N = list(map(int, input().split()))

print(abs(max(N) - min(N)))

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
lst = []
for i in range(N-1):
    for j in range(i+1):
        lst.append(abs(a[i]-a[j]))
print(max(lst))

Submission status: Wrong Answer

Solution code:
N = int(input())
list = input().split()

print(int(max(list)) - int(min(list)))

Submission status: Wrong Answer

Solution code:
x = sorted(map(int,input().split()))
print(abs(x[-1]-x[0]))

Submission status: Wrong Answer

Solution code:
n = int(input())
a_list = [int(i) for i in input().split()]
d_list =[]

for i in range(n):
	for j in range(n-i):
		print(i,n-j-1)
		d_list.append(abs(a_list[i]-a_list[n-j-1]))
		
print(max(d_list))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = input().split()
A = sorted(A)
print(int(A[N-1]) - int(A[0]))

Submission status: Wrong Answer

Solution code:
def INT(): return int(input())
def LIST(): return list(map(int, input().split()))


def main():
    N = INT()
    A = LIST()
    m = 0

    for i, a in enumerate(A):
        for j in range(N-i-1):
            if abs(a-A[j+1]) > m:
                m = abs(a-A[j+1])

    print(m)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

ans = 0
for i in range(n):
    for j in range(n-i):
        dist = abs(a[j] - a[i])
        if dist > ans:
            ans = dist

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

num = 1

while(N >= num*2):
    num *= 2

print(num)

Submission status: Wrong Answer

Solution code:
N = int(input())
getList = input().split(' ')
print(int(max(getList)) - int(min(getList)))

Submission status: Wrong Answer

Solution code:
N = list(map(int, input().split()))
print(max(N)-min(N))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = map(int, input().split())
diff = []

for ai in a:
    for aj in a:
        diff.append(abs(ai - aj))
print(max(diff))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
N = int(input())
A = [int(i) for i in range(N)]

max_ = max(A)
min_ = min(A)
print(max_ - min_)

Submission status: Wrong Answer

Solution code:
from sys import stdin

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

min_number = 10 ** 7
max_number = 0

for k in A:
    if k > max_number:
        max_number = k
    if k < min_number:
        min_number = k

print(max_number - min_number)

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-

def solve():
    N = input()
    A = list(map(int, input().split()))
    min_a = 0
    max_a = float("inf")
    for a in A:
        min_a = min(min_a, a)
        max_a = max(max_a, a)
    print(max_a - min_a)

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import numpy as np
import math
import re
n = int(input())
a = input()
a = re.split(" ",a)

ma = max(a)
mi = min(a)

print(abs(int(ma)- int(mi)))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import numpy as np
import math
import re
n = int(input())
a = input()
a = re.split(" ",a)

ma = max(a)
mi = min(a)

print(int(ma)- int(mi))

Submission status: Wrong Answer

Solution code:
n = int(input())
mx = 0

a = list(map(int, input().split()))
for i in range(len(a)):
    for j in range(len(a[i:])):
        mx = max(mx,abs(a[i] - a[j]))
print(mx)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input()
.split()))
min = 10^9
max = 1
for i in range(n):
    if a[i]<min:
        min = a[i]
    if a[i]>max:
        max = a[i]
print(max-min)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    s = input()
    a = [int(i) for i in s.split()]
    mina = min(a)
    maxa = max(a)
    print(maxa - mina)

Submission status: Wrong Answer

Solution code:
A = list(map(int, input().split()))

A = sorted(A)
print(A[-1] - A[0])

Submission status: Wrong Answer

Solution code:
N = int(input())
list =  [int(i) for i in input().split()]
print(list)
print(max(list) - min(list))

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
# print(max(A) - min(A))
min = 10**10
max = -100
for i in A:
  if (min >= i):
    min = i
  elif (max <= i):
    max = i

print(max - min)

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
# print(max(A) - min(A))
min = 10000000000
max = -100
for i in A:
  if (min > i):
    min = i
  elif (max < i):
    max = i

print(max - min)

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
# print(max(A) - min(A))
min = 100000001
max = 0
for i in A:
  if (min > i):
    min = i
  elif (max < i):
    max = i

print(max - min)

Submission status: Wrong Answer

Solution code:
N = input()
string_list = input().rstrip().split()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = map(int, input().split())
max = 0
min = 0
for i in A:
  if max < i:
     max = i
  if min > i:
    min = i
print("{}".format(max - min))

Submission status: Wrong Answer

Solution code:
from sys import stdin
data=[int(x) for x in stdin.readline().rstrip().split()]
data=sorted(data)
print(abs(data[0]-data[-1]))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = input().split(" ")
B = [int(n) for n in A]

m = 0
M = 0
for b in B:
  if b < m:
    m = b
  
  if b > M:
    M = b

print(M-m)

Submission status: Wrong Answer

Solution code:
N = input()
Ai = list(input().split())

print(int(max(Ai)) - int(min(Ai)))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n):
    for j in range(n):
        if i!=j and abs(a[i]-a[j])>=ans:
            ans=a[i]-a[j]
print(ans)

Submission status: Wrong Answer

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

mn = 10**9+1 # 数列Aの最小値
mx = 0       # 数列Aの最大値

for v in A:
  if v < mn:
    mn = v   # 最小値を更新
  else:
    mx = v   # 最大値を更新

print(mx-mn)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
max=0
for i in range(n-1):
  if abs(a[i]-a[i+1])>max:
    max=abs(a[i]-a[i+1])
print(max)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = input().split()
l.sort()
print(abs(int(l[-1]) - int(l[0])))

Submission status: Wrong Answer

Solution code:
n = int(input())
l = input().split()
l.sort()
print(abs(int(l[0]) - int(l[-1])))

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[int(i) for i in input().split()]
maxv=A[0]
minv=A[1]-A[0]
for i in range(N):
  maxv=max(maxv,A[i]-minv)
  minv=min(minv,A[i])
print(maxv)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 26 23:53:42 2019

@author: yuta
"""

def maxdif(n,a):
    b = sorted(a)
    c = int(b[n-1]) - int(b[0])
    print(c)

x = int(input())
y = input().split()

maxdif(x,y)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in range(n)]
print(max(a) - min(a))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
l = []
for i in range(len(a)):
    for j in range(i,len(a)):
        l.append(abs(a[i]-a[j]))
print(max(a))

Submission status: Wrong Answer

Solution code:
n=int(input())
A=list(map(int,input().split()))
A=sorted(A)
ans=A[n-1]-A[1]
print(ans)

Submission status: Wrong Answer

Solution code:
input()
A = map(int, input().split())
print(max([abs(i - j) for i in A for j in A]))

Submission status: Wrong Answer

Solution code:
# Maximum Difference
import sys

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

res = [0 for _ in range(N*N)]
for i in range(N) :
    for j in range(N) :
        res[i + j] = abs(A[i] - A[j])

print(max(res))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
b = []
for i in range(n):
    b.append(abs(int(a[i-1]) - int(a[i])))
print(max(b))

Submission status: Wrong Answer

Solution code:
N = int(input())
A_list = [int(a) for a in input().split()]
A_list.sort()
print(max([A_list[i+1]-A_list[i] for i in range(N-1)]))

Submission status: Wrong Answer

Solution code:
N = int(input())
a = map(int,raw_input().split())

print a

amax = (max(a))
amin = (min(a))

res = abs(amax-amin)
print res

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    nums = input().split()
    print(nums)
    for i in range(len(nums)):
        nums[i] = int(nums[i])
    print(nums)
    max_diff = 0
    for i in range(len(nums)):
        for j in range(i, len(nums)):
            diff = abs(nums[i] - nums[j])
            if diff > max_diff:
                max_diff = diff
    print(max_diff)

main()

Submission status: Wrong Answer

Solution code:
n = int(input())
nl = sorted(list(map(int, input().split())), reverse=True)
print(nl[0] - nl[1])

Submission status: Wrong Answer

Solution code:
input;n=list(map(int,input().split()))
print(max(n) - min(n))

Submission status: Wrong Answer

Solution code:
a = list(map(int, input().split()))
a.sort()
print(a[-1] - a[0])

Submission status: Wrong Answer

Solution code:
value = []
for part in input().split():
    value.append(int(part))

print(max(value) - min(value))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input().split()
print(int(max(s)) - int(min(s)))

Submission status: Wrong Answer

Solution code:
a=input()
a=sorted(map(int,input().split()))
print(a[-1]-a[1])

Submission status: Wrong Answer

Solution code:
a=input()
a=sorted(map(int,input().split()))
print(a[-1]-a[1])

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(input() .split())
a = int(max(A))
b = int(min(A))
print(abs(a - b))

Submission status: Wrong Answer

Solution code:
n=int(input())
A=list(map(int,input().split()))
A.sort()
print(A)
print(str(A[n-1]-A[0]))

Submission status: Wrong Answer

Solution code:
N = int(input())
lists = [int(i) for i in input().split()]
hoge = lists[0]
cla = 0
for x in lists:
    c = abs(x - hoge)
    if (c > cla):
        cla = c
    hoge = min(hoge, x)
print(cla)

Submission status: Wrong Answer

Solution code:

N = int(input())
print(N)
list_A = [int(str_A) for str_A in input().split(" ")]
print(list_A)

print(max(list_A) - min(list_A))

Submission status: Wrong Answer

Solution code:
n = input()
aString = input()
aList = aString.split(" ")
aList.sort()

print(int(aList[int(n) - 1]) - int(aList[0]))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
ma = 0
mi = 100100100
for i in a:
    ma = max(i,ma)
    mi = min(i,mi)
print(ma-mi)

Submission status: Wrong Answer

Solution code:
a = list(map(int, input().split()))
max = 0

for i in range(len(a)-1):
    if max < abs(a[i]-a[i+1]):
        max = abs(a[i]-a[i+1])

print(max)

Submission status: Wrong Answer

Solution code:
n = int(input())

k = input().split()
print(int(max(k)) - int(min(k)))

Submission status: Wrong Answer

Solution code:
n = int(input()) 
row = input().split()
max = row[0]
min = row[0]


for i in range(n):
        if(max < row[i]):
            max = row[i]

for i in range(n):
        if(min > row[i]):
            min = row[i]


print(int(max)-int(min))

Submission status: Wrong Answer

Solution code:
n = int(input()) 
row = input().split()
max = row[0]
min = row[0]


for i in range(n-1):
        if(max < row[i]):
            max = row[i]

for i in range(n-1):
        if(min > row[i]):
            min = row[i]


print (int(max)-int(min))

Submission status: Wrong Answer

Solution code:
n = int(input()) 
row = input().split()
max = row[0]
min = row[0]


for i in range(n-1):
        if(max < row[n-1]):
            max = row[i]

for i in range(n-1):
        if(min > row[n-1]):
            min = row[i]


print (int(max)-int(min))

Submission status: Wrong Answer

Solution code:
n = int(input()) 
row = input().split()
max = row[0]
min = row[0]

for j in range(n-1):
    for i in range(n-1):
        if(row[j] < row[i+1]):
            max = row[i+1]


    for i in range(n-1):
        if(min > row[n-1]):
            min = row[n-1]


print (int(max)-int(min))

Submission status: Wrong Answer

Solution code:
n = int(input()) 
row = input().split()
max = row[0]
min = row[0]

for i  in range(n-1):
    if(row[i] < row[i+1]):
        max = row[i+1]

for i in range(n-1):
    if(row[i] > row[i+1]):
        min = row[i+1]


print(int(max)-int(min))

Submission status: Wrong Answer

Solution code:
n = int(input()) 
row = input().split()
max = row[0]
min = row[0]

for i  in range(n-1):
    if(row[i] < row[i+1]):
        max = row[i+1]

for i in range(n-1):
    if(row[i] > row[i+1]):
        min = row[i+1]


print(int(max)-int(min))

Submission status: Wrong Answer

Solution code:
def B():
    n = int(input())
    a = input().split()
    
    if(len(a) != n):
        exit(1)

    i_max = 0
    i_min = 1000000001
    for i in a:
        k = int(i)
        if (i_max < k):
                i_max = k
        if (i_min > k):
                i_min = k
    print(i_max,i_min)
    print(abs( i_max - i_min))

if __name__ =='__main__':
    B()

Submission status: Wrong Answer

Solution code:
N = input()
A = input()
b = A.split(" ")
b.sort()

print(int(b[-1])-int(b[0]))

Submission status: Wrong Answer

Solution code:
N = int(input())
a = input().rstrip().split()

print(abs(int(max(a))-int(min(a))))

Submission status: Wrong Answer

Solution code:

Submission status: Wrong Answer

Solution code:
#-*-coding:utf-8-*-

def main():
    #入力
    N = int(input())
    lists = list(map(int, input().split()))

    #変数
    max_element = 0

    #各要素の差を求め前より大きかったらmax_elementに格納
    for i in range(1, N):
        diff = lists[i] - lists[i-1]
        if diff > max_element:
            max_element = diff

    print(max_element)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
Alist = [int(i) for i in input().split()]

Alist.reverse()
print(Alist[0]-Alist[N-1])

Submission status: Wrong Answer

Solution code:
while True:
    try:
        n = int(input())
        num = list(map(int,input().split()))
        for ind in range(len(num)):
            num[ind] -= ind+1
        d = sum(num)//n
        print(sum(abs(i-d) for i in num))
    except:
        break

Submission status: Wrong Answer

Solution code:
n = int(input())
num = list(map(int,input().split()))
for ind in range(len(num)):
    num[ind] -= ind+1
d = sum(num)//n
print(sum(abs(i-d) for i in num))

Submission status: Wrong Answer

Solution code:
n = input()
num_list = list(map(int, input().split()))
print(round(max(num_list) - (min(num_list) ** -1)))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# 桁数の入力
a = int(input())
# スペース区切りの整数の入力
b = input().split()
b.sort()
min = b[0]
b.reverse()
max = b[0]
print(int(max)-int(min))

Submission status: Wrong Answer

Solution code:
N = input()
N = int(N)
AA = input().split()

top = 0
low = 0

Alist = list()
for A in Alist:
    Alist.append(A)
    
for i in range(1,len(Alist)):
    
    if Alist[i] > top:
        top = max(A)
    if Alist[i] < low:
        low = min(A)
        
num = int(top) - int(low)
    
print(num)

Submission status: Wrong Answer

Solution code:
N = input()
N = int(N)
AA = input().split()
for A in AA:

    top = max(A)
    low = min(A)
    num = int(top) - int(low)
    
print(num)

Submission status: Wrong Answer

Solution code:
n = input()
a = input().split()
print(int(max(a)) - int(min(a)))

Submission status: Wrong Answer

Solution code:
n = input()
a = input().split(sep=" ")

mx = max(a)
mn = min(a)

print(int(mx) - int(mn))