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 = sum(map(int,input().split()))

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

Submission status: Accepted

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

hw = [int(x) for x in input().split()]

hwsum = 0

for n in range(len(hw)):
  hwsum += hw[n]

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

Submission status: Accepted

Solution code:
# N: 夏休みの日数，M: 宿題の数
N, M = list(map(int, input().split()))
# i番目の宿題にかかる日数
A = list(map(int, input().split()))

free_days = N - sum(A)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    N, M = MI()
    A = LI()

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

if __name__ == '__main__':
    solve()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N, M  = map(int,input().split())
A = sum(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()))
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()))
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()))

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

Submission status: Accepted

Solution code:
from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
    return int(input())

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


def solve():
    n, m = rl()
    A = rl()
    print (max(n - sum(A), -1))






mode = 's'

if mode == 'T':
    t = ri()
    for i in range(t):
        solve()
else:
    solve()

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

Submission status: Accepted

Solution code:
a, b = input().split()
s = list(map(int, input().split())) 
day = int(a) - sum(s) 
if day>=0:
  print(day)
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]

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

Submission status: Accepted

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

w = sum(A)
ans = N - w

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()))
b=0
for i in range(m):
  b += a[i]

if b<=n :
  print(n-b)
else:
  print(-1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = max(N - sum(A), -1)
print(ans)

Submission status: Accepted

Solution code:
#164B
#Homework

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:
days, num = map(int, input().split())
hw = list(map(int, input().split()))
hang = days - sum(hw)
if hang < 0:
  print("-1")
else:
  print(hang)

Submission status: Accepted

Solution code:
import math
import sys
#####sorting a dictionary by the values#####
def dict_sort(ans):
    ans=sorted(ans.items(),reverse=True,key=lambda kv:(kv[1]))
#####Primes till Nth#####
def seive_primes(n):
    flag=[0]*(n+10)
    flag[1]=flag[0]=1
    i=2
    while i*i<=n+1:
        if flag[i]==0:
            j=i*i
            while j<=n+1:
                flag[j]=1
                j+=i
        i+=1
    return flag
##### naive method for testing prime or not#####
def is_prime(n):
    if n==1:
        return 0
    for i in range(2,int(math.sqrt(n))+1):
        if n%i==0:
            return False
    return True
#####greatest common divisor of two numbers#####
def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)
#####least common multiplyer of two numbers#####
def lcm(a,b):
    return (a*b)//gcd(a,b)
#####factorial of a number#####
def fact(n):
    if n==1:
        return n
    return fact(n-1)*n
#####all the powers of two till nth#####
def pow_2s(n):
    ls=[]
    for i in range(1,n+1):
        ls.append(2**i)
    return ls
#####function that return all the letters#####
def alphbates():
    return "abcdefghijklmnopqrstuvwxyz"
#####taking an array/list as input#####
def inp():
    ls=list(map(int,input().split()))
    return ls
#####taking multiple inputs#####
def mult_inp():
    return map(int,input().split())
#####Main function starts from here#####
n,m=mult_inp()
ls=inp()
print(max(n-sum(ls),-1))

Submission status: Accepted

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

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

ans = n - sum(li)

if ans < 0:
    ans = -1

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n, m, *a = map(int, open(0).read().split())
d = n - sum(a)
if d <0:
    print(-1)
else:
    print(d)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys


def main():
    input = sys.stdin.buffer.readline
    n, m = map(int, input().split())
    a_list = list(map(int, input().split()))
    for a in a_list:
        n -= a
        if n < 0:
            break
    print(n if n >= 0 else -1)


if __name__ == '__main__':
    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()))

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()))
sum=0
for i in range(M):
    sum+=A[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()))

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
k=input()

list_a=k.split()

n=list_a[0]

m=list_a[1]

t=input()

list_b=t.split()

h=len(list_b)

list_s=[int(s) for s in list_b]

if int(m)==int(h) and sum(list_s) <= int(n):
  print(int(n)-sum(list_s))
elif int(m)==int(h) and sum(list_s) > int(n):
  print("-1")

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

a_sum = sum(a)
asobi = n - a_sum

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

Submission status: Accepted

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

y=input()
y_list=y.split()

sum1=0
count=0

for i in range(M):
  s=int(y_list[count])
  count+=1
  sum1+=s

