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: Accepted

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

vacation = M - sum(days)
print(-1 if vacation < 0 else vacation)

Submission status: Accepted

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

for a in A:
    N -= a

if N < 0:
    N = -1

print(N)

Submission status: Accepted

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

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

A_sum = sum(A)

resurt = (N - A_sum) if (N - A_sum) >= 0 else -1

print(resurt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    N, M = map(int, input().split())
    
    s = sum(list(map(int, input().split())))
    if s > N:
        print(-1)
    else:
        print(N - s)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
A,B = map(int,input().split())
s = list(map(int,input().split()))
if sum(s) <= A:
  print(A-sum(s))
else:
  print("-1")

Submission status: Accepted

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

q = input().split()

s = 0
for i in q:
  s = s + int(i)
  
if d-s >= 0:
	print(d-s)
else:
  	print(-1)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
homework = list(map(int, input().split()))
for i in homework:
    N -= i
if(N < 0):
    print (-1)
else:
    print (N)

Submission status: Accepted

Solution code:
import math
import time
from collections import defaultdict,deque
from sys import stdin,stdout
from bisect import bisect_left,bisect_right
n,k=map(int,stdin.readline().split())
a=list(map(int,stdin.readline().split()))
ans=n
ans-=sum(a)
print(max(-1,ans))

Submission status: Accepted

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: Accepted

Solution code:
N, M = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]
print(max(-1, N - sum(A)))

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

main()

Submission status: Accepted

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

for j in range(b):
  a = a - i[j]
 

if (a >= 0):
  print(a)
else:
  print(-1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(max(-1,n-sum(a)))

Submission status: Accepted

Solution code:
from sys import stdin, stdout
from collections import deque, defaultdict
import math as m

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def main():
	n, m = rli()
	tot = sum(rli())
	diff = n - tot
	if diff < 0:
		print("-1")
	else:
		print(diff)
	stdout.close()

if __name__ == "__main__":
	main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

# from fractions import gcd
from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

N, M = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]

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

Submission status: Accepted

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

if n < s:
  print(-1)
else:
  print(n-s)

Submission status: Accepted

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

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

for i in range(M):
    N -= A[i]

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
days = list(map(int, input().split()))
hw_day = 0
for day in days:
    hw_day += day
if N >= hw_day:
    print(N - hw_day)
else:
    print('-1')

Submission status: Accepted

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

Submission status: Accepted

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

holidays=N-sum(As)
if holidays < 0:
  print(-1)
else:
  print(holidays)

Submission status: Accepted

Solution code:
def actual(n, m, a_list):
    a_sum = sum(a_list)

    if n >= a_sum:
        return n - a_sum

    return -1

n, m = map(int, input().split())
a_list = map(int, input().split())

print(actual(n, m, a_list))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
lst = list(map(int,input().split()))
plus = 0
for a in lst:
    plus += a
if plus <= N:
    print(N-plus)
else:
    print('-1')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
nums1 = [int(e) for e in input().split()]
nums2 = [int(e) for e in input().split()]

if nums1[0] - sum(nums2) >= 0:
    print(nums1[0] - sum(nums2))
else:
    print('-1')

Submission status: Accepted

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

A = (list(int(x) for x in input().split()))
if(sum(A)<=N):
    print(N-sum(A))
