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


# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    n, m = input_to_int_map()
    a = input_to_int_tuple()

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

    return ret


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

Submission status: Accepted

Solution code:
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from functools import lru_cache, reduce
from math import gcd
from operator import add, itemgetter, mul, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


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

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

Submission status: Accepted

Solution code:
inf = 10**15
mod = 10**9+7

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

Submission status: Accepted

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

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

total_task = sum(A)
ans = N - total_task if N - total_task >= 0 else -1

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# import sys
# import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
INF = 1<<29
lINF = 1<<35

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

def main():
    n,m = readInt()
    a = readInt()
    s = sum(a)
    print(max(n-s,-1))
    return

if __name__=='__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
from collections import deque, Counter as cnt
from collections import defaultdict as dd
from operator import itemgetter as ig
from bisect import bisect_right as bsr
from math import factorial, ceil, floor
import sys
sys.setrecursionlimit(1000000)

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def nlist(n, v):
    if not n:
        return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]


def yesno(v):
    print(["Yes", "No"][not v])


# エントリーポイント
def main():
    N, M = input(int, int)
    A = input([int, M])
    ans = N - sum(A)
    print(ans if 0 <= ans else -1)


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

shuku = sum(A)

if shuku > N:
    print("-1")
else:
    print(N-shuku)

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():
    import sys
    sys.setrecursionlimit(10 ** 6)
    input = sys.stdin.readline
    N, M = [int(x) for x in input().strip().split()]
    A = sum([int(x) for x in input().strip().split()])
    if N - A < 0:
        print(-1)
    else:
        print(N - A)

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

Submission status: Accepted

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

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

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 = [int(i) for i in input().split()]
a = [int(i) for i in 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()))
print (n-sum(A)) if n >= sum(A) else print ("-1")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
from sys import setrecursionlimit
from collections import Counter, deque, defaultdict
from bisect import bisect_left
setrecursionlimit(1000000)

INF = int(1e10)
MOD = int(1e9 + 7)

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


def main():
    from builtins import int, map
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    if N < sum(A):
        print(-1)
    else:
        print(N - sum(A))
   
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
import sys
import numpy as np
import math
input=sys.stdin.readline

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

n,m=LI()
a=LI()
suma=sum(a)

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

A = sum(a)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

for v in A:
	n -= v

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

Submission status: Accepted

Solution code:
def main():
    n,m = tuple([int(t)for t in input().split()])
    a = tuple([int(t)for t in input().split()])

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    if N - sum(A) >= 0:
        return N - sum(A)
    else:
        return -1
print(main())
#if main():
#    print('Yes')
#else:
#    print('No')

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:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,m = map(int,input().split())
S = sum(map(int,input().split()))
if n >= S:
  print(n-S)
else:
  print(-1)

Submission status: Accepted

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


print(main())

Submission status: Accepted

Solution code:
#  n= int(input())
# import math
# s =input()
n,m = map(int, input().split())
a = list(map(int, input().split()))
# a,b = map(str, input().split())
# ab = [list(map(int,input().split())) for _ in range(n)]

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

Submission status: Accepted

Solution code:
n, m, *a = map(int, open(0).read().split())
x = n - sum(a)
print(x if x>=0 else -1)

Submission status: Accepted

Solution code:
import math
import copy
import sys
import fractions
# import numpy as np
# import statistics
import decimal
import heapq
import collections
import itertools
import bisect

# from operator import mul

sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputIntList():
    outputDataList = []
    inputData = input().split()
    outputDataList = [int(n) for n in inputData]

    return outputDataList


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

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

data = getInputIntList()

total = sum(data)

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

Submission status: Accepted

Solution code:
import sys

# S = input()
# N, M = map(int, input().split())
# nums = list(map(int, input().split()))
# nums_2d = [list(map(int, input().split())) for _ in range(N)]


def main():

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

    total = sum(As)
    ans = N - total if total <= N else -1
    print(ans)


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

Submission status: Accepted