if N>=sum1:
  print(N-sum1)
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())
A = [int(i) for i in input().split()]
print(N-sum(A) if N-sum(A) >= 0 else -1)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
arr = [int(x) for x in input().split()]
sm = 0
for i in arr:
	sm+=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)

print(n-s if n-s>=0 else "-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:
# https://atcoder.jp/contests/abc163/tasks/abc163_b

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

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
a = list(map(int,input().split()));
x = 0;
y = -1;

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

if x > n:
    print(y);
else:
    print(n-x);

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
A=[]
A=list(map(int,input().split()))
if(N-sum(A)<0):
    print('-1')
    exit()
print(N-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:
    print(n-sum(a))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

if (n >= st):
  print(n-st)
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("-1")
        exit()
    elif N>=0 and i+1 == M:
        print(N)
        exit()

Submission status: Accepted

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

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:
import sys
import math
def main():
    N,M=tuple(map(int,sys.stdin.readline().split()))
    r=N-sum(tuple(map(int,sys.stdin.readline().split())))
    print('-1') if r<0 else print(r)
if __name__=='__main__':main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = [int(i) for i in input().split()]
N = n[0]
M = n[1]

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


A_sum = sum(A)

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
arr = list(map(int, input().split()))
A=[]
suM=0
for i in arr:
  A.append(i)
for i in A:
  suM+=i
if suM>n:
  print(-1)
elif (suM==n) or (suM<n):
  print(n-suM)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():

    N, M = input_ints()

    A = input_int_list_in_line()

    day = N - sum(A)

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


def input_int():
    return int(input())


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


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


def input_int_tuple_list(n: int, q: int):
    return [tuple(map(int, input().split())) for _ in range(n)]


main()

Submission status: Accepted

Solution code:
n,m = list(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()))
print(N-sum(A) if sum(A)<=N else '-1')

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

Submission status: Accepted

Solution code:
arr = list(map(int, input().split()))
ais = list(map(int, input().split()))

days,tasks = arr[0],arr[1]

def main(days, ais):
  sum = 0
  for i in ais:
    sum += i
    if sum > days: return -1

  return days - sum

print(main(days, ais))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 163 B

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

day = sum(a)

ans = n - day
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()))

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

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

Submission status: Accepted

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

a = sum(A)

ans = N-a
if ans < 0:
    ans = -1

print(ans)

Submission status: Accepted

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

n, m = map(int,input().split())
a_list = list(map(int,input().split()))
ans = solve(n,m,a_list)
print(ans)

Submission status: Accepted

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

workdays=int()

for i in a:
    workdays += i

if workdays>n:
    print("-1")

else:
    print(n-workdays)

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

Submission status: Accepted

Solution code:

def main():
    n, m = list(map(int, input().split()))
    a_list = list(map(int, input().split()))
    
    homework_day = 0
    for task in a_list:
        homework_day += task
    
    play_day = n - homework_day
    if play_day >= 0:
        print(play_day)
    else:
        print(-1)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
  n, m = map(int, input().split())
  
  A = list(map(int, input().split()))
  
  total = sum(A)
  
  if total > n:
    print(-1)
    return
  
  free = n - total
  print(free)
  
main()

Submission status: Accepted

Solution code:
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, M = map(int, readline().split())
A = list(map(int,readline().split()))
B = sum(A)
if B > N:
    print(-1)
else:
    print(N-B)

Submission status: Accepted

Solution code:
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

ans = n - sum(A)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
def cumsum(x):
    return list(np.cumsum(x))

def cumsum_number(N,K,x):
    ans=[0]*(N-K+1)
    number_cumsum = cumsum(x)
    number_cumsum.insert(0,0)
    for i in range(N-K+1):
        ans[i]=number_cumsum[i+K]-number_cumsum[i]
    return ans
