Problem:


Score : 200 points

Problem Statement

Takahashi has N days of summer vacation.

His teacher gave him M summer assignments. It will take A_i days for him to do the i-th assignment.

He cannot do multiple assignments on the same day, or hang out on a day he does an assignment.

What is the maximum number of days Takahashi can hang out during the vacation if he finishes all the assignments during this vacation?

If Takahashi cannot finish all the assignments during the vacation, print -1 instead.

Constraints

1 \leq N \leq 10^6

1 \leq M \leq 10^4

1 \leq A_i \leq 10^4

Input

Input is given from Standard Input in the following format:

N M
A_1 ... A_M

Output

Print the maximum number of days Takahashi can hang out during the vacation, or -1.

Sample Input 1

41 2
5 6

Sample Output 1

30

For example, he can do the first assignment on the first 5 days, hang out on the next 30 days, and do the second assignment on the last 6 days of the vacation. In this way, he can safely spend 30 days hanging out.

Sample Input 2

10 2
5 6

Sample Output 2

-1

He cannot finish his assignments.

Sample Input 3

11 2
5 6

Sample Output 3

0

He can finish his assignments, but he will have no time to hang out.

Sample Input 4

314 15
9 26 5 35 8 9 79 3 23 8 46 2 6 43 3

Sample Output 4

9



Sample input:
41 2
5 6


Sample output:
30

Submission status: Wrong Answer

Solution code:
n, m= map(int,input().split())
lista=[]
eq2=0
eq=0
#lista= list(map(int,input().split()))

for x in input().split():
	x= int(x)
	lista.append(x)
	eq2+=x

eq= n-eq2
if eq<=n:
	print(eq)
else:
	print('-1')

Submission status: Wrong Answer

Solution code:
n, m= map(int,input().split())
lista=[]
sum=0
eq=0
#lista= list(map(int,input().split()))

for x in input().split():
	x= int(x)
	lista.append(x)
	sum+=x

eq= n-sum
if eq<<n:
	print(eq)
elif eq==0:
	print('0')
else:
	print('-1')

Submission status: Wrong Answer

Solution code:
n, m= map(int,input().split())
lista=[]
sum=0
eq=0
#lista= list(map(int,input().split()))

for x in input().split():
	x= int(x)
	lista.append(x)
	sum+=x

eq= n-sum
if eq<=n:
	print(eq)
else:
	print('-1')

Submission status: Wrong Answer

Solution code:
arr=list(map(int,input().rstrip().split()))
N=arr[0]
M=arr[1]
arr=list(map(int,input().rstrip().split()))
summ=0
for i in range(M) :
    summ+=arr[i]
if summ>=N :
    print(-1)
else :
    print(N-summ)

Submission status: Wrong Answer

Solution code:
arr=list(map(int,input().rstrip().split()))
N=arr[0]
M=arr[1]
arr=list(map(int,input().rstrip().split()))
summ=0
for i in range(M) :
    summ+=arr[i]
if summ>=N :
    print(-1)
else :
    print(N-summ)

Submission status: Wrong Answer

Solution code:
temp=list(map(int,input().rstrip().split()))
N=temp[0]
M=temp[1]
arr=list(map(int,input().rstrip().split()))
summ=0
for i in range(M) :
    summ+=arr[i]
if summ>=N :
    print(-1)
else :
    print(N-summ)

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
c = [int(x) for x in input().split()]
print(c,len(c))
csum = 0
for i in range(len(c)):
    csum = csum + c[i]
if a>=csum:
    print(a-csum)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
m,n=map(int,input().split())
s=list(map(int,input().split()))
sum_s=sum(s)
ans=m-sum_s
print(ans)

Submission status: Wrong Answer

Solution code:
a1, b = [int(s) for s in input().split(" ")]
S=0
a= [int(s) for s in input().split(" ")]
k=0
while(k< b and a1>=S  ):
    S=S+a[k]
    k=k+1
if a1-S> 0:
    print(a1-S)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
a1, b = [int(s) for s in input().split(" ")]
S=0
a= [int(s) for s in input().split(" ")]
for k in range(0,b):
    S=S+a[k]
if a1-S> 0:
    print(a1-S)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
