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: Wrong Answer

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

def main():
    N, M, *A = map(int, read().split())
    ans = sum(A)
    if ans > N:
        ans == -1
    print(ans)
    return

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

homework=0

for a in A:
    homework+=a

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

Submission status: Wrong Answer

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

a = sum(list(map(int, input().split()))) 
ans = n - a

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

a_sum = sum(a)
ans = n-a_sum

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

tmp = []
for i in listA:
    tmp.append(int(i))
print(N - sum(tmp))

Submission status: Wrong Answer

Solution code:
import math
import operator as op
from functools import reduce

def ncr(n, r):
    r = min(r, n-r)
    numer = reduce(op.mul, range(n, n-r, -1), 1)
    denom = reduce(op.mul, range(1, r+1), 1)
    return numer / denom
"""
int(input())
map(int,input().split())
list(map(int,input().split()))
"""


            
       

t=1
for term in range(1,t+1):
    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: Wrong Answer

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: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
import math

S =  list(map(int,input().split()))
N = S[0]
M = S[1]
A =  list(map(int,input().split()))
ans = N-sum(A)
if ans <= 0:
    ans = -1
    
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(mi())
n,m = mi()
a = li()
if (sum(a) - n < 0):
    print("-1")
else:
    print(n - sum(a))

Submission status: Wrong Answer

Solution code:


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

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

Submission status: Wrong Answer

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

print(N - sum(A))

Submission status: Wrong Answer

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

sum = 0
for e in l:
    sum += e

x = N - sum
print(x)

Submission status: Wrong Answer

Solution code:
def b163(n, m, al):


    return n - sum(al) if n - sum(al) < 0 else "-1"

def main():
    n , m = map(int, input().split())
    al = list(map(int, input().split()))
    print(b163(n, m, al))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

import sys
import pprint

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)


def main():
	log = Logger(1)
	n, m = map(int, sys.stdin.readline().split())
	a = list(map(int, sys.stdin.readline().split()))
	print(n-sum(a))
	


main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,b=map(int,input().split())
a_list=list(map(int,input().split()))

s=0

for a in a_list:
    s+=a


if N-s <0:
    ans=0
else:
    ans=N-s

print(ans)

Submission status: Wrong Answer

Solution code:
import math

# N = int(input())
# S = int(input())

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

# l = raw_input().split()
Ms = list(map(int, input().split()))

print(N-sum(Ms))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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: Wrong Answer

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

Submission status: Wrong Answer

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


sumA = sum(A)

if sumA >= 0:
    print(NM[0]-sumA)

else:
    print("-1")

Submission status: Wrong Answer

Solution code:
def solve():
  n, m = map(int, input().split())
  a = list(map(int, input().split()))
  hoge = max(0, n-sum(a))
  if hoge > 0:
    print(a)
  else:
    print(-1)
  return 0
 
if __name__ == "__main__":
  solve()

Submission status: Wrong Answer

Solution code:
# python3
# -*- coding: utf-8 -*-
import sys
import math
import bisect
from fractions import gcd
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint

INF = float('inf')

ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
lmtx = lambda h: [list(map(int, lmis())) for _ in range(h)]
sys.setrecursionlimit(1000000000)


def lcm(a, b):
    return (a * b) // gcd(a, b)


# main
n, m = mis()
alist = lmis()

if n <= m:
    print('-1')
    exit(0)
else:
    print(str(n-sum(alist)))

Submission status: Wrong Answer

Solution code:
def solution():
    return 1

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

Submission status: Wrong Answer

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

print(n - sum(a))

Submission status: Wrong Answer

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

ans=n-sum(hw)
print(ans)

Submission status: Wrong Answer

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

ans = N - sum(A)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def solve():
  n, m = map(int, input().split())
  a = list(map(int, input().split()))
  hoge = max(0, n-sum(a))
  if hoge == 0:
    print(-1)
  else:
    print(a)
  return 0
 
if __name__ == "__main__":
  solve()

Submission status: Wrong Answer

Solution code:
import sys

n, m = map(int, sys.stdin.readline().split())

line = sys.stdin.readline().split()
nums = list(map(int, line))

print(n - sum(nums))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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: Wrong Answer

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: Wrong Answer

Solution code:
from sys import stdin


def get_result(data):
    N, M = data[0]
    A = data[1]
    return N - sum(A)


if __name__ == '__main__':
    raw_data = [val.rstrip() for val in stdin.readlines()]
    data = [list(map(int, val.split(' '))) for val in raw_data]
    result = get_result(data)
    print(result)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
a = list(map(int, input().split()))
for i in a:
  n -= i
print(n)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = n
for i in range(m):
    ans -= lis[i]
print(ans)

Submission status: Wrong Answer

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

ans = N
for i in range(M):
    ans -= a[i]

print(ans)

Submission status: Wrong Answer

Solution code:
N,M = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
wa = 0
for i in range(M):
    wa += a[i]
print(N-wa)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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: Wrong Answer

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: Wrong Answer

Solution code:
n,m=map(int,input().split())
arr=list(map(int,input().split()))
print(n-sum(arr))

Submission status: Wrong Answer

Solution code:
#author : dokueki

