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:
import sys
readline = sys.stdin.readline

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

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

print(ans)

Submission status: Accepted

Solution code:

def submit():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    print(max(-1, n - sum(a)))


submit()

Submission status: Accepted

Solution code:
#create date: 2020-04-19 21:02

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n, m = na()
    a = na()
    ans = n - sum(a)
    print(ans if ans >= 0 else -1)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)

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

total = sum(A)
ans = N - total

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from collections import *
from math import *

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
input = sys.stdin.readline

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 = 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:
import sys
readline = sys.stdin.readline
import math

def main():
    N, M = map(int, readline().rstrip().split())
    A = list(map(int, readline().rstrip().split()))
    print(max(N-sum(A), -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)
    exit()

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:
def get_ints():
    return list(map(int, input().split()))

n, m = get_ints()
a = get_ints()
total = sum(a)
print(n - total if total <= n else -1)

Submission status: Accepted

Solution code:
n,m,*a=map(int,open(0).read().split())
s=sum(a)
print(max(-1,n-s))

Submission status: Accepted

Solution code:
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

n,m,*A = get_all_int()
ans = n - sum(A)
print(ans if ans >= 0 else -1)

Submission status: Accepted

Solution code:
"""
// Author : snape_here - Susanta Mukherjee
     
 """
 
from __future__ import division, print_function
 
import os,sys
from io import BytesIO, IOBase
 
if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
 
 
def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().split())
def li(): return list(mi())
 
 
def read():
    sys.stdin = open('input.txt', 'r')  
    sys.stdout = open('output.txt', 'w') 
 
def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

mod=1000000007

import math

import bisect

abc="abcdefghijklmnopqrstuvwxyz"

def main():

    n,m=mi()
    a=li()
    s=sum(a)
    if s>n:
        print(-1)
    else:
        print(n-sum(a))

        
# region fastio

 
BUFSIZE = 8192
 
 
class FastIO(IOBase):
    newlines = 0
 
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
 
 
def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()
 
 
if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
 
input = lambda: sys.stdin.readline().rstrip("\r\n")
 
# endregion
 
 
if __name__ == "__main__":
    #read()
    main()

Submission status: Accepted

Solution code:
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from heapq import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(l,n):
	zz = n - sum(l)
	if(zz < 0):
		return -1
	return n - sum(l)