A = list(map(int,input().split()))
free = n - sum(A)
if free <= 0:
  print(0)
else:
  print(int(free))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
A = list(map(int,input().split()))
free = n - sum(A)
if free < 0:
  print(0)
else:
  print(free)

Submission status: Wrong Answer

Solution code:
a1, b = [int(s) for s in input().split(" ")]
a = [int(h) for h in input().split()]
c=sum(a)
if a1-c> 0:
    print(a1-c)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:

def resolve():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    print(N - sum(A))

if __name__ == "__main__":
    resolve

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    ret = -1
    A_sum = sum(A)
    if not (A_sum < 0):
        ret = N - A_sum
    print(int(ret))

Submission status: Wrong Answer

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

a = 0
for i in range(n):
    a += a_list[i]

print(k - a)

Submission status: Wrong Answer

Solution code:
import math
a=input().split()
f=input().split()
s=0
fl=0
for i in range(0,int(a[1])):
    if(s>=int(a[0])):
        break
        fl+=1
if(fl!=1):
    print(int(a[0])-s)
else:
    print("-1")

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
a = list(map(int, input().split()))
study_sum = sum(a)
tem_ans = n - study_sum
print(tem_ans) if tem_ans > 0 else print(-1)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
a = list(map(int, input().split()))
study_sum = sum(a)
print(n-study_sum)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = list(map(int, input().split()))
SumA = sum(list(A))
if 1 <= N <= 10^6 and 1 <= M <= 10^4 and 1 <= SumA <= 10^4:
  R = N - SumA
  print(R)

Submission status: Wrong Answer

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


def solve(N: int, M: int, A: "List[int]"):
    a_sum = N
    for x in A:
        a_sum -= x

    if N < 0:
        print(-1)
    else:
        print(a_sum)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(M)]  # type: "List[int]"
    solve(N, M, A)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N, M = map(int, input().split())

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

    total_A = sum(A)

    ans = N - total_A

    if ans > 0:
        print('{}'.format(ans))
    else:
        print('{}'.format(-1))



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
l = [int(i) for i in input().split()]
if(n > sum(l)):
  print(n-sum(l))
else:
  print(-1)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = list(map(int, input().split()))
SumA = sum(A)
if 1 <= N <= 10^6 and 1 <= M <= 10^4 and 1 <= SumA <= 10^4:
  R = N - SumA
  print(R)

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
l = list(map(int, input().split()))
print(a - sum(l))

Submission status: Wrong Answer

Solution code:
N, M = input().split()

N = int(N)
M = int(M)

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


if sum(a) < N:
    print(N-sum(a))

if sum(a) > N:
    print(-1)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = input().split()
A_int = [int(n) for n in A]

rest = sum(A_int)
if N - rest >= 0:
  print(rest)
else:
  print(-1)

Submission status: Wrong Answer

Solution code:
inp=[int(x) for x in input().split()]
n,m=inp[0],inp[1]
arr=[int(x) for x in input().split()]
print(n-sum(arr))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = input().split()
A_int = [int(n) for n in A]

rest = sum(A_int)
if rest >= 0:
  print(rest)
else:
  print(-1)

Submission status: Wrong Answer

Solution code:
import sys

days, N = map(int, sys.stdin.readline().split())

a = list(map(int, sys.stdin.readline().split()))

print(days - sum(a))

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
A = map(int,input().split())
ans = N-sum(A)
print(-1) if ans>=N else print(ans)

Submission status: Wrong Answer

Solution code:
import math
n,m=map(int,input().split())
arr=list(map(int,input().split()))
if sum(arr)<n:
    print(-1)
else:
    print(n-sum(arr))

Submission status: Wrong Answer

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


def solve(N: int, M: int, A: "List[int]"):
    a_sum = N - sum(A)
    if N <0:
        print(-1)
    else:
        print(a_sum)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(M)]  # type: "List[int]"
    solve(N, M, A)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
a = [int(x) for x in input().split() if x != "0"]

if a[0]-(sum(a)-a[0]-a[1]) >= 0 :{
	print(a[0]-(sum(a)-a[0]-a[1]))
	}
else :{
	print(-1)
	}

Submission status: Wrong Answer

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

