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

Submission status: Accepted

Solution code:
def main():
  N, M = map(int, input().split())
  xyz = [int(t) for t in input().split()]
  hi = N - sum(xyz)
  if hi >= 0:
    print(hi)
  else:
    print(-1)
main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

nm = input().split(" ")

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

alist = input().split(" ")

sum = 0

for i in range(n):
    sum = sum + int(alist[i])

if sum <= m:
    sa = math.floor(m-sum)
    print(sa)
else:
    print(-1)

Submission status: Accepted

Solution code:
def solution():
    return 1

def main():
    N , M = list(map(int , input().split()))
    assignments = list(map(int , input().split()))
    for a in assignments:
        N -= a 
    if N < -1:
        N = -1
    print(N)       
   
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():
    N, M = map(int, input().split(' ')) # Nにちかん ，Mこ
    An = list(map(int, input().split(' '))) # An日かかる
    
    if sum(An) > N:
        print('-1')
        return
    
    out = []
    for a in An:
        if a <= 24:
            out.append(a)
        else:
            t = a // 24
            m = a % 24
            for _ in range(t):
                out.append(24)
            out.append(m)
    nissuu = len(out)
    # print(out, nissuu, sum(out))
    
    print(N - sum(out))
            
    
    
    
    
main()

Submission status: Accepted

Solution code:
def main(N=None, M=None, A=None):
    if not N:
        N, M = map(int, input().split())
        A = list(map(int, input().split()))
    ans = N - sum(A)
    if ans < 0:
        ans = -1
    print(ans)
    return ans


if __name__ == "__main__":
    # assert main(41, 2, [5, 6]) == 30
    # assert main(10, 2, [5, 6]) == -1
    # assert main(11, 2, [5, 6]) == 0
    # assert main(314, 15, [9, 26, 5, 35, 8, 9, 79,
    #                       3, 23, 8, 46, 2, 6, 43, 3]) == 9
    main()

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

Submission status: Accepted

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

time_to_finish = sum([int(x) for x in input().split(' ')])
hanging_out = n - time_to_finish

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
def A():
    r = int(input())
    print(math.pi*(r)*2)

def B():
    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)

B()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l=[int(i) for i in input().split()]
m=[int(i) for i in input().split()]
print(max(-1,l[0]-sum(m)))

Submission status: Accepted

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

Submission status: Accepted

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

summ = sum(A)
subd = N_niti - summ

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

Submission status: Accepted

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

total = sum(lst)

if n - total < 0:
    print(-1)
else:
    print(n-total)

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:
# -*- coding: utf-8 -*-
import math

###
# main
if(__name__ == '__main__'):
    # input
    n, m = map(int, input().split(" "))
    a = list(map(int, input().split(" ")))

    sum = 0
    for elem in a:
        sum += elem

    ans = -1
    if sum <= n:
        ans = n - sum

    print(ans)

# else:
    # do nothing

Submission status: Accepted

Solution code:
import numpy as np
from collections import defaultdict
from math import gcd
import time
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


start = time.time()
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_lst = list(map(int, input().split()))

res = n - sum(a_lst)

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

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:
D, N = map(int, input().split())
d=list(map(int,input().split()))
SUM=sum(d)

if SUM > D:
    print(-1)
else:
    print(D-SUM)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
lis = list(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()))
cost = 0
for a in A:
    cost += a

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

Submission status: Accepted

Solution code:
NM = input()
NMs = NM.split(" ")
N = int(NMs[0])
M = int(NMs[1])
A = input()
Ai = A.split(" ")
days = 0
for i in Ai:
    days = days + int(i)
if days <= N:
    print (N - days)
else:
    print("-1")

Submission status: Accepted

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

for i in a:
    arr += i

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

Submission status: Accepted

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

allAssignm = sum(A)

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

Submission status: Accepted

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

A_ = sum(A)

if N >= A_:
    print(N-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)
else:
  print(N-sum(A))

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N, M = map(int, readline().split())
    A = list(map(int, readline().split()))
    ans = max(N-sum(A), -1)
    print(ans)


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)
print(ans if ans>=0 else -1)

Submission status: Accepted

Solution code:
def main():
    n, m = map(int, input().split())
    a_list = list(map(int, input().split()))
    s = sum(a_list)
    print(max(-1, 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 -= 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()))
