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:
import sys
input = lambda: sys.stdin.readline().rstrip() 

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

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

if __name__ == '__main__':
    resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
A = map(int, input().split())
leftover = N - sum(A)
if leftover>=0:
  print(leftover)
else:
  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(N-sum(A))
else:
    print("-1")

Submission status: Accepted

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

ans = N - sum(A)
if ans < 0:
    ans = -1
print(ans)

Submission status: Accepted

Solution code:
import sys
## io
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))
## dp
INIT_VAL = 0
DP2 = lambda d1, d2: [[INIT_VAL]*d2 for _ in range(d1)]
DP3 = lambda d1, d2, d3: [[[INIT_VAL]*d3 for _ in range(d2)] for _ in range(d1)]

def main():
    a, b = MII()
    dd = MII()
    total = sum(dd)
    if total > a: print(-1); exit(0)
    else: print(a-total)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()
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 = map(int,input().split())
n = list(map(int,input().split()))

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

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

Submission status: Accepted

Solution code:
x,y=map(int,input().split())
if y==1:
    t=int(input())
else:
    t=sum(list(map(int,input().split())))
if x-t<0:
    print(-1)
else:
    print(x-t)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
line = list(map(int,input().split()))
day = line[0]
work = line[1]
line2 = list(map(int,input().split()))
haveto=0
for i in line2:
    haveto+= i

answer = day - haveto
if answer<0:
    print("-1")
else:
    print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

work = n - sum(a)

if work >= 0:
    print(work)
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:
n, m = list(map(int, input().split(" ")))
a = list(map(int, input().split(" ")))
a_sum = sum(a)
ans = n - a_sum

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

Submission status: Accepted

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

SUM = sum(A)

if N - SUM >= 0: print(N - SUM)
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(map(int,input().split()))
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 = [int(i) for i in input().split()]

play = n - sum(a)

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

Submission status: Accepted

Solution code:

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

A = list(map(int, input().split()))
for a in A:
    N -= a

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

Submission status: Accepted

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

for i in L:
    N-=i

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

Submission status: Accepted

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

Submission status: Accepted

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

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 = [int(x) for x in input().split()]
if N >= sum(a):
    print(N-sum(a))
else:
    print('-1')

Submission status: Accepted

Solution code:
import sys

N, M = map(int, sys.stdin.readline().rstrip().split())
A = list(map(int, sys.stdin.readline().rstrip().split()))

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(mi())
n,m = mi()
a = li()
if (n - sum(a) < 0):
    print("-1")
else:
    print(n - sum(a))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
import sys
from collections import Counter
from itertools import permutations, combinations
from fractions import gcd
from math import ceil, floor
import bisect
sys.setrecursionlimit(10 ** 6)

def input():
    return sys.stdin.readline()[:-1]

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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

sum = 0
for i in A:
    sum += i

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

Submission status: Accepted

Solution code:
n,m = list(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:
def input_one_number():
    return int(input())

def input_multiple_number():
    return map(int, input().split())

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


N, M = input_multiple_number()

listA = input_multiple_number_as_list()

hw = 0

for a in listA:
	hw += a

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    b, c = map(int, input().split())
    a = [int(i) for i in input().split()]

    if sum(a) <= b:
        print(b-sum(a))
    else:
        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 = map(int, input().split(" "))

workday = sum(a)

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

Submission status: Accepted

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

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

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:
N, M = tuple(map(int, input().split()))
A = list(map(int, input().split()))
res = N - sum(A)
if res < 0:
    print(-1)
else:
    print(res)

Submission status: Accepted

Solution code:
import numpy as np
n, m=map(int,input().split())
a = np.array(list(map(int, input().split())))
days = n - np.sum(a)
if days < 0:
    print(-1)
else:
    print(days)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
a = list(map(int,input().split()))
sum_a = sum(a)
ans = 0
if n >= sum_a:
    ans = n - sum_a
else:
    ans = -1
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 -= A[i]

if N<0:
	N = -1

print(N)

Submission status: Accepted

Solution code:

N,M = map(int,input().split())
A = [int(a) for a 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()))
a = sum(A)
if a > N:
    print(-1)
else:
    print(N - a)

Submission status: Accepted

Solution code:
import numpy as np
N, M = map(int, input().split())
A_l = np.array(list(map(int, input().split()))).sum()
if N>=A_l:
    print(N-A_l)
