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

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

if N - sum(data) >= 0:
    print(N-sum(data))
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()))

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

Submission status: Accepted

Solution code:
#高橋君の夏休みは N 日間です。
#夏休みの宿題が M 個出されており
#i 番目の宿題をやるには Ai 日間かかります。
#夏休み中に全ての宿題を終わらせるぉとができないときは、かわりに '-1' を出力

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

Submission status: Accepted

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

def answer(N: int, M: int, A: list) -> int:
    A = sum(A)
    if N < A:
        return -1
    else:
        return N - A

print(answer(N, M, A))

Submission status: Accepted

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

answer = N - sum(A)

if N >= sum(A):
    print(answer)

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

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

Submission status: Accepted

Solution code:
# 高橋君の夏休みは N 日間
# 夏休みの宿題が M 個
# 遊ぶことができる日数は？
# ただし、夏休み中に全ての宿題を終わらせることができないときは、-1 を出力

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

answer = N - sum(A)

if N >= sum(A):
    print(answer)

else:
    print('-1')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, readline().split()))
    a = list(map(int, readline().split()))
    print(n - sum(a) if sum(a) <= n else -1)


if __name__ == '__main__':
    solve()

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=list(map(int ,input().split()))
a=list(map(int ,input().split()))
s=0
for i in range(0,len(a)):
	s+=a[i]
if(s>n):
	print(-1)
	
elif(s<n):
	hangout=n-s
	print(hangout)
		
elif(s==n):
	print(0)

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

Submission status: Accepted

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

d = 0
flag = True
for a in A:
    d += a

    if(d > n):
        flag = False
        break

print(n-d if flag else -1)

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
A_list = []
for i in range(1, M+1):
    A_list.append("A_" + str(i))
A_list = map(int, input().split())

answer = N - sum(A_list)

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# 夏休みN日間
# 宿題はM個出されており、i番目の宿題をやるにはj日間かかる。
# この場合、宿題を全部終わらせるのに ...日かかる

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

# 宿題が全てが終わる場合
if n - sum(days) >= 0:
    print(n - sum(days))
# 宿題終わらない場合
else:
    print(-1)

Submission status: Accepted

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

if n - sum(d) <= -1:
    print(-1)
else:
    print(n - sum(d))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n,m = 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())
list01 = input().split()
list02 = [int(a) for a in list01]
if sum(list02) <= n:
    print(n - sum(list02))
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 個出されており、i 番目の宿題をやるには Ai 日間かかります。

    複数の宿題を同じ日にやることはできず、また、宿題をやる日には遊ぶことができません。
    夏休み中に全ての宿題を終わらせるとき、最大何日間遊ぶことができますか？
    ただし、夏休み中に全ての宿題を終わらせることができないときは、かわりに -1 を出力してください。
'''

'''
制約：
    1 ≦ N ≦ 1000000
    1 ≦ M ≦ 10000
    1 ≦ Ai ≦ 10000