N,M = list(map(int, stdin.readline().rstrip().split()))
l = list(map(int, stdin.readline().rstrip().split()))
ans = solve(l,N)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, m = list(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:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,m = LI()
a = LI()
if sum(a) <= n:
    print(n-sum(a))
else:
    print(-1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n, m = map(int, input().split())
    num_list = list(map(int, input().split()))

    sum_count = 0
    for i in range(m):
        sum_count += num_list[i]

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

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

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
a_array = [int(x) for x in input().split()]
print(max(-1, n-sum(a_array)))

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
input=lambda: sys.stdin.readline().rstrip()
n,m=map(int,input().split())
A=[int(i) for i in input().split()]
if sum(A)>n:
  print(-1)
else:
  print(n-sum(A))

Submission status: Accepted

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

sumA = sum(As)

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

Submission status: Accepted

Solution code:
from math import sqrt,ceil




# n=int(input())
# c,b=map(int,input().split())
# a=list(map(int,input().split()))

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

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

Submission status: Accepted

Solution code:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,m=LI()
  l=LI()

  sm=sum(l)
  if n<sm:
    return -1
  return n-sm

# main()
print(main())

Submission status: Accepted

Solution code:
# coding: utf-8
N, M = map(int, input().split())
A = list(map(int, input().split()))
v = N - sum(A)
print(v if v >= 0 else -1)

Submission status: Accepted

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

total = sum(A)

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

Submission status: Accepted

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

Submission status: Accepted

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

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


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys,collections as cl,bisect as bs,math
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n,k = m()
a = l()

po = n - sum(a)

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

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

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

Submission status: Accepted

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

Submission status: Accepted

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

import sys
sys.setrecursionlimit(300000)


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

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:
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


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


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


if __name__ == "__main__":
    main()

Submission status: Accepted

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


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:
def examA():
    N = I()

    ans = 0
    print(ans)
    return

def examB():
    N, M = LI()
    A = LI()
    S = sum(A)
    if N>=S:
        ans = N-S
    else:
        ans = -1
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(readline())
def LI(): return list(map(int,readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examB()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

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

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

S = sum(A)

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m = inpl()
a = inpl()
su = sum(a)
if n >= su:
    print(n-su)
else:
    print(-1)

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:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n,m=MI()
    aa=LI()
    ans=n-sum(aa)
    if ans<0:print(-1)
    else:print(ans)

main()

Submission status: Accepted

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

    return t if t >= 0 else -1

print(main())

Submission status: Runtime Error

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

Submission status: Runtime Error

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

ans1 = sum(A)
ans2 = N - ans1

if sns2 < 0:
    print(-1)
else:
    print(ans2)

Submission status: Runtime Error

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: Runtime Error

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

enjoy = N - sum(A)

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

else:
    print('-1')

Submission status: Runtime Error

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: Runtime Error

Solution code:
N = int(input())
M = int(input())
list =[]
homework = 0

for A in range(0, M):
    list.append(int(input()))
    homework = homework + list[A]

play = N - homework

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

Submission status: Runtime Error

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

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

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

# 処理
answer = n - sum(a)

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

Submission status: Runtime Error

Solution code:
int a[10010];
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++)scanf("%d",&a[i]);
    int s=0;
    for(int i=0;i<m;i++)s+=a[i];
    if(s>n){
        printf("-1\n");
    }else{
        printf("%d\n",n-s);
    }
}

Submission status: Runtime Error

Solution code:
day, assignment = map(int, input().split())
assignment_time = map(int, input().split())
if sum(assignment_time) > N:
    print(-1)
else:
    print(N - sum(assignment_time))

Submission status: Runtime Error

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

for i in range(M):
    A_sum += int(input())

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

n, m = getList()
nums = getList()
sn = sum(nums)
if sn > n:
  print(-1)
else:
  print(n - sn)

Submission status: Runtime Error

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

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

ans = n - sum(a)

if ans < 0:
    return -1
else:
    return ans

Submission status: Runtime Error

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

if N >= a:
  print(int(N-a))
if N < a:
  print(-1)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
N, M = map(int, input().spit())
A = [input() for _ in range(M)]

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split)
a = list(map(int, input().split()))
ct = 0
for i in range(m):
    ct += a[i]

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

Submission status: Runtime Error

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

c = 0
for i in range n:
  c += p[i]
  
if c > a:
  print(-1)
else:
  print(a-c)

Submission status: Runtime Error

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

if sum(A) < A:
    print(-1)
else:
    print(A - sum(A))

Submission status: Runtime Error

Solution code:
m,n,*aa = open(0).read().split()
ans = m-sum(aa)
if ans<0:
  print(-1)
else:
  print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
i = 100
count = 0
while N>i:
  count+=1
  i = int((i/100)*101)
print(count)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, M = map(int, input().split())
    A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

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




if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np

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

arr = np.array(lists)
days = arr.sum()

if days >= 0:
  print(int(n - days))
else:
  print('-1')

Submission status: Runtime Error

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)-1):
  hwsum += hw[n]

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

Submission status: Runtime Error

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)-1):
  hwsum += hw[n]

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

Submission status: Runtime Error

Solution code:
n = int(input("enter " ))
k =  int(input("enter " ))
sum =0 
for i in range(n) :
  l = int(input("enter " ))
  sum +=l 
n = n - sum 
if n >= 0 : 
  print(n)
else :
  print(-1)

Submission status: Runtime Error

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

ans=n

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

Submission status: Runtime Error

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

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