num = 0
for i in range(0, len(a)):
    num += int(a[i])

print(num)

target = n - num

if target >= 0:
    print(target)
else:
    print("-1")

Submission status: Wrong Answer

Solution code:
i = list(map(int, input().split()))
a_i = list(map(int, input().split()))
n = i[0]
m = i[1]
print(n - sum(a_i) if n >= n - sum(a_i) else -1)

Submission status: Wrong Answer

Solution code:
x, y = map(int,input().split())
arr = list(map(int, input().split()[:y]))
s = 0
for i in arr:
    s += i
re = x - s
if re > x:
    print(-1)
elif re == x:
    print(0)
else:
    print(re)

Submission status: Wrong Answer

Solution code:
user = list(eval(input().replace(" ",",")))
print(user)
sum = 0
for i in user:
    if i == user[0]:
        continue
    elif i == user[1]:
        continue
    sum = sum + i
print(sum - user[0])

Submission status: Wrong Answer

Solution code:
x, y = map(int,input().split())
arr = list(map(int, input().split()[:y]))
s = 0
for i in arr:
    s += i
re = x - s
if re > 0:
    print(re)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
c=input().split()
d=list(map(int,c))
e=sum(d)
f=a-e
print(f)

Submission status: Wrong Answer

Solution code:
import sys

def main():

	S = 0
	N,M = map(int, input().split())
	Lists = list(map(int, input().split()))
	
	count = 0
	
	for List in Lists:
		S += List
	
	
	print(N-S)
	
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
a=list(map(int,input().split()))
sam =  sum(int(i) for i in a)
SAM = n-sam
if SAM >0:
  print(SAM)
else:
  print(-1)

Submission status: Wrong Answer

Solution code:
#cording:utf-8

import math

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

s = [int(M) for M in input().split()]
print(N,M)
print(s)

sum(s)

Pr=N-sum(s)
if Pr<= N:
    print(Pr)

else:
    print(-1)

Submission status: Wrong Answer

Solution code:
l=[list(map(int,input().split())) for _ in range(2)]
homework=0
for i in range(l[0][1]):
    homework=homework+l[1][i]
print(homework)
free=l[0][0]-homework
if free<0:
    print(-1)
else:
    print(free)

Submission status: Wrong Answer

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

d = sum(c)

if a - d >= 1:
  print(a - d)
else:
  print("-1")

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
day_cost = [int(i) for i in input().split()]
holidays = N-sum(day_cost)

if holidays > 0:
    print(holidays)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
A = list(map(int, input().split()))
S=0
for a in A:
   S+=a
   
if N-S>0:
    print(N-S)   
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
n_vacations, n_an = list(map(int, input().split()))
an = list(map(int, input().split()))

print(n_vacations - sum(an))

Submission status: Wrong Answer

Solution code:
n,m =map(int,input().split())
a = list(map(int, input().split())) 
ans = n - sum(a)
print(ans)

Submission status: Wrong Answer

Solution code:
x, y = map(int,input().split())
arr = list(map(int, input().split()[:y]))
s = 0
for i in arr:
    s += i
print(x-s)

Submission status: Wrong Answer

Solution code:
n,m= map(int, input().split())
a = list(map(int, input().split()))
if m == len(a):
    print(n-sum(a))

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
c=input().split()
if sum(int(i) for i in c)>a:
    print(-1)
else:
    print(a-sum(int(i)) for i in c)

Submission status: Wrong Answer

Solution code:
def q2():
    N, M = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    sum_A = sum(A)
    if N > sum_A:
        ans = N - sum_A
    else:
        ans = 0
    print(ans)


if __name__ == '__main__':
    q2()

Submission status: Wrong Answer

Solution code:
n,m= map(int, input().split())
a = list(map(int, input().split()))
if m != len(a):
    pass
else:
    print(n-sum(a))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
a = list(map(int,input().split()))
print(n-sum(a))

Submission status: Wrong Answer

Solution code:
n, m =map(int, input().split())
a =list(map(int, input().split()))
print(n-sum(a))

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
lists0=list(map(int,input().split()))
lists1=lists0[0:M-1]
SUM=sum(lists1)
X=N-SUM
if X>=0:print(X)
else:print("-1")