"""
int #整数
float #小数

#for
for name in fruits: #fruitの頭から操作
    print(name)

#リスト
list0 = [] #リスト生成
list0 = [1,2,3,4] #初期化
list0 = [0]*10 #[0,0,0,0,0,0,0,0,0,0]
list1= [i for i in range(10)] #>>> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
list1 = list(map(int, input().split()))　# 複数の入力をリストに入れる
number=[int(input()) for i in range(int(input()))] #複数行の入力をリストに
list1 = list1 + [6, 7, 8] #リストの追加
list2.append(34) #リストの追加　最後に（）内が足される
list.insert(3,10) #リストの追加　任意の位置（追加したい位置,追加したい値）
len(list4) #リストの要素数
max(sa) #list saの最小値
list5.count(2) #リスト(文字列も可）内の2の数
list1.sort() #並び替え小さい順
list1.sort(reverse=True)  #並び替え大きい順
set(list1) #list1内の重複している要素を削除し、小さい順に並べる
sum([2,3,   ,3]) #リストの合計

abs(a) #aの絶対値
max(a,b) min(a,b) #最大値　最小値
text1 = text1.replace("34","test") #text1内の"34"を"test"に書き換える(文字列内の文字を入れ替える)

exit(0) #強制終了

cumsum(リスト) #累積和をリストで返す
cumsum_number(N,K,x) #N個の数が含まれるリストx内のK個からなる部分和をリストで返す
"""
N,M=map(int,input().split())
day=sum(list(map(int,input().split())))
if day<=N:
    print(N-day)
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())

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

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

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

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
a_list = list(map(int, input().split()))
days = sum(a_list)
if N >= days:
    print(N-days)
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")
else:
    print(n-sum(a))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from collections import deque
import numpy as np
import math
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def Main():
    n,m = IL()
    a = np.array(list(IL()))
    b = np.cumsum(a,axis=0)
    if n<b[-1]:
        print(-1)
    else:
        print(n-b[-1])
if __name__=='__main__':
    Main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
a = list(map(int,input().split()))
#合計で何日かかるかを計算して
s = sum(a)
#遊べる日数はn-sで、n-s<0になったら宿題終わらないので-1を出す
print(max(-1,n-s))

Submission status: Accepted

Solution code:
def inpl(): return list(map(int, input().split()))

N, M = inpl()
print(max(-1, N - sum(inpl())))

Submission status: Accepted

Solution code:
n = int(input().split()[0])
print(max(-1, n - sum(map(int, input().split()))))

Submission status: Accepted

Solution code:
def resolve():
    a, b = input().strip().split(' ')
    n, m = [int(a), int(b)]
    array = list(map(int, input().strip().split(' ')))
    homework_sum = 0
    for i in range(m):
        homework_sum = homework_sum + array[i]
    if n - homework_sum >= 0:
        ans = n - homework_sum
    else:
        ans = -1
    print(ans)
resolve()

Submission status: Accepted

Solution code:
import numpy as np

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

    kadai = np.sum(a)
    if n<kadai:
        print(-1)
    else:
        print(n-kadai)

if __name__ == '__main__':
    main()

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()))
s = sum(a)
print(max(-1,n-s))

Submission status: Accepted

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

homework = 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(' ')))
asum=sum(a)

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

Submission status: Accepted

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

if(n-asum)<0:
    print("-1")
    exit()
else:
    print(n-asum)
    exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#inport
import sys
import numpy as np

#input
N,M = [int(x) for x in sys.stdin.readline().split()]
A = [list(map(int, sys.stdin.readline().split()))]

A = np.array(A)
d = np.sum(A)        

#shori
##初期化
if N-d < 0:
    print(-1)
else:
    print(N-d)

Submission status: Accepted

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

days = sum(A)
holidays = N - days

if holidays >= 0:
    print(holidays)
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()))
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=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(map(int,input().split(' ')))

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
ALL, num = map(int, input().split())
time = list(map(int, input().split()))
if (ALL - sum(time)) >=0:
  print(ALL - sum(time))
else:
  print("-1")

Submission status: Accepted

Solution code:
a=input()
a=a.split()
N=int(a[0])

b=input()
b=b.split()

z=0

for x in b:
  z=z+int(x)

w=N-z

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

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:
def main():
  import math
  n,m=map(int,input().split())
  a=list(map(int,input().split()))
  if(n<sum(a)):
    print(-1)
    return 0
  print(n-sum(a))

main()

Submission status: Accepted

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

for a in A:
    n -= a
    if n < 0:
        print(-1)
        break
else:
    print(n)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
p =list(map(int,input().split()))
sum = 0
for i in range(m):
  sum += p[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()))

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

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

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

Submission status: Accepted

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

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