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

Submission status: Accepted

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

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 = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
p = N - sum(A)
print(max(p, -1))

Submission status: Accepted

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

s = sum(a)

result = n - s

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

Submission status: Accepted

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

Submission status: Accepted

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

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

work = 0
for i in a:
    work+=i
if work > n:
    print("-1")
else:
    print(n - work)

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

ans = -1

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

day = 0
for i in range(m):
    day += s[i]

ans = n - day

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin


def get_result(data):
    N, M = data[0]
    A = data[1]
    ans = N - sum(A)
    if ans < 0:
        return -1
    return ans


if __name__ == '__main__':
    raw_data = [val.rstrip() for val in stdin.readlines()]
    data = [list(map(int, val.split(' '))) for val in raw_data]
    result = get_result(data)
    print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
ip1 = input()
ip1list = ip1.split(" ")
N = int(ip1list[0])
M = int(ip1list[1])
ip2 = input()
A_sub = ip2.split(" ")
A = []
for a in A_sub:A.append(int(a))
r = N-sum(A)
if r < 0:
    print(-1)
else:
    print(r)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in list:
    sum += i

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

Submission status: Accepted

Solution code:
import sys


lines = 2
inp = list()

for _ in range(lines):
    inp.append(sys.stdin.readline().strip())


n = int(inp[0].split()[0])
a_lst = [int(i) for i in inp[1].split()]

rest = n - sum(a_lst)

rest = rest if rest >= 0 else -1

print(rest)

Submission status: Accepted

Solution code:

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

play_day = N-sum(A)

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

Submission status: Accepted

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

n = int(n)
m = int(m)

days = 0

for a in l_a:
  days += int(a)
  
if (n - days) < 0:
  print(-1)
else:
  print(n - days)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

lis = map(int, input().split())
sum = sum(lis)

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N, M = map(int, input().rstrip().split())
As = [int(x) for x in input().rstrip().split()]
# print(N, M)
# print(As)
ret = N - sum(As)
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()))
remainday = N - sum(A)
if remainday < 0:
    print(-1)
else:
    print(remainday)

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

Submission status: Accepted

Solution code:
data = [input().split() for i in range(2)]
NM = data[0]
N = int(NM[0])
M = int(NM[1])
A = data[1]
sum = 0
for i in A:
  sum += int(i)
result = N - sum
if result >=0:
  print(result)
else:
  print("-1")

Submission status: Accepted

Solution code:
line = input().split(" ")
summer_day = int(line[0])
summer_kadai = int(line[1])

kadai_list = input().split(" ")
hituyou_day = 0
for i in range(summer_kadai):
    hituyou_day = hituyou_day + int(kadai_list[i])

if (hituyou_day <= summer_day):
    print(summer_day - hituyou_day)
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:
r, m = (int(each) for each in input().split())
a = [int(each) for each in input().split()]
print(max(r-sum(a), -1))

Submission status: Accepted

Solution code:
from sys import stdin

lines = stdin.readlines()

n, m = [int(x) for x in lines[0].rstrip().split()]
a_s = [int(x) for x in lines[1].rstrip().split()]

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

a,b=map(int,input().split())
li=list(map(int,input().split()))
sum_w=sum(li)
c=a-sum_w
if c<0:
    print(-1)
else:
    print(c)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
A=[int(_) for _ in input().split()]
cnt=0
for i in A:
  cnt+=i
ans=N-cnt
if ans<0:
  ans=-1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(max(N - sum(a_list), -1))

Submission status: Accepted

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

if M>=sum_A:
  print(M-sum_A)
else:
  print(-1)

Submission status: Accepted

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

sum = 0

for i in a:
    sum += i

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()))
all = 0
for time in a:
    all += time
if(all <= n):
    print(n-all)
else:
    print("-1")

Submission status: Accepted

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


sumA = sum(A)
bj = -1

if NM[0]-sumA >= 0:
    print(NM[0]-sumA)

else:
    print(bj)

Submission status: Accepted

Solution code:
n,m = input().split()
n = int(n)
m = int(m)
mlist = input().split(" ")
intmlist = [int(s) for s in mlist]
intmlist.sort(reverse=True)
# mlist = []
# for i range(0,m):
    # mlist.append(input())
# print(intmlist)

for i in range(0,m):
    n = n - intmlist[i]
    if n < 0:
        print(-1)
        break
    if i == m - 1:
        print(n) 
# if sumday > n:
#     print(-1)
# else:
#     print(n - sumday)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

day = list(map(int,input().split()))
days = 0
for i in range(m):
  days += day[i]
  
ans = n -days
if(ans<0):
	print(-1)
else:
  print(ans)

Submission status: Accepted

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

ans = -1
A_total = sum(A)

if N - A_total >= 0:
    ans = N - A_total

print(ans)

Submission status: Accepted

Solution code:
n,m = input().split(' ')
n = int(n)
m = int(m)
s = sum(list(map(int, input().split())))
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()))
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 = sum(A)

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

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:
N,M = map(int, input().split())			# "5 7" -> ["5", "7"] -> 5, 7 => N=5,K=7
A =        list( map(int, input().split()) )	# 1 2 3 4 5 ...