Submission status: Wrong Answer

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

a=[]
a=list(input().split())


for k in range(m):

    n=n-int(a[k])

    if n < 0:
        break

print(n)

Submission status: Wrong Answer

Solution code:
import math
N, M = map(int,input().split())
L = list(map(int,input().split()))
max(-1,N-sum(L))

Submission status: Wrong Answer

Solution code:
n,m= map(int, input().split())
a = list(map(int, input().split()))
if m != len(a):
    pass
else:
    print(n-sum(a))

Submission status: Wrong Answer

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

mod = 10 ** 9 + 7

def comb(n, k):
    res = 1
    for i in range(n - k + 1, n + 1):
        res = res * i % mod
    for i in range(1, k + 1):
        res = res * pow(i, mod - 2, mod) % mod
    return res

calc = comb(n + 1, k)
ans = 0
ans += calc

for i in range(k + 1, n + 1):
    calc *= n + 2 - i
    calc //= i
    ans += calc

if k == n + 1:
    ans = 1
    
print(ans % mod)

Submission status: Wrong Answer

Solution code:
N, M = [int(x) for x in input().split()]
L = [int(x) for x in input().split()]

print(N - sum(L))

Submission status: Wrong Answer

Solution code:
L = list(map(int,input().split()))
N = L[0]
M = L[1]
O = L[2:]
max(-1,N-sum(O))

Submission status: Wrong Answer

Solution code:
n,m= map(int, input().split())
a = list(map(int, input().split()))
print(n-sum(a))

Submission status: Wrong Answer

Solution code:
import numpy as np

length,hm = map(int,input().split())

time = list(map(int,input().split()))
ans = length - np.sum(time)

if ans > 0:
  print(ans)
else:
  print(-1)

Submission status: Wrong Answer

Solution code:
s = [input() for i in range(2)] 
li1 = list(map(int, s[0].split()))
li2 = list(map(int, s[1].split()))
k=0;
for j in li2:
    k+=j
    print(k)
if li1[0] > k or li1[0] == k:
    print(li1[0]-k)
else:
    print('-1')

Submission status: Wrong Answer

Solution code:
m,n=[int(i) for i in input().split(' ')]
a_list=[int(i) for i in input().split(' ')]
play_m=m-sum(a_list)
print(play_m)

Submission status: Wrong Answer

Solution code:
n,m = input().split()
n = int(n)
m = int(m)
list1 = list(map(int,input().split()))
sum = 0
for i in range(0,m):
    sum = sum + list1[i]
print(n-sum)

Submission status: Wrong Answer

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

a=[]
a=list(input().split())


for k in range(0,m):

    n=n-int(a[k])

    if n >= 0:
        pass

    else:

        break

print(n)

Submission status: Wrong Answer

Solution code:
n,m=[int(x) for x in input().split()]
li=list(map(int,input().split()))
s=sum(li)
if s<n:
  print("-1")
elif s==n:
  print(0)
else:
  print(n-s)

Submission status: Wrong Answer

Solution code:
from sys import stdin
N,M = stdin.readline().rstrip().split()
a_list = stdin.readline().rstrip().split()
N,M = int(N),int(M)
for a in a_list:
  N-=int(a)
if(N>=0):
  print(N)
print('-1')

Submission status: Wrong Answer

Solution code:
import numpy as np
tmp = np.array(list(map(int, input().split())))
N = tmp[0]
M = tmp[1]
A = np.array(tmp[2:])
Needed = np.sum(A)
if Needed > N:
    print(str(-1))
else:
    print(str(N - Needed))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
s = sum(a)
print(n - s)

Submission status: Wrong Answer

Solution code:
a=input()
b=input()

aa=a.split(' ')
N=int(aa[0])
M=int(aa[1])

bb=b.split(' ')
sum=0
for b1 in bb:
    sum+=int(b1)

print(N-sum)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = map(int, input().split())
 
if(sum(A) == N):
  print('0')
elif(sum(A) < N):
  print(N - sum(A))
else:
  print('-1')

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
a = map(int, input().split())
c = 0
for b in a:
    c += b
if n - c <= 0:
    print(-1)
else:
    print(n-c)

Submission status: Wrong Answer