print(max(N-sum(A),-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 = input().split()
a = input().split()
total = 0

for a_i in a:
    total = total + int(a_i)

print( max( int(n)-total, -1 ) )

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
List=list(map(int,input().split()))
for i in List:
  a-=i
if a>=0:
  print(a)
else:
  print("-1")

Submission status: Accepted

Solution code:
N, M = (int(x) for x in input().split())
assignment = (int(x) for x in input().split())
for i in assignment:
    N = N - i
if N < 0:
    print('-1')
else:
    print(N)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
a,b = input().split()
yasumi = int(a)

c = map(int,input().split())
syukudai = sum(c)

if syukudai <= yasumi:
  print(str(yasumi - syukudai))
else:
  print("-1")

Submission status: Accepted

Solution code:
N, M = [int(s) for s in input().split()]
sAs = sum([int(s) for s in input().split()])

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

Submission status: Accepted

Solution code:
(N,M) = map(int,input().split())
l = [int(x) for x in input().split()]
sm = 0
for i in range(M):
    sm += l[i]
if sm <= N:
    print(N-sm)
else:
    print('-1')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

  req_days = sum(A_list)

  ans = N-req_days

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


if __name__ == "__main__":
  main()

Submission status: Accepted

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

res = N- sum(Alist)

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

Submission status: Accepted

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

total=sum(A)

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

Submission status: Accepted

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

Submission status: Accepted

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

N = NM[0]

ans = N - sum(A)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
A = [int(i) for i in input().split()]
del A[m:len(A)]
print(n - sum(A)) if sum(A) <= n else print(-1)

Submission status: Accepted

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

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

Submission status: Accepted

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

do = 0

for i in range(m):
    do += li[i]

ans = n-do

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

import sys


def input():
    return sys.stdin.readline()


def resolve():
    n, m = map(int, input().split())
    a_list = list(map(int, input().split()))

    task = 0
    for ai in a_list:
        task += ai

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


if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

Submission status: Accepted

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

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:
n,m=map(int,input().split())
L=list(map(int,input().split()))
total = sum(L)
ans = n-total
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()))

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

Submission status: Accepted

Solution code:
n, m = (int(x) for x in 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())
hw=list(map(int,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()))
S=sum(A)
if N<S:
    print(-1)
else:
    print(N-S)

Submission status: Accepted

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

work = input().split()
work = [int(n) for n in work]

summary = sum(work)

if (n < summary):
    print(-1)
elif (n == summary):
    print(0)
else:
    print(n-summary)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(max(-1, 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(n-sum(a))
else:
	print('-1')

Submission status: Accepted

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

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (n, m) = [int(e) for e in lines[0].split(' ')]
    a = [int(e) for e in lines[1].split(' ')]

    return (n, m, a)


def solve(n, m, a):

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

    
    return result
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()

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:
n, m = map(int, input().split())
a = list(map(int, input().split()))

rem = n - sum(a)

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
M, N = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
total = 0
for i in range(N):
  total += A[i]
  if(total>M):
    print(-1)
    sys.exit()
print(M-total)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
n,m = [int(i) for i in readline().split()]
A = [int(i) for i in readline().split()]

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

Submission status: Accepted

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

SA = sum(A)
if N < SA :
    print("-1")
else:
    D = N - SA
    print(int(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]
#	print(sum,a[i])

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
import numpy as np
import math
from collections import deque 
from functools import reduce

# input = sys.stdin.readline

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

a = 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())
li=list(map(int,input().split()))
s=sum(li)
ans=n-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()))
s = 0
for i in range(len(A)):
    s = s + A[i]
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 (res := N - sum(A)) < 0:
    print(-1)
else:
    print(res)

Submission status: Accepted

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

Submission status: Accepted

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

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

else:
    play = n - sum(a)
    print(play)

Submission status: Accepted

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

for i in range(m):
    sum += hw_list[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()))

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

Submission status: Accepted

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

Submission status: Accepted

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

sumday = sum(a)

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()))
ans=sum(A)
if N-ans <0:
    print(-1)
else:
    print(N-ans)

Submission status: Accepted

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

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(ans)
else:
    print(-1)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

for A in As:
    N -= A

print(max(N, -1))

Submission status: Accepted

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

a_sum = sum(a)
ans = n-a_sum

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

Submission status: Accepted

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

ans = N

for A in Aj:
	ans -= A 
	if ans < 0:
		ans = -1
		break
print(ans)

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:
n,m = map(int,input().split())
s =input().split()
num = 0
Sum = 0
for i in range(m):
    num = int(s[i])
    Sum += num
if n - Sum >=0:
    print(n-Sum)