print( max(-1, 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(x)
else:
    print(-1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
input = sys.stdin.buffer.readline
def int_array():
	return list(map(int, input().strip().split()))
def str_array():
	return input().strip().split()
 
######################## TEMPLATE ENDS HERE ########################

d, n = int_array()
days = d-sum(int_array())
if days >= 0:
	print(days)
else:
	print(-1)

Submission status: Accepted

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

summer_holidays = N
work_days = sum(A)
actual_holidays = summer_holidays - work_days
    
answer = max(-1, actual_holidays)

print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

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

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

ans = -1

for i in range(m):
  n -= a[i]
  if n < 0:
    break

if n >= 0:
  ans = n

print(ans)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
a = [int(i) for i in 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()))

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

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
list1=[0]*b
list1=list(map(int,input().split()))
ans=a-sum(list1)
if ans<0:
    ans=-1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = N - sum(hw)

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 sum(a)>N:
    print("-1")
else:
    print(N-sum(a))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import numpy as np

def main():
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    nisuu = a[0]
    syukudai = np.sum(np.array(b))
    if nisuu >= syukudai:
        print(nisuu-syukudai)
    else:
        print(-1)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main_function():
    from sys import stdin
    from sys import stdout
    input = stdin.readline
    print = stdout.write

    n, m = list(map(int, input().split()))
    a = list(map(int, input().split()))
    summa = sum(a)
    if summa > n:
        print(f'-1')
    else:
        print(f'{n - summa}')


if __name__ == '__main__':
    main_function()

Submission status: Accepted

Solution code:
N, M = [int(x) for x in input().strip().split(" ")]
A = [int(x) for x in input().strip().split(" ")]
sum_A = sum(A)
rest = N - sum_A
print(rest if rest >=0 else -1)

Submission status: Accepted

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

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
line1 = input()
line2 = input()
n, m = line1.split(" ")
a_list = line2.split(" ")
a_list = [int(a) for a in a_list]
day = sum(a_list)

if int(n) < day:
    print(-1)
else:
    print(int(n)-day)

Submission status: Accepted

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

if sum(A) <= N:
    d = N - sum(A)

print(d)

Submission status: Accepted

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

B = sum(A)

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

Submission status: Accepted

Solution code:

def main():
    nm = list(map(int, input().split()))
    a = list(map(int, input().split()))
    aa = nm[0] - sum(a)
    aa = aa if aa >= 0 else -1
    print(aa)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

result = N - sum(syuku)

print(result) if result >= 0 else print('-1')

Submission status: Accepted

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

Submission status: Accepted

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

homework_day = sum(A)

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

Submission status: Accepted

Solution code:
from sys import stdin

def main():

    input = stdin.readline

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

    ans = N - sum(A)

    if ans < 0:
        ans = -1

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
A = list(map(int, input().split()))
ans = N
for i in range(M):
    ans -= A[i]
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(' ')))
print(max(N-sum(A),-1))

Submission status: Accepted

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

homework_days = sum(An)

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

Submission status: Accepted

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

S=0
for x in range(0,M):
	S=S+X[x]

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    i = input().split()[0]
    i = int(i)
    ii = input().split()
    ii = [int(x) for x in ii]
    ii = sum(ii)
    if ii > i:
        print(-1)
    else:
        print(i - ii)


main()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

import sys
import pprint

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)


def main():
	log = Logger(1)
	n, m = map(int, sys.stdin.readline().split())
	a = list(map(int, sys.stdin.readline().split()))
	if n - sum(a) >= 0:
		print(n-sum(a))
	else:
		print(-1)
	


main()

Submission status: Accepted

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

def main():
# 整数の入力

    line1 = input().split(' ')
    n = int(line1[0])
    m = int(line1[1])
    a = [int(x) for x in input().split(' ')]
    s = sum(a)
    rest = n - s
    if rest >= 0:
        print(rest)
    else:
        print(-1)
    

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

res = N - sum(As)

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

Submission status: Accepted

Solution code:
input = raw_input

n, m = map(int, input().split(" "))
ds = map(int, input().split(" "))
sd = sum(ds)
out = n - sd

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

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
a = 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 a:
    n-=i
    if n<0:
        print(-1)
        exit()
print(n)

Submission status: Accepted

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

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

Submission status: Accepted

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

days = n - sum(am)

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

Ans_sum = sum(A)

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

Submission status: Accepted

Solution code:
n,m=list(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:
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()))

sum_A = sum(A)

ans = N - sum_A

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math

# N = int(input())
# S = int(input())

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

# l = raw_input().split()
Ms = list(map(int, input().split()))

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

days = N - sum(A)

if days >= 0:
    print(days)
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:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect

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


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    n, m = LI()
    a = LI()
    if n - sum(a) >= 0:
        print(n - sum(a))
    else:
        print('-1')

    return


if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
import math

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

for i in range (m):
    s = s + math.ceil(a[i])

t = n - s

if t < 0:
    print ('-1')
else:
    print (t)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
#A = [0]*M
A_map = map(int, input().split())
A = list(A_map)
sum_homeworkday = 0
for i in range(M):
    sum_homeworkday = A[i] + sum_homeworkday
play_days = N -sum_homeworkday
if play_days >= 0:
    print(play_days)
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:
    ans = -1
print(ans)

Submission status: Accepted

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

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))


def main():
    N, M = MI()
    A = LI()
    sumA = sum(A)
    ans = N - sumA
    if ans<0:
        print(-1)
    else:
        print(ans)



if __name__ == "__main__":
	main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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