Solution code:
from sys import stdin
N,M = stdin.readline().rstrip().split()
a_list = stdin.readline().rstrip().split()
N,M = int(N),int(M)
for a in a_list:
  N-=int(a)
if(N>0):
  print(N)
print(-1)

Submission status: Wrong Answer

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

date = sum(a)
if n-date <= 0:
    print(-1)
else:
    print(n-date)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = map(int, input().split())
 
if(sum(A) == N):
  print('0')
elif(sum(A) > N):
  print(sum(A) - N)
else:
  print('-1')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
a = list(map(int, input().split()))
s = 0
for i in range(m):
    s += a[i]
print(n-s)

Submission status: Wrong Answer

Solution code:
N,M=map(int, input().split())
A=list(map(int, input().split()))
if sum(A)>=N:
  print(N-sum(A))
else:
  print(-1)

Submission status: Wrong Answer

Solution code:
n,m = input().split()
n = int(n)
m = int(m)
list1 = list(map(int,input().split()))
sum = 0
for i in range(m):
    sum = sum + list1[i]
print(n-sum)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = map(int, input().split())
 
if(sum(A) == N):
  print('0')
elif(sum(A) > N):
  print(N - sum(A))
else:
  print('-1')

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
a = map(int, input().split())
b = sum(a)
if n < sum(a):
    print(-1)
else:
    print(n-b)

Submission status: Wrong Answer

Solution code:
import numpy as np

length,hm = map(int,input().split())

time = list(map(int,input().split()))
print(length - np.sum(time))

Submission status: Wrong Answer

Solution code:
N, M, *A = map(int, open(0).read().split())
print(N - sum(A))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
# a = int(input())
# スペース区切りの整数の入力
# 文字列の入力
# s = input()
# 出力
# print("{} {}".format(a+b+c, s))
# b, c = map(int, input().split())

N, M = map(int, input().split())
array = list(map(int, input().strip().split()))
for value in array :
  N -= value
print(N)

Submission status: Wrong Answer

Solution code:
n,m= map(int, input().split())
a= list(map(int, input().split()))
if m == len(a):
    c= n-sum(a)
    print(c)
else:
    pass

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = A = map(int, input().split())
 
if(sum(A) == N):
  print('0')
elif(sum(A) > N):
  print(N - sum(A))
else:
  print('-1')

Submission status: Wrong Answer

Solution code:
N,M = map(int, input().split())
A = [list(map(int,input().split()))]
print(A)
SUM = sum(A[0])
if SUM>N:
    print(-1)
else:
    print(N-SUM)

Submission status: Wrong Answer

Solution code:
import math
a=input().split()
f=input().split()
s=0
fl=0
for i in range(0,int(a[1])):
    s+=math.ceil(int(f[i]))
    if(s>int(a[0])):
        break
        fl+=1
if(fl!=1):
    print(int(a[0])-s)
else:
    print("-1")

Submission status: Wrong Answer

Solution code:
N, M = map(int,input().split())	
A = list(map(int,input().split()))
print(N-sum(A))

Submission status: Wrong Answer

Solution code:
A, B = map(int, input().split())
l = list(map(int, input().split()))
count = 0
for a in l:
    count += a
print(A-count)

Submission status: Wrong Answer

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

if n-sum(a) < 0:
    print(0)
else:
    print(n-sum(a))

Submission status: Wrong Answer

Solution code:
n = input().split()
m = input().split()
n = [int(i) for i in n]
m = [int(i) for i in m]
a = n[0]
for i in m:
  a -= i
  if a<0:
    print("-1")
if a>0:
  print(a)

Submission status: Wrong Answer

Solution code:
import numpy as np

if __name__ == "__main__":
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    ret = -1
    A_sum = sum(A)
    if not A_sum < 0:
        ret = N - A_sum
    print(int(ret))

Submission status: Wrong Answer

Solution code:
n,m= map(int, input().split())
a= list(map(int, input().split()))
if m == len(a):
    c= n-sum(a)
print(c)

Submission status: Wrong Answer

Solution code:
N, M = map(int,input().split())
L = list(map(int,input().split()))
max(-1,N-sum(L))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a = list(map(int,input().split()))
print(n-sum(a))