else:
    print('-1')

Submission status: Accepted

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

Submission status: Accepted

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

tot=0
for i in a:
  tot+=i

if tot<=n:
  print(str(n-tot))
else:
  print("-1")

Submission status: Accepted

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

homework=0

for a in A:
    homework+=a

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

Submission status: Accepted

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

a = [0]*m

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

#print(a)

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

Submission status: Accepted

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

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

A_sum = np.sum(A)

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

Submission status: Accepted

Solution code:
N,M = [int(x) for x in input().split()]
L = [int(x) for x in input().split()]
d = N-sum(L)
print(d if d >= 0 else -1)

Submission status: Accepted

Solution code:

# coding: utf-8
import sys
# import collections

# import bisect
# import math
import numpy as np

# from fractions import gcd

"""Template"""


class IP:
    """
    入力を取得するクラス
    """

    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: int
        """
        return int(self.input())

    def S(self):
        """
        1文字の取得(str
        :return: str
        """
        return self.input()

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]

    def SILS(self, n):
        """
        Some Int LineS
        横に複数、縦にも複数
        :param n: 行数
        :return: list
        """
        return [self.IL() for _ in range(n)]

    def SSLS(self, n):
        """
        Some String LineS
        :param n: 行数
        :return: list
        """
        return [self.SL() for _ in range(n)]


class Idea:
    def __init__(self):
        pass

    def HF(self, p):
        """
        Half enumeration
        半分全列挙です
        pの要素の和の組み合わせを作ります。
        ソート、重複削除行います
        :param p: list : 元となるリスト
        :return: list : 組み合わせられた和のリスト
        """
        return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))

    def Bfs2(self, a):
        """
        bit_full_search2
        bit全探索の改良版
        全探索させたら2進数のリストと10進数のリストを返す
        :return: list２つ : １個目 2進数(16桁)  2個目 10進数
        """
        # 参考
        # https://blog.rossywhite.com/2018/08/06/bit-search/
        # https://atcoder.jp/contests/abc105/submissions/4088632
        value = []
        for i in range(1 << len(a)):
            output = []

            for j in range(len(a)):
                if self.bit_o(i, j):
                    """右からj+1番目のiが1かどうか判定"""
                    # output.append(a[j])
                    output.append(a[j])
            value.append([format(i, 'b').zfill(16), sum(output)])

        value.sort(key=lambda x: x[1])
        bin = [value[k][0] for k in range(len(value))]
        val = [value[k][1] for k in range(len(value))]
        return bin, val

    def S(self, s, r=0, m=-1):
        """
        ソート関係行います。色々な設定あります。
        :param s: 元となるリスト
        :param r: reversするかどうか 0=False 1=True
        :param m: （2次元配列）何番目のインデックスのソートなのか
        :return: None
        """
        r = bool(r)
        if m == -1:
            s.sort(reverse=r)
        else:
            s.sort(reverse=r, key=lambda x: x[m])

    def bit_n(self, a, b):
        """
        bit探索で使います。0以上のときにTrue出します
        自然数だからn
        :param a: int
        :param b: int
        :return: bool
        """
        return bool((a >> b & 1) > 0)

    def bit_o(self, a, b):
        """
        bit探索で使います。1のときにTrue出すよ
        oneで1
        :param a: int
        :param b: int
        :return: bool
        """
        return bool(((a >> b) & 1) == 1)

    def ceil(self, x, y):
        """
        Round up
        小数点切り上げ割り算
        :param x: int
        :param y: int
        :return: int
        """
        return -(-x // y)

    def ave(self, a):
        """
        平均を求めます
        :param a: list
        :return: int
        """
        return sum(a) / len(a)

    def gcd(self, x, y):
        if y == 0:
            return x
        else:
            return self.gcd(y, x % y)

    def lcm(self, x, y):
        return (x * y) // self.gcd(x, y)


"""ここからメインコード"""


def main():
    # 1文字に省略
    r, e = range, enumerate
    ip = IP()
    id = Idea()

    """この下から書いてね"""
    # n, m = ip.IL()
    # a = np.array(ip.IL())
    # for _ in range(m):
    #     a[np.argmax(a)] //= 2
    # print(np.sum(a))
    n, m = ip.IL()
    a = ip.IL()
    if sum(a) <= n:
        print(n - sum(a))
    else:
        print(-1)


main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
x = list(map(int,input().split()))[:b]

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

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()))
ma=sum(a)
#print(ma)
if ma<=n:
    print(n-ma)
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)