else:
    print(-1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

limit = list(map(int, input().split()))
days = list(map(int, input().split()))

sum = 0

for v in days:
    sum += v

print(max(limit[0] - sum, -1))

Submission status: Accepted

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

Submission status: Accepted

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

if L >= 0:
  print(L)
else:
  print(-1)

Submission status: Accepted

Solution code:
import itertools
import math
import fractions
import functools
n, m = map(int, input().split())
a = list(map(int, input().split()))
if(n >= sum(a)):print(n-sum(a))
else:print(-1)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

days = sum(A)

rest = N - days
print(max(-1, rest))

Submission status: Accepted

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

Submission status: Accepted

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

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

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

if __name__ == '__main__':

    ABC_163_B()

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(m):
    if n >= a[i]:
        n -= a[i]
    else:
        n = -1
        break

print(n)

Submission status: Accepted

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

L = N - sum(HW)
if L < 0:
    print(-1)
else:
    print(L)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in a:
    n-=i
    if n<0: #宿題の総日数が夏休みの日数を上回った場合
        print(-1)
        exit()
print(n)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
n,m=map(int,input().split())

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

s=np.sum(a)

v=n-s
if v>=0:
    print(v)
else:
    print(-1)

Submission status: Accepted

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

print(-1 if n < sum(a) else n - sum(a))

Submission status: Accepted

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

for i in range(m):
    sum +=a[i]

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

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
day = list(map(int,input().split()))
all_s = sum(day)

ans = n-all_s

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

Submission status: Accepted

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

for i in range(m):
    n = n - a[i]

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

Submission status: Accepted

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

if N < sum(A_list):
    print(-1)
else:
    print(N-sum(A_list))

Submission status: Accepted

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

for i in range(m):
    n -= a[i]
if n < 0:
    print("-1")
else:
    print(n)

Submission status: Accepted

Solution code:
def main():
    import sys
    input=sys.stdin.readline
    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: Accepted

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

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

Submission status: Accepted

Solution code:
def resolve():
    a,b = map(int, input().split())
    A = list(map(int, input().split()))
    count = 0

    for c in range(b):
        count += A[c]
    
    result = a - count
    if result < 0:
        print("-1")
    else:
        print(result)
    
resolve()

Submission status: Accepted

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

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

all_days = sum(A)

if(all_days > N):
    print(-1)

else:
    print(N - all_days)

Submission status: Accepted

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

a = [ int( i ) for i in input().split() ]
#print( a )

sumA = int( 0 )
for ai in a:
    sumA += ai

ans = n - sumA

if ans >= 0:
    print( ans )
elif ans < 0:
    print( "-1" )

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
A = []
A.extend(map(int, input().split()))

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

Submission status: Accepted

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

A = list(map(int, input().split()))
         
n = N - np.sum(A)
if(n >= 0):
    print(n)
else:
    print(-1)

Submission status: Accepted

Solution code:
import functools
N, M = list(map(int,input().split()))
A = list(map(int,input().split()))
N = N - functools.reduce(lambda x,y: x + y, A)
if N < 0:
    print(-1)
else:
    print(N)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

print(max(n-sum(a), -1))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(M):
    N=N-li[i]

if N>=0:
    print(N)

else:
    print("-1")

Submission status: Accepted

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

a = [int(i) for i in a]
if int(n) >= sum(a):
    print(int(n)-sum(a))
else:
    print(-1)

Submission status: Accepted

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

Submission status: Accepted

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

homework_day = sum(A)

play_day = N-homework_day

if(play_day < 0):
    print("-1")
else:
    print("{}".format(play_day))

Submission status: Accepted

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

Submission status: Accepted

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

days = sum(A)
free = N - days

if free < 0:
    print(-1)
else:
    print(free)

Submission status: Accepted

Solution code:
import sys
import os
import bisect, collections, copy, itertools, math, string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int, input().split()))
def LS(): return list(input().split())

def solve():
	nm = LI()
	a = LI()
	n = nm[0]
	m = nm[1]

	for _a in a:
		n -= _a

	if n < 0:
		n = -1
	print(n)
	
if __name__ == '__main__':
	solve()

Submission status: Accepted

Solution code:
def main():
    n, m = map(int, input().split())
    As = list(map(int, input().split()))
    if n >= sum(As):
        ans = n - sum(As)
    else:
        ans = -1
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n, k = [int(tmp)for tmp in input().split()]
a = list(map(int,input().split()))
x = n - sum(a)
if x >=0 :
  print(x)
else :
  print("-1")

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    NM = input()
    N = int(NM.split(" ")[0])
    M = int(NM.split(" ")[1])
    strA = input()
    listA = strA.split(" ")

    X = 0
    for i in range(0, M):
        X += int(listA[i])

    Y = N - X
    if(Y < 0):
        Y = -1
    print(Y)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n, m = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

print(max(n - sum(A), -1))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
import numpy as np

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

if n>=s:
    print(n-s)
else:
    print(-1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# n 夏休み日数
# m 宿題の数
# a1,a2.. それぞれの宿題がかかる日数

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

total = sum(a)

if(total>n):
  print(-1)
else:
  print(n-total)

Submission status: Accepted

Solution code:
N, M = [int(n) for n in input().split()]
A = [int(n) for n in input().split()]
print("-1" if N < sum(A) else N - sum(A))

Submission status: Accepted

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

if n - sum(A) < 0:
  print(-1)
else:
  print(n - sum(A))

Submission status: Accepted

Solution code:
N,M=list(map(int,input().split()))
src=list(map(int,input().split()))
for s in src:
  N-=s
if 0<=N:
  print(N)
else:
  print(-1)

Submission status: Accepted

Solution code:
s=list(map(int,input().split()))
t=list(map(int,input().split()))
print(-1 if sum(t)-s[0] > 0 else s[0]-sum(t))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
for num	in input().split():
  n-=int(num)
print(n if n>=0 else -1)

Submission status: Accepted

Solution code:

N,M = map(int,input().split())
A = [int(x) for x in input().split()]

if N < sum(A):
    print(-1)
else:
    print(N-sum(A))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)
input = lambda: sys.stdin.readline().strip()

def main():
    N,M = map(int,input().split())
    A_list = list(map(int,input().split()))

    for i in A_list:
        N -= i
    print(N if N>=0 else -1)

main()

Submission status: Accepted

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

ans = n - sum(A)

if ans < 0:
    print("-1")
else:
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#ABC163b
import math
n, m = map(float,input().split())
a = map(float,input().split())

time = math.ceil(sum(a))

if time > n:
    print(-1)
elif time <= n:
    print(int(n-time))

Submission status: Accepted

Solution code:

N,M =map(int,input().split())
A =[int(j) for j in input().split()]
if N-sum(A) >=0:
    print(N-sum(A))
else:
    print(-1)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

n, m = map(int, input().split())

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
total, num = map(int, input().split())
days = list(map(int, input().split()))
days = sum(days)
if days > total:
    print(-1)