Submission status: Wrong Answer

Solution code:
x, y = map(int,input().split())
arr = list(map(int, input().split()))
s = 0
for i in arr:
    s += i
print(x-s)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
A = list(map(int, input().split()))
flg = 0
cnt = sum(A)
if n > cnt:
  print(n-cnt)
else:
  print('-1')

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
s=list(map(int,input().split()))
S=0
for i in range(K):
    S+=s[i]
if S>=0:
    print (N-S)
else:
    print (-1)

Submission status: Wrong Answer

Solution code:
mn = input().split()
mn = [int(x) for x in mn]
n = mn[0]
m = mn[1]
a = input().split()
a  = [int(x) for x in a]


total = sum(a)

print(n-total)

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
    n, m = map(int, input().split())
    al = list(map(int, input().split()))
    res = sum(al[:m])
    print(n - res)

Submission status: Wrong Answer

Solution code:
tmp = input().split(" ")
N = int(tmp[0])
M = int(tmp[1])
tmp = input().split(" ")
A = [int(i) for i in tmp]
print(N-sum(A))

Submission status: Wrong Answer

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

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

a = sum(l)

if N-a > 0:
    print(N-a)

else:
    print(-1)

Submission status: Wrong Answer

Solution code:
x, y = input().split()
arr = list(map(int, input().split()))
s = 0
for i in arr:
    s += i
x = int(x)
print(x-s)

Submission status: Wrong Answer

Solution code:
n = input().split()
m = input().split()
n = [int(i) for i in n]
m = [int(i) for i in m]
a = n[0]
for i in m:
  a -= i
  if a<0:
    print("-1")


print(a)

Submission status: Wrong Answer

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

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

if n > sum(a):
    print(-1)
else:
    print(n - sum(a))

Submission status: Wrong Answer

Solution code:
def main():
    n,m = map(int,input().split())
    a = list(map(int,input().split()))
    s = sum(a)
    if s<n:
        print('-1')
    else:
        print(n-s)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N,M = map(int, input().split())
A = list(map(int, input().split()))
task = 0
for i in range(M):
    task += A[i]
answer = task
if answer >= 0:
    print(N - task)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np

tmp = np.array(list(map(int, input().split())))
N = tmp[0]
A = tmp[2:]

Needed = np.sum(A)

if Needed > N:
    print(-1)
else:
    print(N - Needed)

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
    n, m = map(int, input().split())
    al = list(map(int, input().split()))
    al.sort()
    res = sum(al[:m])
    print(n - res)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
s=list(map(int,input().split()))
S=0
for i in range(K):
    S+=s[i]
print (N-S)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
N,M = map(int,input().split())
homeworks = np.asarray(list(map(int,input().split())))

for homework in homeworks:
    if N >= 0 :
        N -= homework 
    else:
        print('-1')
        sys.exit()

print(N)

Submission status: Wrong Answer

Solution code:
tmp = input().split(" ")
N = int(tmp[0])
M = int(tmp[1])
tmp = input().split(" ")

for i in range(M):
  N -= int(tmp[i])
print(N)

Submission status: Wrong Answer

Solution code:
N , M  = input().split()
A   = input().split()
N , M  = int(N) , int(M)
for i in range(M):
    A[i] = int(A[i])
print(A , M , N)
for i in range(M):
    N -= A[i]
if N < -1:
    N = -1
print(N)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
a = list(map(int, input().split()))
if n - sum(a) > 0:
    print(n - sum(a))
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
a = map(int, input().split())
print(n-sum(a))
-1 if n < sum(a)  else n-sum(a)

Submission status: Wrong Answer

Solution code:
n, m= map(int, input().split())
a= list(map(int, input().split()))
c= n-sum(a)
print(c)

Submission status: Wrong Answer

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

if sum(a)>=n:
    print('-1')
else:
    print(n-sum(a))

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
a = list(map(int, input().split()))
for i in range(M):
  N -= a[i]
print(N if N>1 else '-1')

Submission status: Wrong Answer

Solution code:
n, _ = map(int, input().split())
nums = list(map(int, input().split()))
total = sum(nums)
ans = n - total
print(ans)

Submission status: Wrong Answer

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