'''

# 標準入力からN, M, Ai を取得する
n, m = map(int, input().split())
a = list(map(int, input().split()))

# 宿題にかかる日数を計算する
work_days = 0
for i in range(0, m):
    work_days += a[i]

# 遊べる日を計算して出力する
result = 0
if n >= work_days:
    result = n - work_days
else:
    result = -1

print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# B - Homework

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

if N < sum(my_list):
    answer = -1
else:
    answer = N - sum(my_list)

print(answer)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
c = list(map(int, input().split()))
if a >= sum(c):
  print(a - sum(c))
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:
N, M = map(int, input().split())
A = list(map(int, input().split()))
A1 = sum(A)

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
task = []
for i in range(1, M + 1):
    task.append("A_" + str(i))

task = map(int, input().split())
task_total = sum(task)

if task_total <= N:
    print(N - task_total)

else:
    print(-1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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()))
ans = max(-1, N-sum(A))
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

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

ans = N - sum(A)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

# リストにM個の数字を、入力したい
# study_days_list = []
# study_days_list.append(study_days)
# print(study_days_list)

total_study_days = sum(study_days)

answer = (N - total_study_days)

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

Submission status: Accepted

Solution code:

# 高橋君の夏休みはN日間です。夏休みの宿題がM個出されており,i番目の宿題をやるにはAi日間かかります。
# 複数の宿題を同じ日にやることはできず、また、宿題をやる日には遊ぶことができません。
# 夏休み中に全ての宿題を終わらせるとき、最大何日間遊ぶことができますか？
# ただし、夏休み中に全ての宿題を終わらせることができないときは、かわりに -1 を出力してください。


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

# リストにM個の数字を、入力したい
# study_days_list = []
# study_days_list.append(study_days)
# print(study_days_list)

total_study_days = sum(study_days)

answer = (N - total_study_days)

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

Submission status: Accepted

Solution code:
# 問題文
# 高橋君の夏休みはN日間です。
# 夏休みの宿題が M個出されており、i番目の宿題をやるにはAi日間かかります。
# 複数の宿題を同じ日にやることはできず、また、宿題をやる日には遊ぶことができません。
# 夏休み中に全ての宿題を終わらせるとき、最大何日間遊ぶことができますか？
# ただし、夏休み中に全ての宿題を終わらせることができないときは、かわりに -1 を出力してください。

# n（夏休みの日数）,m（宿題の数）：標準入力
# リストの中のA(宿題日)：リストを作成し、標準入力
n, m = map(int, input().split())
A = list(map(int, input(). split()))

# 最大で n −合計(A1+. . .+AM)日間遊ぶことができる
if n < sum(A):   # 夏休みの日数より宿題日が多い場合：宿題をやる日数が足りない→終わらせることができない
    print(-1)
else:
    print(n-sum(A)) # その他→宿題は終わる→夏休みの日数-宿題日

# NameError: name 'N' is not defined

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

Submission status: Accepted

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

# 夏休みはN日間です。
# 夏休みの宿題が M個 出されており、i番目の宿題をやるには Ai日間 かかります。
# 高橋君が遊ぶことのできる日数、または、-1 を出力せよ。

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

Submission status: Accepted

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

hell = sum(homework)

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# @uthor : Kaleab Asfaw
from sys import stdin, stdout
# Fast IO
# from math import gcd

def input():
	a = stdin.readline()
	if a[-1] == "\n": a = a[:-1]
	return a
def print(*argv, end="\n", sep=" "):
	n = len(argv)
	for i in range(n):
		if i == n-1: stdout.write(str(argv[i]))
		else: stdout.write(str(argv[i]) + sep)
	stdout.write(end)
# Others
mod = 10**9+7
def lcm(x, y): return (x * y) / (gcd(x, y))
def fact(x, mod=mod):
	ans = 1
	for i in range(1, x+1): ans = (ans * i) % mod
	return ans
def arr2D(n, m, default=0):
	lst = []
	for i in range(n): temp = [default] * m; lst.append(temp)
	return lst
def sortDictV(x): return {k: v for k, v in sorted(x.items(), key = lambda item : item[1])}

def solve(n, lst):
	if sum(lst) > n: return -1
	return n - sum(lst)

n, a = list(map(int, input().split()))
lst = list(map(int, input().split()))
print(solve(n, lst))

Submission status: Accepted

Solution code:
#163b
#値を受け取る
N, M = map(int, input().split())
A = list(map(int, input().split()))

#listの合計が夏休みの日数でできるか判断

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

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

Submission status: Accepted

Solution code:
summer_vacation, homework = map(int, input().split())
days = list(map(int, input().split()))

if summer_vacation < sum(days):                 # if elseを逆にするとerrorが出る
    print(-1)
else:
    print(summer_vacation-sum(days))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
sv,m = input().split(" ") # 夏休みの日数と問題数を数値で格納
sv = int(sv)
m = int(m)

day = input().split(" ") #
days = 0 #

for i, new in enumerate(day): # 独学のP105をパクる
    days += int(day[i]) # 宿題を終わらせるのにかかる総日数を加算で出す

if days > sv: # 総日数が夏休み日数より多かったら-1を出力
    print("-1")
else: # じゃなかったら残り日数を遊べる日として出力
    print(sv - days)

Submission status: Accepted

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

Submission status: Accepted

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

if n >= sum(homework):
  print(n-sum(homework))

else:
  print(-1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
a = list(map(int,input().split()))
# a_sum = 0
# for b in a:
#     a_sum += int(b)

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(n - sum(a))
# リスト内の日数の合計が夏休みの日数より多ければ-1を表示
else:
    print("-1")

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
# 受け取った文字をスペースで分けてリスト化
a = list(input().split())
# 文字列のリストの値を整数化
a_int = [int(i) for i in a]
# 夏休みの日数がリスト内の日数の合計より多ければ残日数を表示 
if n >= sum(a_int):
    print(n - sum(a_int))
# リスト内の日数の合計が夏休みの日数より多ければ-1を表示
else:
    print("-1")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 遊べる日数 = 夏休み総数N - 課題にかかる日数A
N, M = map(int, input().split())
A = list(map(int, input().split()))

answer = N - sum(A)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m = 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:
S_list = [(input()) for i in range(2)]
n,m = map(int,S_list[0].split())
S_list_1 = list(map(int,S_list[1].split()))
sum_homework = sum(S_list_1)
if  sum_homework > n:
    result = -1
else:
    result = n - sum_homework
print(result)

Submission status: Accepted

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

work_days = 0

for i in range(M):
    work_days += int(A[i])

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

Submission status: Accepted

Solution code:
#   夏休みの課題
#   入力

n, m = map(int, input().split())
a = input().split()
a_sum = 0
for b in a:
    a_sum += int(b)
if a_sum > n:
    print(-1)
else:
    print(n - a_sum)

Submission status: Accepted

Solution code:
# 高橋君の夏休みが N 日間
# 夏休みの宿題が M個出されており、i 番目の宿題をやるには　A i日間かかる
# 条件　複数の宿題を同じ日にはできない。
# また宿題をやる日は遊べない。
# 夏休み中に全ての宿題を終わらせるとき、最大何日遊ぶことができるか。
# 終わらない時は-1

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

# 宿題にかかる合計日数
play_day = N - sum(A)

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

Submission status: Accepted

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


answer = n - sum(a)

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

enjoy = N - sum(A)

if N >= sum(A):
    print(enjoy)

else:
    print('-1')

Submission status: Accepted

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

day = N - sum(A)

if N - sum(A) >= 0:
    print(day)

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

Submission status: Accepted

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

answer = N - sum(A)

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

Submission status: Accepted

Solution code:
summer_vacation, amount_of_homework = map(int, input().split())
a = map(int, input().split())
homework_list = list(a)

total_days = 0

for i in homework_list:
    total_days += i

if summer_vacation >= total_days:
    print(summer_vacation - total_days)
else:
    print(-1)

Submission status: Accepted

Solution code:
# 夏休みN日間
# 夏休みの宿題がM個出されており、i番目の宿題をやるにはAi日間
# 複数の宿題を同じ日にやることはできず、宿題をやる日には遊べない
# 最大何日間遊べるか、終わらない場合は-1を出力

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

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

Submission status: Accepted

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

for i in range(M):
    homework += a[i]

play = N - homework

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# abc163B
# https://atcoder.jp/contests/abc163/tasks/abc163_b

# 夏休みはN日間
# 夏休みの宿題はM個
# 宿題は同じ日に複数できない、宿題の時は遊ぶことはできない
# 最大何日間遊ぶことが出来るか
# 夏休み中に終わらせられない場合は、"-1"

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

# 処理
# 宿題にかかる合計日数
answer = n - sum(a)

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
task = []
for i in range(1,M + 1):
    task.append("A_" + str(i))

task = map(int, input().split())
task_total = sum(task)

if task_total <= N:
    print(N - task_total)

else:
    print(-1)

Submission status: Accepted

Solution code:
days_summer_vacation, amount_homework = map(int, input().split())
a = map(int, input().split())
schedule_hw = list(a)

need_days_hw = 0

for i in schedule_hw:
    need_days_hw += i


if days_summer_vacation > need_days_hw:
    print(days_summer_vacation - need_days_hw)
elif days_summer_vacation == need_days_hw:
    print(0)
else:
    print(-1)

Submission status: Accepted

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

answer = N - sum(A)

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

Submission status: Accepted

Solution code:
N , M = map(int,input().split())
C = list(map(int,input().split()))
r = 0
for i in range(M):
    r += C[i]

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def answer(n: int, m: int, a: []) -> int:
    return max(-1, n - sum(a))


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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

A_list = []
for i in range(1, M+1):
    A_list.append("A_" + str(i))
A_list = map(int,input().split())

answer = N - sum(A_list)

if answer >= 0:
    print(answer)
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()))

# x = 宿題をする日の合計
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()))
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 = []
for i in range(1, M+1):
    A_list.append("A_" + str(i))
A_list = map(int, input().split())

answer = N - sum(A_list)

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

Submission status: Accepted

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

if N >= B:
    print(N - B)
else:
    print("-1")

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# B - Homework

# N日の夏休みの間に、M個の宿題が出されており
# i番目の宿題にはAi日かかる。
# 夏休み中、最大何日遊ぶことができるか

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

answer = N - sum(A)

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

Submission status: Accepted

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

D = sum(A)

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

Submission status: Accepted

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

print(answer(N, M, A))

Submission status: Accepted

Solution code:
summer_vacation, homework = map(int, input().split())
days = list(map(int, input().split()))

if summer_vacation < sum(days):                 # if elseを逆にするとerrorが出る
    print(-1)
else:
    print(summer_vacation-sum(days))

Submission status: Accepted

Solution code:
# 163_b
N,M=map(int,input().split())
A=input().split()
for i in range(len(A)):
    A[i]=int(A[i])
if (1<=N and N<=10**6)and(1<=M and M<= 10**4):
    for j in range(len(A)):
        N-=A[j]
    if N >= 0:
        print(N)
    if N < 0:
        print('-1')

Submission status: Accepted

Solution code:
import numpy as np
 
N, M = map(int, input().split())
A = []
A = map(int, input().split())
 
dif = N - sum(A)
 
if dif >= 0:
  print(dif)
else:
  print('-1')

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
list1 = (input()).split(' ')
def answer(N: int, M: int, list1: list) -> int:
    homework_days = 0
    for i in range(0, M):
        homework_days += int(list1[i])
        i += 1
    if homework_days <= N:
        return N - homework_days
    else:
        return -1
print(answer(N, M, list1))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
*a,=map(int,input().split())
ans=n-sum(a)
print([-1,ans][ans>=0])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
A=input()
List_A=A.split()
day=0
for i in range(0,M):
    day=day+int(List_A[i])

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

Submission status: Accepted

Solution code:
# B - Homework
# https://atcoder.jp/contests/abc163/tasks/abc163_b

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

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

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

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:
sv,hm=map(int,input().split())
i=list(map(int,input().split()))
sum=0

for j in range(hm):
  sum+=i[j]
  
if sv-sum>=0:
  print(sv-sum)
else:
  print("-1")

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N,M = map(int, input().split())
data = list(map(int, input().split()))
S = 0
for i in range(0,len(data)):
    S += data[i]

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

Submission status: Accepted

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


def solve(N: int, M: int, A: "List[int]"):
    answer = N - sum(A)
    if answer < 0:
        answer = -1
    return answer


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(M)]  # type: "List[int]"
    answer = solve(N, M, A)
    print(answer)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def atc_163b(a: str, b: str) -> int:
    NM = a.split(" ")
    N = int(NM[0])
    M = int(NM[1])

    A = b.split(" ")
    A_int = [int(ai) for ai in A]
    play_days = N - sum(A_int)

    if play_days < 0:
        return -1
    else:
        return (play_days)

a = input()
b = input()

print(atc_163b(a, b))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
import math

N, M = map(int, input().split())
a = map(int, input().split())
A = 0
for i in a:
    A += i

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

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 数値の取得
holi,hw = map(int,input().split())
hw_day = list(map(int,input().split()))

# 判定結果を出力
hw_sum = sum(hw_day)
if hw_sum <= holi:
    print(holi - hw_sum)
else:
    print("-1")

Submission status: Accepted

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

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

ms = input().split()

for i in range(int(m)):
    n -= int(ms[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()))

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

Submission status: Accepted

Solution code:

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

if __name__ == "__main__":
    main()

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