elif total >= days:
    print(total - days)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10**7)
from pprint import pprint as pp
from pprint import pformat as pf

import math
#from sortedcontainers import SortedList, SortedDict, SortedSet # no in atcoder
import bisect


if __name__ == '__main__':
    n, m = list(map(int, input().split()))
    a_list = list(map(int, input().split()))
    s = sum(a_list)
    if n >= s:
        print(n - s)
    else:
        print(-1)

    #print('\33[32m' + 'end' + '\033[0m') # debug

Submission status: Accepted

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

Submission status: Accepted

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

total_work = sum(a)
if total_work > n:
    print("-1")
elif total_work == n:
    print("0")
else:
    ans = n - total_work
    print(ans)

Submission status: Accepted

Solution code:
bg=input().split()
n=int(bg[0])
m=int(bg[1])

b2=input().split()
s=0
for a in range(m):
  s+=int(b2[a])
  
if n>=s:
  print(n-s)
else:
  print("-1")

Submission status: Accepted

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

for i in A:
    sumStudyDay += int(i)
    
leftDay = int(N)-sumStudyDay

if leftDay<0:
    print(-1)
else:
    print(leftDay)

Submission status: Accepted

Solution code:
# B - Homework

N, M = map(int, input().split())
A = [int(a) for a in input().split()]

for a in A: N -= a
print(N if N >= 0 else -1)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
days = (int)(input().split(" ")[0])
nokori = days - sum(list(map(int, input().split(" "))))
print(nokori if nokori >= 0 else -1)

Submission status: Accepted

Solution code:
import numpy as np

from sys import stdin


def main():
    n, m = map(int, stdin.readline().split())
    a = list(map(int, stdin.readline().split()))
    a = np.array(a)

    ans = n - np.sum(a)

    print(-1) if ans < 0 else print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
array = []

for i in range(2):
    val = input()
    array.append(val.split())

summar_days = int(array[0][0])
amount_homework = int(array[0][1])

if amount_homework != len(array[1]):
    print("Error: M is different than length of A")
    exit()

for need_days in array[1]:
    summar_days = summar_days - int(need_days)
    if summar_days < 0:
        summar_days = -1
        break

print(summar_days)

Submission status: Accepted

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: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Wed May  6 00:38:38 2020

@author: shinba
"""

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

print(N-sum(A) if N>=sum(A) else -1)

Submission status: Accepted

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

Submission status: Accepted

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

if sum(A)>n:
  print('-1')
  exit(0)
for i in range(m):
  n-=A[i]
print(n)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, m = (int(i) for i in input().split());
v = [int(i) for i in input().split()];

if sum(v) <= n:
    print(n - sum(v));
else:
    print("-1");

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
List = list(map(int, input().split()))
# print(List)

total = 0
for a in List:
  # print(a)
  total = total + a

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

Submission status: Accepted

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

n = int(a[0])
m = int(a[1])

y = input().split()

x = [int(i) for i in y]

if(sum(x) == n):
  print(0)
elif(sum(x) > n):
  print(-1)
else:
  print(n-sum(x))

Submission status: Accepted

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

whole_day = N - sum(A)

if whole_day >= 0:
    print(whole_day)
else:
    print(-1)

Submission status: Accepted

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

print(max(n-sum(a),-1))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
print(-1 if (d := tuple(map(int, input().split()))[0] - sum(map(int, input().split()))) < 0 else d)

Submission status: Accepted

Solution code:
n, m = map(lambda x: int(x), input().split())
days = n - sum(map(lambda x: int(x), input().split()))
print(days) if days >= 0 else print('-1')

Submission status: Accepted

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

Submission status: Accepted

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

S=0
S=sum(A)
if N-S>=0:
    print(N-S)
else:
    print("-1")

Submission status: Accepted

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

for i in A:
    N-=i
    if N<0:
        print(-1)
        exit()
print(N)

Submission status: Accepted

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

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

s = sum(tasks)

if n >= s:
    print(n-s)
else:
    print(-1)

Submission status: Accepted

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

Submission status: Accepted

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

d = n - sum(a)
print(d if d >= 0 else -1)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
c = list(map(int, input().split()))
d = sum(c)
e = a - d
print(e if e >= 0 else "-1")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

Solution code:
import numpy as np

def calculate_free_day(summer_days, need_days):
    return summer_days - np.sum(need_days)

if __name__ == "__main__":
    summer = int(input().split()[0])
    need = np.array([int(i) for i in input().split()])
    free_day = calculate_free_day(summer, need)

    if free_day >= 0:
        print(free_day)
    else:
        print(-1)

Submission status: Accepted

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

Submission status: Accepted

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

if int(N)-sum(list(map(int,A)))>=0:
    print(int(N)-sum(list(map(int,A))))
else:
    print("-1")

Submission status: Accepted

Solution code:
N, M = tuple(int(c) for c in input().split(' '))
A = tuple(int(c) for c in input().split(' '))
if sum(A) > N:
  print(-1)
else:
  print(N - sum(A))

Submission status: Accepted

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