yasumi = n[1] - sum(a)
if 0 <= yasumi:
  print(yasumi)
else:
  print(-1)

Submission status: Wrong Answer

Solution code:
N,M = map(int, input().split())
A = list(map(int, input().split()))
task = 0
for i in range(M):
    task += A[i]
answer = task
if answer > 0:
    print(N - task)
else:
    print(-1)

Submission status: Wrong Answer

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

for i in range(M):
    sum += A[i]

print(sum)
ans = N - sum
if(ans >= 0):
    print(ans)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

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

print(N- sum(A))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
a = list(map(int,input().split()))
if sum(a) < n:
    print(n - sum(a))
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
a = map(int, input().split())
print(n-sum(a))
-1 if n <= sum(a)  else n-sum(a)

Submission status: Wrong Answer

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

total = 0
for i in range(M):
    total += A[i]

if(N - total >0): print(N-total)
else: print(-1)

Submission status: Wrong Answer

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

k = sum(A)

print(n-k)

Submission status: Wrong Answer

Solution code:
N,M = map(int, input().split())
A = list(map(int, input().split()))  # 入力のときに N を使う必要はありません
# print(A[0]) 

F=N-sum(A)
print(F)

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
a = map(int, input().split())
print(n-sum(a))
-1 if n <= (n-sum(a))  else n-sum(a)

Submission status: Wrong Answer

Solution code:
all_days, hw_num = map(int, input().split())
hw_days = []
work = 0

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

for hw_day in hw_days:
    work += hw_day

if (all_days-work)>0:
    print(all_days-work)
else:
    print('-1')

Submission status: Wrong Answer

Solution code:
str = input().split()
line = input().split()

num = 0
for i in range(int(str[1])):
    num = num + int(line[i])

if (int(str[0]) - num)  > 0:
    print(int(str[0]) - num)
else:
    print(-1)

Submission status: Wrong Answer

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

for i in range(M):
    sum += A[i]

print(sum)
ans = N - sum

print(ans)

Submission status: Wrong Answer

Solution code:
n, _ = map(int, input().split())
nums = list(map(int, input().split()))
total = sum(nums)
ans = total - n
print(ans)

Submission status: Wrong Answer

Solution code:
def readInt():
    return list(map(int,input().split()))
n, m = readInt()
a = readInt()
ans = n- sum(a)
if ans <= 0:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
N,M= map(int,input().split())
homeworks = list(map(int, input().split()))
for homework in homeworks:
  N-=homework
print(N)

Submission status: Wrong Answer

Solution code:
N, M = map(int,input().split())
l = list(map(int,input().split()))
su = sum(l) + 1
if N < su:
    print('-1')
else:
    print(N - su)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
a = list(map(int, input().split()))
for i in range(M):
  N -= a[i]
print(N if N>0 else '-1')

Submission status: Wrong Answer

Solution code:
nm = list(map(int, input().split()))
am = list(map(int, input().split()))
x = 0
for i in range(len(am)):
    x += am[i]
if x > nm[0]:
    print('-1')
else:
    print(x)

Submission status: Wrong Answer

Solution code:
N,M = map(int, input().split())
A = list(map(int, input().split()))
AA = 0
for i in range(M):
    AA = AA+A[i]
print(AA)
if N-(AA) >= 0:
    print(N-AA)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
a=input().split()
f=input().split()
s=0
fl=0
for i in range(0,int(a[1])):
    s+=int(f[i])
    if(s>int(a[0])):
        break
        fl+=1
if(fl!=1):
    print(int(a[0])-s)
else:
    print("-1")

Submission status: Wrong Answer

Solution code:


def getIntList():
    return list(map(int, input().split()))

def main():
    
    N,M = map(int,input().split())
    A = getIntList()

    for i in range(M):
        N += A[i]
    
    if N >= 0:
        print(N)
    else:
        print(-1)

    return

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n = input().split()
m = input().split()
n = [int(i) for i in n]
m = [int(i) for i in m]
a = n[0]
for i in m:
  a -= i
  if a<0:
    print("-1")
  else:
    print(a)

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
a = map(int, input().split())
print(n-sum(a))
-1 if n < (n-sum(a))  else n-sum(a)