Solution code:
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    n, m = nm()
    a = nl()

    if sum(a) > n:
        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()))

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

Submission status: Accepted

Solution code:
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N, M = list(map(int,_in[0].split(' ')))  # type:list(int)
    A_arr = list(map(int,_in[1].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = -1 if N - sum(A_arr)<0 else N - sum(A_arr)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)

Submission status: Accepted

Solution code:
N, M, *X = map(int, open(0).read().split())

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

Submission status: Accepted

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

ax = sum(a)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M, *A = map(int, read().split())
x = N - sum(A)
print(x if x >= 0 else -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:
#!/usr/bin/env python3
import sys


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


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(M)]  # type: "List[int]"
    solve(N, M, A)

if __name__ == '__main__':
    main()

Submission status: Accepted

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


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


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(M)]  # type: "List[int]"
    solve(N, M, A)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
LI = lambda: list(map(int,input().split()))
MI = lambda: map(int,input().split())
yes = lambda: print("YES")
no = lambda: print("NO")
I = lambda: list(input())
J = lambda x: "".join(x)
II = lambda: int(input())
SI = lambda: input()
#---khan17---template
n,m = MI()
a = LI()
c = n-sum(a)
print(c if c>=0 else -1)

Submission status: Accepted

Solution code:
import sys

n, m, *a = map(int, sys.stdin.read().split())

def main():
    r = n - sum(a)
    print(r if r >= 0 else -1)

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

Submission status: Accepted

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

sumcost = 0
for a in aes:
  sumcost += a

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

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:
str1 = str(input())
s1 = str1.split(' ')
n = int(s1[0])
m = int(s1[1])
str2 = str(input())
s2 = str2.split(' ')
l2 = [int(x) for x in s2]
if n<sum(l2):
    print('-1')
else:
    print(n-sum(l2))

Submission status: Accepted

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

sa = sum(aaa)
if sa > n:
    print(-1)
else:
    print(n - sa)

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

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

Submission status: Accepted

Solution code:

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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

if __name__ == '__main__':
    resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
A = list(map(int,input().split()))
tmp = N
for i in A:
    tmp -= i
ans = lambda x:x if x>=0 else -1
print(ans(tmp))

Submission status: Accepted

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


if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
a = list(map(int, input().split())) # list()でリスト化、それを変数に代入。

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from itertools import combinations # (string,3) 3回
#from collections import deque
#import collections.defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n,m = readInts()
    A = readInts()
    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()))

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

Submission status: Accepted

Solution code:
n, m = list(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:
# coding: utf-8

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

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

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
A = LIST()

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

ans = n-sum(a_L)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
a = [int(item) for item in input().split()]
total = sum(a)

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

Submission status: Accepted

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

sum_ = sum(A)

a = N - sum_

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

print(ans)

Submission status: Accepted

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

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


if __name__ == "__main__":
    resolve()

Submission status: Accepted

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


def solve(N: int, M: int, A: "List[int]"):
    s = sum(A)
    print(max(-1, N-s))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(M)]  # type: "List[int]"
    solve(N, M, A)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

s = sum(a)

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

Submission status: Accepted

Solution code:
import sys
from collections import *
import heapq
import math
from math import gcd
import bisect
import copy
from itertools import permutations,accumulate,combinations,product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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:
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

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

Submission status: Accepted

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

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

s = sum(a)

n -= s

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

Submission status: Accepted

Solution code:
import sys
from collections import deque
input = lambda: sys.stdin.readline().rstrip()
Yes = lambda boolean: print('Yes') if boolean else print('No')
YES = lambda boolean: print('YES') if boolean else print('NO')
aint = lambda: int(input())
ints = lambda: list(map(int, input().split()))
is_even = lambda x: True if x%2==0 else False
zeros2d = lambda r,c: [[0 for col in range(c)] for row in range(r)]

n,m = ints()
a = ints()
s = sum(a)
print(max(-1,n-s))

Submission status: Accepted

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