import sys
INT_MAX = sys.maxsize
INT_MIN = -(sys.maxsize)
sys.setrecursionlimit(10**7)
mod = 1000000007


def IOE():
    sys.stdin = open("input.txt", "r")
    sys.stdout = open("output.txt", "w")


def main():
    n, m = map(int, sys.stdin.readline().split())
    a = list(map(int, sys.stdin.readline().split()))
    print(max(0, n-sum(a)))


if __name__ == "__main__":
    try:
        IOE()
    except:
        pass
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    N, M = iim()
    A = sum(iim())

    print(N-A)

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
import sys, re
import math
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul	# 
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd	# 最大公約数
from heapq import heappush, heappop

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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

# -*- coding: utf-8 -*-


n, m = MAP()
a = LIST()

for x in a:
    n -= x

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

Submission status: Wrong Answer

Solution code:
N,K=[int(s) for s in input().split()]
ls=[int(s) for s in input().split()]
print(N-sum(ls))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import  deque
import sys
import bisect
import math
import itertools
from queue import deque
from math import gcd

INF = float('inf')
mod = 10**9+7
eps = 10**-7

def inp(): return int(sys.stdin.readline())
 
def inp_list(): return list(map(int, sys.stdin.readline().split()))

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

N, M = inp_list()
A = inp_list()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def solve():
  n, m = map(int, input().split())
  a = list(map(int, input().split()))
  print(max(0, n-sum(a)))
  return 0
 
if __name__ == "__main__":
  solve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

a_sum = sum(a)
ans = n-a_sum

if n > m and ans > 0:
    print(ans)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
s = input().split(" ")
N = int(s[0])
M = s[1]
s = input().split(" ")
A = []
sum = 0
for w in s:
    A.append(int(w))
    sum += int(w)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
import sys
N,M = list(map(int, sys.stdin.readline().rstrip().split())) 
A = list(map(int, sys.stdin.readline().rstrip().split())) 

s = 0
for n in range(M):
  s += A[n]
  
s -= N
if s < 0:
  print(-1)
else:
  print(s)

Submission status: Wrong Answer

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: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
import itertools

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

ans = N -sum(A)

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


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

    r = n - sum(a_list)
    print(r)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,m=INTM()
    a=LIST()
    print(n-sum(a))
if __name__ == '__main__':
    do()

Submission status: Wrong Answer

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

print(N-sum(A))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
l=list(map(int,input().split()))
for i in l:
  n-=i
print(n)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
N, M = map(int, input().split())
A = list(map(int, input().split()))
print(N - sum(A))

Submission status: Wrong Answer

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

import math

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

    print(n - sum(a_li))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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: Wrong Answer

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

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

sum_a = sum(a)
print(n-sum_a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

r = n-sum(a_list)
print(r if r > 0 else -1)

Submission status: Wrong Answer

Solution code:
import numpy as np


def solve():
    return n - np.sum(a)



n, m = [int(i) for i in input().split(" ")]
a = [int(i) for i in input().split(" ")]
print(solve())

Submission status: Wrong Answer

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: Wrong Answer

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

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

Submission status: Wrong Answer

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

a = sum(list(map(int, input().split())))

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
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


def main():
    n, m = MAP()
    a = LIST()
    print(n - sum(a))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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: Wrong Answer

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

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

Submission status: Wrong Answer

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: Wrong Answer

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

Submission status: Wrong Answer

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

print(max(0,n))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
l=list(map(int,input().split()))
ans=n
for i in l:
  ans-=i
  if ans<=0:
    ans=-1
    break
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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: Wrong Answer

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

Submission status: Accepted

Solution code:
def sep():
    return map(int,input().strip().split(" "))
def lis():
    return list(sep())


n,m=sep()
ar=lis()
k=sum(ar)
if k>n:
    print(-1)
else:
    print(n-k)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
A = list(map(int, input().split()))
assert len(A) == M
# M個の宿題, それぞれAi日かかる
yasumi = N - sum(A)
if yasumi >= 0:
  print(yasumi)
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())
total = sum(list(map(int, input().split())))

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

Submission status: Accepted

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

def main(n,m,a):
    days=sum(a)
    if days>n:
        return -1
    else:
        return n-days

if __name__=='__main__':
    n,m,a=readinput()
    ans=main(n,m,a)
    print(ans)

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 = list(map(int, input().split()))
a_total = sum(a_list)
ans = n - a_total

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M=list(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 math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    n,m = i_map()
    a = sum(i_list())
    if a > n:
        print(-1)
    else:
        print(n-a)




if __name__=="__main__":
    main()

Submission status: Accepted

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

answer = n - sum(list)
if n < sum(list):
    answer =  -1

print(answer)

Submission status: Accepted

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

total_days = sum(A)

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

Submission status: Accepted

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

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

sum = 0
for i in li:
    sum += i

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

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

Submission status: Accepted

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

Submission status: Accepted

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

x = 0
for day in days:
    x = x + int(day)

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

Submission status: Accepted

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

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

# 全ての宿題にかかる日数 sum(data)

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

Submission status: Accepted

Solution code:
import sys

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

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

sum_day = sum(A)

ans = N - sum_day

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