else:
    print(-1)

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
l=list(map(int,input().split()))
k=n-sum(l)
if k>=0:
    print(k)
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(-1)
else:
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

for aa in a:
  n -= aa

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()))

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

Submission status: Accepted

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

sum_a = sum(a)

if sum_a > n:
    print(-1)

else:
    print(n - sum_a)

Submission status: Accepted

Solution code:
N,M=list(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())
for i in list(map(int,input().split())):
    N -= i
if(N >= 0):
    print(N)
else:
    print(-1)

Submission status: Accepted

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

tot = sum(a)

ans = N - tot

if ans < 0:
  ans = -1

print(ans)

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:
i,j = list(map(int, input().split()))
s = list(map(int, input().split()))
z=sum(s)
if i<z:
    print(-1)
else:
    print(i-z)

Submission status: Accepted

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

sum=sum(a)

if sum <= n:
  print(n-sum)
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(-1)
    exit()
print(N-sum(A))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n,m=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:
# from math import pi
# r=int(input())
# print(2*(pi*r))


n,k=map(int,input().split())
a=[int(x) for x in input().split()]
#print(sum(a))
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()))
ans=n-sum(a)
if ans>=0:
	print(ans)
else:
	print('-1')

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
nm = input().split()
d = input().split()

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

di = [int(i) for i in d]

for i in di:
	n = n - i

if n < 0:
	n = -1

print(n)

Submission status: Accepted

Solution code:
import math

S =  list(map(int,input().split()))
N = S[0]
M = S[1]
A =  list(map(int,input().split()))
ans = N-sum(A)
if ans < 0:
    ans = -1
    
print(ans)

Submission status: Accepted

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

play = n - sum(a)

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

Submission status: Accepted

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

sa=n-sum(a)
if sa>=0:
  print(sa)
else:
  print(-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 -1)

Submission status: Accepted

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

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

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)
    quit()
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

ans = N - sum(a_list) if N >= sum(a_list) else -1

print(ans)

Submission status: Accepted

Solution code:
f=lambda:map(int,input().split())
n,m=f()
l=list(f())
print(max(n-sum(l),-1))

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

Solution code:
inp1 = list(map(int, input().split()))
n = inp1[0]
m = inp1[1]

inp2 = list(map(int, input().split()))
sum2 = sum(inp2)
ans =  n - sum2
if (n - sum2) >= 0:
  print(n - sum2)
else:
  print("-1")

Submission status: Accepted

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

Submission status: Accepted

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

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

res=N-sum(A)

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

Submission status: Accepted

Solution code:
N,M=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()))
for i in range(M):
    N = N - A[i]
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()))
f=n - sum(a)
if f>=0:
	print(f)
else:
	print(-1)

Submission status: Accepted

Solution code:
def Main(N, M, A):
    return max(N - sum(A), -1)    

def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    print(Main(N, M, A))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# coding: utf-8

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

nums = [int(x.strip()) for x in input().split(' ') ]
count = 0

for num in nums:
    count = count + num

if N < count:
    print(-1)
else:
    print(N-count)

Submission status: Accepted

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

a = list(map(int,input().split()))
sum = 0
for i in a:
    sum = sum + i 
if n < sum:
    print(-1)
else:
    print(n - sum)

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:
n,m=map(int,input().split())
li=list(map(int,input().split()))
s=sum(li)
x=n-s
if x>=0:
    print(x)
else:
    print(-1)

Submission status: Accepted

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

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

Submission status: Accepted

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

sum = 0
for e in l:
    sum += e

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import numpy as np

def main():
    args = input().rstrip().split(' ')
    N, M = int(args[0]), int(args[1])
    args = input().rstrip().split(' ')
    hw = np.array([int(i) for i in args])
    sum_hw = np.sum(hw)
    if(sum_hw > N):
        print('-1')
    else:
        print(N - sum_hw)
    
    
if __name__ == "__main__":
    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(ans)
else:
    print(-1)

Submission status: Accepted

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

nokori = n - sum(data)

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

Submission status: Accepted

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

d = sum(a)
ans = n - d

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

Submission status: Accepted

Solution code:
import sys

N, M=list(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:
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: Accepted

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

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

if (NM[0] - work >= 0):
    print(NM[0] - work)
else:
    print(-1)

Submission status: Accepted

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

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

Submission status: Accepted

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

sum_a = sum(A)
day = n - sum_a

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def b163(n, m, al):


    return n - sum(al) if n - sum(al) >= 0 else "-1"

def main():
    n , m = map(int, input().split())
    al = list(map(int, input().split()))
    print(b163(n, m, al))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x,y = map(int,input().split())
li = list(map(int,input().split()))

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

Submission status: Accepted

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

p = sum(a)

print(n - p if n - p >= 0 else -1)

Submission status: Accepted

Solution code:
import itertools
import math
import string
import collections
from collections import Counter
from collections import deque
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


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


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
N, M = map(int, input().split())
a = readints()
sum = 0
for i in range(M):
    sum += a[i]
if N < sum:
    print(-1)
if N >= sum:
    print(N-sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
import sys
import collections

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





if __name__ == '__main__':
    main()

Submission status: Accepted

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

print(max(-1, N-A))

Submission status: Accepted

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

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

nd = sum(As)

ans = '-1' if nd>N else N-nd
print(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:
x,y = map(int,input().split())
li = list(map(int,input().split()))

if sum(li) > x:
    print(-1)
else:
    print(x-sum(li))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n,m = map(int,readline().split())
lst1 = list(map(int,readline().split()))
ans = -1 if sum(lst1) > n else n-sum(lst1)
print(ans)

Submission status: Accepted

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


def solve(N: int, M: int, A: "List[int]"):
    play = N - sum(A)
    if play > -1:
        print(play)
    else:
        print(-1)


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

Solution code:
# -*- coding: utf-8 -*-
n, m = map(int, input().split())
List = list(map(int, input().split()))

s = sum(List)

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()))
total = n
for i in range(m):
    total -= a[i]
if total < 0:
    print(-1)
else:
    print(total)

Submission status: Accepted

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

res = n - sum(array)
print(res if res >= 0 else -1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve(n, m, a_list):
    res = n - sum(a_list)
    if res >= 0:
        return res
    else:
        return -1


def main():
    n, m = map(int, input().split())
    a_list = list(map(int, input().split()))
    res = solve(n, m, a_list)
    print(res)


def test():
    assert solve(41, 2, [5, 6]) == 30
    assert solve(10, 2, [5, 6]) == -1
    assert solve(11, 2, [5, 6]) == 0
    assert solve(314, 15, [9, 26, 5, 35, 8, 9, 79, 3, 23, 8, 46, 2, 6, 43, 3]) == 9


if __name__ == "__main__":
    test()
    main()

Submission status: Accepted

Solution code:
input_line = input()
Line = input_line.split()
Line = [int(s) for s in Line]

N,M = Line[0],Line[1]

input_line = input()
Line = input_line.split()
Line = [int(s) for s in Line]

if (N-sum(Line)) < 0 :
    print("-1")
else:
    print(N-sum(Line))

Submission status: Accepted

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

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

Sum = sum(A);
ans = max(-1, n - Sum);

print(ans);

Submission status: Accepted

Solution code:
import sys
N,M=map(int, sys.stdin.readline().split())
A=map(int, sys.stdin.readline().split())
sum_A=sum(A)
if sum_A<=N:
    print N-sum_A
else:
    print -1

Submission status: Accepted

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

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())
a_sum = sum([int(x) for x in input().split()])
if n < a_sum:
    print(-1)
else:
    print(n - a_sum)

Submission status: Accepted

Solution code:
# Problem B - Homework

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

# initialization
a_sum = sum(a_list)

# check
c = N - a_sum
if c<0:
    print(-1)
else:
    print(c)

Submission status: Accepted

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

Submission status: Accepted

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-sum(A))

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, m = list(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:
n,m=map(int,input().split())
a=list(map(int,input().split()))
x=n-sum(a)
if x>=0:
  print(str(x))
else:
  print("-1")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
import socket

hostnames = ['N551J', 'F551C', 'X553M']
input_file = 'b1.in'
if socket.gethostname() in hostnames:
    sys.stdin = open(input_file)


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


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


def solve():
    n, m = read_int_list()
    a = read_int_list()
    res = n - sum(a)
    if res < 0:
        res = -1
    return res


def main():
    res = solve()
    print(res)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

hwd = sum(A)
holiday = N - hwd
if holiday < 0:
    print(-1)
else:
    print(holiday)