output_description
stringlengths
15
956
submission_id
stringlengths
10
10
status
stringclasses
3 values
problem_id
stringlengths
6
6
input_description
stringlengths
9
2.55k
attempt
stringlengths
1
13.7k
problem_description
stringlengths
7
5.24k
samples
stringlengths
2
2.72k
Print the integer in Takahashi's mind after he eats all the symbols. * * *
s769771439
Runtime Error
p03315
Input is given from Standard Input in the following format: S
s = input() a = 0 for i in range(4): a += 1 if s[i:i+1] == "+" else a -= 1 print(a)
Statement There is always an integer in Takahashi's mind. Initially, the integer in Takahashi's mind is 0. Takahashi is now going to eat four symbols, each of which is `+` or `-`. When he eats `+`, the integer in his mind increases by 1; when he eats `-`, the integer in his mind decreases by 1. The symbols Takahashi is going to eat are given to you as a string S. The i-th character in S is the i-th symbol for him to eat. Find the integer in Takahashi's mind after he eats all the symbols.
[{"input": "+-++", "output": "2\n \n\n * Initially, the integer in Takahashi's mind is 0.\n * The first integer for him to eat is `+`. After eating it, the integer in his mind becomes 1.\n * The second integer to eat is `-`. After eating it, the integer in his mind becomes 0.\n * The third integer to eat is `+`. After eating it, the integer in his mind becomes 1.\n * The fourth integer to eat is `+`. After eating it, the integer in his mind becomes 2.\n\nThus, the integer in Takahashi's mind after he eats all the symbols is 2.\n\n* * *"}, {"input": "-+--", "output": "-2\n \n\n* * *"}, {"input": "----", "output": "-4"}]
Print the integer in Takahashi's mind after he eats all the symbols. * * *
s583898444
Runtime Error
p03315
Input is given from Standard Input in the following format: S
S=input() a=0 for i in range(4): if i==='+': a+=1 else: a-=1 print(a)
Statement There is always an integer in Takahashi's mind. Initially, the integer in Takahashi's mind is 0. Takahashi is now going to eat four symbols, each of which is `+` or `-`. When he eats `+`, the integer in his mind increases by 1; when he eats `-`, the integer in his mind decreases by 1. The symbols Takahashi is going to eat are given to you as a string S. The i-th character in S is the i-th symbol for him to eat. Find the integer in Takahashi's mind after he eats all the symbols.
[{"input": "+-++", "output": "2\n \n\n * Initially, the integer in Takahashi's mind is 0.\n * The first integer for him to eat is `+`. After eating it, the integer in his mind becomes 1.\n * The second integer to eat is `-`. After eating it, the integer in his mind becomes 0.\n * The third integer to eat is `+`. After eating it, the integer in his mind becomes 1.\n * The fourth integer to eat is `+`. After eating it, the integer in his mind becomes 2.\n\nThus, the integer in Takahashi's mind after he eats all the symbols is 2.\n\n* * *"}, {"input": "-+--", "output": "-2\n \n\n* * *"}, {"input": "----", "output": "-4"}]
Print the integer in Takahashi's mind after he eats all the symbols. * * *
s249924337
Runtime Error
p03315
Input is given from Standard Input in the following format: S
s=input() count=0 for i in s: if i='+': count+=1 else: count-=1
Statement There is always an integer in Takahashi's mind. Initially, the integer in Takahashi's mind is 0. Takahashi is now going to eat four symbols, each of which is `+` or `-`. When he eats `+`, the integer in his mind increases by 1; when he eats `-`, the integer in his mind decreases by 1. The symbols Takahashi is going to eat are given to you as a string S. The i-th character in S is the i-th symbol for him to eat. Find the integer in Takahashi's mind after he eats all the symbols.
[{"input": "+-++", "output": "2\n \n\n * Initially, the integer in Takahashi's mind is 0.\n * The first integer for him to eat is `+`. After eating it, the integer in his mind becomes 1.\n * The second integer to eat is `-`. After eating it, the integer in his mind becomes 0.\n * The third integer to eat is `+`. After eating it, the integer in his mind becomes 1.\n * The fourth integer to eat is `+`. After eating it, the integer in his mind becomes 2.\n\nThus, the integer in Takahashi's mind after he eats all the symbols is 2.\n\n* * *"}, {"input": "-+--", "output": "-2\n \n\n* * *"}, {"input": "----", "output": "-4"}]
Print the integer in Takahashi's mind after he eats all the symbols. * * *
s836864244
Runtime Error
p03315
Input is given from Standard Input in the following format: S
S = input() ans = 0 for i in S: if i == "+": ans++ else: ans-- print(ans)
Statement There is always an integer in Takahashi's mind. Initially, the integer in Takahashi's mind is 0. Takahashi is now going to eat four symbols, each of which is `+` or `-`. When he eats `+`, the integer in his mind increases by 1; when he eats `-`, the integer in his mind decreases by 1. The symbols Takahashi is going to eat are given to you as a string S. The i-th character in S is the i-th symbol for him to eat. Find the integer in Takahashi's mind after he eats all the symbols.
[{"input": "+-++", "output": "2\n \n\n * Initially, the integer in Takahashi's mind is 0.\n * The first integer for him to eat is `+`. After eating it, the integer in his mind becomes 1.\n * The second integer to eat is `-`. After eating it, the integer in his mind becomes 0.\n * The third integer to eat is `+`. After eating it, the integer in his mind becomes 1.\n * The fourth integer to eat is `+`. After eating it, the integer in his mind becomes 2.\n\nThus, the integer in Takahashi's mind after he eats all the symbols is 2.\n\n* * *"}, {"input": "-+--", "output": "-2\n \n\n* * *"}, {"input": "----", "output": "-4"}]
Print the integer in Takahashi's mind after he eats all the symbols. * * *
s565613938
Runtime Error
p03315
Input is given from Standard Input in the following format: S
S = int(input()) A = S.count("+") B = S.count("-") print(A - B)
Statement There is always an integer in Takahashi's mind. Initially, the integer in Takahashi's mind is 0. Takahashi is now going to eat four symbols, each of which is `+` or `-`. When he eats `+`, the integer in his mind increases by 1; when he eats `-`, the integer in his mind decreases by 1. The symbols Takahashi is going to eat are given to you as a string S. The i-th character in S is the i-th symbol for him to eat. Find the integer in Takahashi's mind after he eats all the symbols.
[{"input": "+-++", "output": "2\n \n\n * Initially, the integer in Takahashi's mind is 0.\n * The first integer for him to eat is `+`. After eating it, the integer in his mind becomes 1.\n * The second integer to eat is `-`. After eating it, the integer in his mind becomes 0.\n * The third integer to eat is `+`. After eating it, the integer in his mind becomes 1.\n * The fourth integer to eat is `+`. After eating it, the integer in his mind becomes 2.\n\nThus, the integer in Takahashi's mind after he eats all the symbols is 2.\n\n* * *"}, {"input": "-+--", "output": "-2\n \n\n* * *"}, {"input": "----", "output": "-4"}]
Print the integer in Takahashi's mind after he eats all the symbols. * * *
s000391678
Runtime Error
p03315
Input is given from Standard Input in the following format: S
n = input().split() a = 0 for i in n: if i = "+" a+=1 else a-=1 print(a)
Statement There is always an integer in Takahashi's mind. Initially, the integer in Takahashi's mind is 0. Takahashi is now going to eat four symbols, each of which is `+` or `-`. When he eats `+`, the integer in his mind increases by 1; when he eats `-`, the integer in his mind decreases by 1. The symbols Takahashi is going to eat are given to you as a string S. The i-th character in S is the i-th symbol for him to eat. Find the integer in Takahashi's mind after he eats all the symbols.
[{"input": "+-++", "output": "2\n \n\n * Initially, the integer in Takahashi's mind is 0.\n * The first integer for him to eat is `+`. After eating it, the integer in his mind becomes 1.\n * The second integer to eat is `-`. After eating it, the integer in his mind becomes 0.\n * The third integer to eat is `+`. After eating it, the integer in his mind becomes 1.\n * The fourth integer to eat is `+`. After eating it, the integer in his mind becomes 2.\n\nThus, the integer in Takahashi's mind after he eats all the symbols is 2.\n\n* * *"}, {"input": "-+--", "output": "-2\n \n\n* * *"}, {"input": "----", "output": "-4"}]
Print the integer in Takahashi's mind after he eats all the symbols. * * *
s745823325
Runtime Error
p03315
Input is given from Standard Input in the following format: S
s = list(input()) cnt = 0 for i in s: if i = '+': cnt = cnt +1 if i = '-': cnt = cnt-1 print(cnt)
Statement There is always an integer in Takahashi's mind. Initially, the integer in Takahashi's mind is 0. Takahashi is now going to eat four symbols, each of which is `+` or `-`. When he eats `+`, the integer in his mind increases by 1; when he eats `-`, the integer in his mind decreases by 1. The symbols Takahashi is going to eat are given to you as a string S. The i-th character in S is the i-th symbol for him to eat. Find the integer in Takahashi's mind after he eats all the symbols.
[{"input": "+-++", "output": "2\n \n\n * Initially, the integer in Takahashi's mind is 0.\n * The first integer for him to eat is `+`. After eating it, the integer in his mind becomes 1.\n * The second integer to eat is `-`. After eating it, the integer in his mind becomes 0.\n * The third integer to eat is `+`. After eating it, the integer in his mind becomes 1.\n * The fourth integer to eat is `+`. After eating it, the integer in his mind becomes 2.\n\nThus, the integer in Takahashi's mind after he eats all the symbols is 2.\n\n* * *"}, {"input": "-+--", "output": "-2\n \n\n* * *"}, {"input": "----", "output": "-4"}]
Print the integer in Takahashi's mind after he eats all the symbols. * * *
s496579080
Runtime Error
p03315
Input is given from Standard Input in the following format: S
r = 0 s = input() for a in s: if a == “+”: r += 1 else: r -= 1 return r
Statement There is always an integer in Takahashi's mind. Initially, the integer in Takahashi's mind is 0. Takahashi is now going to eat four symbols, each of which is `+` or `-`. When he eats `+`, the integer in his mind increases by 1; when he eats `-`, the integer in his mind decreases by 1. The symbols Takahashi is going to eat are given to you as a string S. The i-th character in S is the i-th symbol for him to eat. Find the integer in Takahashi's mind after he eats all the symbols.
[{"input": "+-++", "output": "2\n \n\n * Initially, the integer in Takahashi's mind is 0.\n * The first integer for him to eat is `+`. After eating it, the integer in his mind becomes 1.\n * The second integer to eat is `-`. After eating it, the integer in his mind becomes 0.\n * The third integer to eat is `+`. After eating it, the integer in his mind becomes 1.\n * The fourth integer to eat is `+`. After eating it, the integer in his mind becomes 2.\n\nThus, the integer in Takahashi's mind after he eats all the symbols is 2.\n\n* * *"}, {"input": "-+--", "output": "-2\n \n\n* * *"}, {"input": "----", "output": "-4"}]
Print the answer. * * *
s449725538
Accepted
p03196
Input is given from Standard Input in the following format: N P
import sys sys.setrecursionlimit(10**5 + 10) def input(): return sys.stdin.readline().strip() def resolve(): n, p = map(int, input().split()) import math # cf. https://qiita.com/suecharo/items/14137fb74c26e2388f1f def make_prime_list_2(num): if num < 2: return [] # 0のものは素数じゃないとする prime_list = [i for i in range(num + 1)] prime_list[1] = 0 # 1は素数ではない num_sqrt = math.sqrt(num) for prime in prime_list: if prime == 0: continue if prime > num_sqrt: break for non_prime in range(2 * prime, num, prime): prime_list[non_prime] = 0 return [prime for prime in prime_list if prime != 0] def prime_factorization_2(num): """numの素因数分解 素因数をkeyに乗数をvalueに格納した辞書型dict_counterを返す""" if num <= 1: # 例えば1を食ったときの対処の仕方は問題によって違うと思うのでそのつど考える。 # cf. https://atcoder.jp/contests/abc110/submissions/12688244 return False else: num_sqrt = math.floor(math.sqrt(num)) prime_list = make_prime_list_2(num_sqrt) dict_counter = ( {} ) # 何度もこの関数を呼び出して辞書を更新したい時はこれを引数にして # cf. https://atcoder.jp/contests/arc034/submissions/12251452 for prime in prime_list: while num % prime == 0: if prime in dict_counter: dict_counter[prime] += 1 else: dict_counter[prime] = 1 num //= prime if num != 1: if num in dict_counter: dict_counter[num] += 1 else: dict_counter[num] = 1 return dict_counter if p != 1: d = prime_factorization_2(p) ans = 1 for k, v in d.items(): if v >= n: ans *= k ** (v // n) print(ans) else: print(1) resolve()
Statement There are N integers a_1, a_2, ..., a_N not less than 1. The values of a_1, a_2, ..., a_N are not known, but it is known that a_1 \times a_2 \times ... \times a_N = P. Find the maximum possible greatest common divisor of a_1, a_2, ..., a_N.
[{"input": "3 24", "output": "2\n \n\nThe greatest common divisor would be 2 when, for example, a_1=2, a_2=6 and\na_3=2.\n\n* * *"}, {"input": "5 1", "output": "1\n \n\nAs a_i are positive integers, the only possible case is a_1 = a_2 = a_3 = a_4\n= a_5 = 1.\n\n* * *"}, {"input": "1 111", "output": "111\n \n\n* * *"}, {"input": "4 972439611840", "output": "206"}]
Print the answer. * * *
s715116276
Wrong Answer
p03196
Input is given from Standard Input in the following format: N P
#!/usr/bin/env python3 import sys from typing import ( Any, Callable, Deque, Dict, List, Mapping, Optional, Sequence, Set, Tuple, TypeVar, Union, ) # import time # import math # import numpy as np # import scipy.sparse.csgraph as cs # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall # import random # random, uniform, randint, randrange, shuffle, sample # import string # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits # import re # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s) # from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]). # from collections import deque # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate() # from collections import defaultdict # subclass of dict. defaultdict(facroty) # from collections import Counter # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter) # from datetime import date, datetime # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj # from datetime.datetime import strptime # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj # from datetime import timedelta # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available. # from copy import copy, deepcopy # use deepcopy to copy multi-dimentional matrix without reference # from functools import reduce # reduce(f, iter[, init]) # from functools import lru_cache # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed) # from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn). # from heapq import nlargest, nsmallest # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn). # from itertools import count, cycle, repeat # count(start[,step]), cycle(iter), repeat(elm[,n]) # from itertools import groupby # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])] # from itertools import starmap # starmap(pow, [[2,5], [3,2]]) returns [32, 9] # from itertools import product, permutations # product(iter, repeat=n), permutations(iter[,r]) # from itertools import combinations, combinations_with_replacement # from itertools import accumulate # accumulate(iter[, f]) # from operator import itemgetter # itemgetter(1), itemgetter('key') # from fractions import Fraction # Fraction(a, b) => a / b ∈ Q. note: Fraction(0.1) do not returns Fraciton(1, 10). Fraction('0.1') returns Fraction(1, 10) def main(): mod = 1000000007 # 10^9+7 inf = float("inf") # sys.float_info.max = 1.79e+308 # inf = 2 ** 63 - 1 # (for fast JIT compile in PyPy) 9.22e+18 sys.setrecursionlimit(10**6) # 1000 -> 1000000 def input(): return sys.stdin.readline().rstrip() def ii(): return int(input()) def isp(): return input().split() def mi(): return map(int, input().split()) def mi_0(): return map(lambda x: int(x) - 1, input().split()) def lmi(): return list(map(int, input().split())) def lmi_0(): return list(map(lambda x: int(x) - 1, input().split())) def li(): return list(input()) import math class Eratos: def __init__(self, num): """ O(nlglgn) で num までの素数判定テーブルを作る >>> e = Eratos(10) >>> e.table [False, False, True, True, False, True, False, True, False, False, False] """ assert num >= 1 self.table_max = num # self.table[i] は i が素数かどうかを示す (bool) self.table = [False if i == 0 or i == 1 else True for i in range(num + 1)] for i in range(2, int(math.sqrt(num)) + 1): if self.table[i]: for j in range( i**2, num + 1, i ): # i**2 からスタートすることで定数倍高速化できる self.table[j] = False def is_prime(self, num): """ O(1) で素数判定を行う >>> e = Eratos(100) >>> [i for i in range(1, 101) if e.is_prime(i)] [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97] """ assert num >= 1 if num > self.table_max: raise ValueError( "Eratos.is_prime(): exceed table_max({}). got {}".format( self.table_max, num ) ) return self.table[num] def prime_factorize(self, num): """ O(√n) で素因数分解を行う >>> e = Eratos(10000) >>> e.prime_factorize(6552) {2: 3, 3: 2, 7: 1, 13: 1} """ assert num >= 1 if int(math.sqrt(num)) > self.table_max: raise ValueError( "Eratos.prime_factorize(): exceed prime table size. got {}".format( num ) ) # 素因数分解の結果を記録する辞書 factorized_dict = dict() candidate_prime_numbers = [ i for i in range(2, int(math.sqrt(num)) + 1) if self.is_prime(i) ] # n について、√n 以下の素数で割り続けると最後には 1 or 素数となる # 背理法を考えれば自明 (残された数が √n より上の素数の積であると仮定。これは自明に n を超えるため矛盾) for p in candidate_prime_numbers: if num == 1: # これ以上調査は無意味 break if num % p == 0: cnt = 0 while num % p == 0: num //= p cnt += 1 factorized_dict[p] = cnt if num != 1: factorized_dict[num] = 1 return factorized_dict n, p = mi() e = Eratos(10**6 + 1) if p == 1: print(1) else: d = e.prime_factorize(p) gcd = 1 for k, v in d.items(): if v >= n: gcd *= k * (v // n) print(gcd) if __name__ == "__main__": main()
Statement There are N integers a_1, a_2, ..., a_N not less than 1. The values of a_1, a_2, ..., a_N are not known, but it is known that a_1 \times a_2 \times ... \times a_N = P. Find the maximum possible greatest common divisor of a_1, a_2, ..., a_N.
[{"input": "3 24", "output": "2\n \n\nThe greatest common divisor would be 2 when, for example, a_1=2, a_2=6 and\na_3=2.\n\n* * *"}, {"input": "5 1", "output": "1\n \n\nAs a_i are positive integers, the only possible case is a_1 = a_2 = a_3 = a_4\n= a_5 = 1.\n\n* * *"}, {"input": "1 111", "output": "111\n \n\n* * *"}, {"input": "4 972439611840", "output": "206"}]
Print the answer. * * *
s329022909
Accepted
p03196
Input is given from Standard Input in the following format: N P
import sys import collections input_methods = ["clipboard", "file", "key"] using_method = 0 input_method = input_methods[using_method] tin = lambda: map(int, input().split()) lin = lambda: list(tin()) mod = 1000000007 # +++++ def main(): # a = int(input()) n, p = tin() # s = input() bb = collections.defaultdict(lambda: 0) tp = p for i in range(2, p): if tp % i == 0: while tp % i == 0: bb[i] += 1 tp = tp // i if i * i > tp: bb[tp] += 1 break rr = 1 for k in bb: # pa((k, bb[k])) if bb[k] >= n: rr *= k ** (bb[k] // n) print(rr) # +++++ isTest = False def pa(v): if isTest: print(v) def input_clipboard(): import clipboard input_text = clipboard.get() input_l = input_text.splitlines() for l in input_l: yield l if __name__ == "__main__": if sys.platform == "ios": if input_method == input_methods[0]: ic = input_clipboard() input = lambda: ic.__next__() elif input_method == input_methods[1]: sys.stdin = open("inputFile.txt") else: pass isTest = True else: pass # input = sys.stdin.readline ret = main() if ret is not None: print(ret)
Statement There are N integers a_1, a_2, ..., a_N not less than 1. The values of a_1, a_2, ..., a_N are not known, but it is known that a_1 \times a_2 \times ... \times a_N = P. Find the maximum possible greatest common divisor of a_1, a_2, ..., a_N.
[{"input": "3 24", "output": "2\n \n\nThe greatest common divisor would be 2 when, for example, a_1=2, a_2=6 and\na_3=2.\n\n* * *"}, {"input": "5 1", "output": "1\n \n\nAs a_i are positive integers, the only possible case is a_1 = a_2 = a_3 = a_4\n= a_5 = 1.\n\n* * *"}, {"input": "1 111", "output": "111\n \n\n* * *"}, {"input": "4 972439611840", "output": "206"}]
Print the answer. * * *
s294958707
Runtime Error
p03196
Input is given from Standard Input in the following format: N P
from collections import defaultdict N, P = map(int, input().split()) dic = defaultdict(int) MAX = int(P**0.5)+1 for p in range(2, MAX): while P % p == 0: dic[p] += 1 P //= p if P: dic[P] += 1 ans = 1 print(dic)1 for p, cnt in dic.items(): ans *= pow(p, cnt//N) print(ans)
Statement There are N integers a_1, a_2, ..., a_N not less than 1. The values of a_1, a_2, ..., a_N are not known, but it is known that a_1 \times a_2 \times ... \times a_N = P. Find the maximum possible greatest common divisor of a_1, a_2, ..., a_N.
[{"input": "3 24", "output": "2\n \n\nThe greatest common divisor would be 2 when, for example, a_1=2, a_2=6 and\na_3=2.\n\n* * *"}, {"input": "5 1", "output": "1\n \n\nAs a_i are positive integers, the only possible case is a_1 = a_2 = a_3 = a_4\n= a_5 = 1.\n\n* * *"}, {"input": "1 111", "output": "111\n \n\n* * *"}, {"input": "4 972439611840", "output": "206"}]
Print the answer. * * *
s297332036
Accepted
p03196
Input is given from Standard Input in the following format: N P
import sys from sys import exit from collections import deque from bisect import ( bisect_left, bisect_right, insort_left, insort_right, ) # func(リスト,値) from heapq import heapify, heappop, heappush from itertools import product, permutations, combinations, combinations_with_replacement from functools import reduce from math import sin, cos, tan, asin, acos, atan, degrees, radians sys.setrecursionlimit(10**6) INF = 10**20 eps = 1.0e-20 MOD = 10**9 + 7 def lcm(x, y): return x * y // gcd(x, y) def lgcd(l): return reduce(gcd, l) def llcm(l): return reduce(lcm, l) def powmod(n, i, mod): return pow(n, mod - 1 + i, mod) if i < 0 else pow(n, i, mod) def div2(x): return x.bit_length() def div10(x): return len(str(x)) - (x == 0) def perm(n, mod=None): ans = 1 for i in range(1, n + 1): ans *= i if mod != None: ans %= mod return ans def intput(): return int(input()) def mint(): return map(int, input().split()) def lint(): return list(map(int, input().split())) def ilint(): return int(input()), list(map(int, input().split())) def judge(x, l=["Yes", "No"]): print(l[0] if x else l[1]) def lprint(l, sep="\n"): for x in l: print(x, end=sep) def ston(c, c0="a"): return ord(c) - ord(c0) def ntos(x, c0="a"): return chr(x + ord(c0)) class counter(dict): def __init__(self, *args): super().__init__(args) def add(self, x, d=1): self.setdefault(x, 0) self[x] += d class comb: def __init__(self, n, mod=None): self.l = [1] self.n = n self.mod = mod def get(self, k): l, n, mod = self.l, self.n, self.mod k = n - k if k > n // 2 else k while len(l) <= k: i = len(l) l.append( l[i - 1] * (n + 1 - i) // i if mod == None else (l[i - 1] * (n + 1 - i) * powmod(i, -1, mod)) % mod ) return l[k] N, P = mint() ans = 1 p = 2 while P > 1: if P % p == 0: n = 0 while P % p == 0: n += 1 P //= p if n == N: ans *= p n = 0 p = p + 1 if p * p < P else P print(ans)
Statement There are N integers a_1, a_2, ..., a_N not less than 1. The values of a_1, a_2, ..., a_N are not known, but it is known that a_1 \times a_2 \times ... \times a_N = P. Find the maximum possible greatest common divisor of a_1, a_2, ..., a_N.
[{"input": "3 24", "output": "2\n \n\nThe greatest common divisor would be 2 when, for example, a_1=2, a_2=6 and\na_3=2.\n\n* * *"}, {"input": "5 1", "output": "1\n \n\nAs a_i are positive integers, the only possible case is a_1 = a_2 = a_3 = a_4\n= a_5 = 1.\n\n* * *"}, {"input": "1 111", "output": "111\n \n\n* * *"}, {"input": "4 972439611840", "output": "206"}]
Print the answer. * * *
s323689570
Wrong Answer
p03196
Input is given from Standard Input in the following format: N P
def exEuqrid(a, b): list = [a, b] listx = [1, 0] listy = [0, 1] while list[1] != 0: list.append(list[0] % list[1]) q = list[0] // list[1] listx.append(listx[0] - (q * listx[1])) listy.append(listy[0] - (q * listy[1])) list.pop(0) listx.pop(0) listy.pop(0) ans = [] ans.append(listx[0]) ans.append(listy[0]) ans.append(list[0]) return ans x, y = map(int, input().split()) if x < y: z = y y = x x = z print(exEuqrid(x, y)[2])
Statement There are N integers a_1, a_2, ..., a_N not less than 1. The values of a_1, a_2, ..., a_N are not known, but it is known that a_1 \times a_2 \times ... \times a_N = P. Find the maximum possible greatest common divisor of a_1, a_2, ..., a_N.
[{"input": "3 24", "output": "2\n \n\nThe greatest common divisor would be 2 when, for example, a_1=2, a_2=6 and\na_3=2.\n\n* * *"}, {"input": "5 1", "output": "1\n \n\nAs a_i are positive integers, the only possible case is a_1 = a_2 = a_3 = a_4\n= a_5 = 1.\n\n* * *"}, {"input": "1 111", "output": "111\n \n\n* * *"}, {"input": "4 972439611840", "output": "206"}]
Print the answer. * * *
s743998819
Runtime Error
p03196
Input is given from Standard Input in the following format: N P
from fractions import gcd from random import randint def brent(N): # brent returns a divisor not guaranteed to be prime, returns n if n prime if N % 2 == 0: return 2 y, c, m = randint(1, N - 1), randint(1, N - 1), randint(1, N - 1) g, r, q = 1, 1, 1 while g == 1: x = y for i in range(r): y = ((y * y) % N + c) % N k = 0 while k < r and g == 1: ys = y for i in range(min(m, r - k)): y = ((y * y) % N + c) % N q = q * (abs(x - y)) % N g = gcd(q, N) k = k + m r = r * 2 if g == N: while True: ys = ((ys * ys) % N + c) % N g = gcd(abs(x - ys), N) if g > 1: break return g def factorize(n1): if n1 <= 0: return [] if n1 == 1: return [1] n = n1 t = {} p = 0 mx = 1000000 if n % 2 == 0: t[2] = 0 if n % 3 == 0: t[3] = 0 while n % 2 == 0: t[2] += 1 n //= 2 while n % 3 == 0: t[3] += 1 n //= 3 i = 5 inc = 2 # print(n) # use trial division for factors below 1M while i <= mx: while n % i == 0: if i not in t.keys(): t[i] = 0 t[i] += 1 n //= i i += inc inc = 6 - inc # use brent for factors >1M # print(t) while n > mx: p1 = n # iterate until n=brent(n) => n is prime while p1 != p: p = p1 p1 = brent(p) # print(p1) if p1 not in t.keys(): t[p1] = 0 t[p1] += 1 n //= p1 # print(n) if n != 1: t[n] = 1 return t from functools import reduce from sys import argv def main(): n, p = tuple(map(int, input().strip().split())) q = factorize(p) # print(q) ans = 1 for a in q.keys(): q[a] //= n ans = ans * (a ** q[a]) print(ans) if __name__ == "__main__": main()
Statement There are N integers a_1, a_2, ..., a_N not less than 1. The values of a_1, a_2, ..., a_N are not known, but it is known that a_1 \times a_2 \times ... \times a_N = P. Find the maximum possible greatest common divisor of a_1, a_2, ..., a_N.
[{"input": "3 24", "output": "2\n \n\nThe greatest common divisor would be 2 when, for example, a_1=2, a_2=6 and\na_3=2.\n\n* * *"}, {"input": "5 1", "output": "1\n \n\nAs a_i are positive integers, the only possible case is a_1 = a_2 = a_3 = a_4\n= a_5 = 1.\n\n* * *"}, {"input": "1 111", "output": "111\n \n\n* * *"}, {"input": "4 972439611840", "output": "206"}]
Print the maximum possible number of times he waked up early during the recorded period. * * *
s786072265
Wrong Answer
p03895
The input is given from Standard Input in the following format: N a_1 b_1 a_2 b_2 : a_N b_N
import sys import bisect input = sys.stdin.readline def cumsum(inlist): s = 0 outlist = [] for i in inlist: s += i outlist.append(s) return outlist oneday = 86400 time = [0 for i in range(oneday)] n = int(input()) t = 0 for i in range(n): a, b = [int(v) for v in input().split()] t = (t + a) % oneday time[t] += 1 t = (t + b) % oneday time = time * 2 timesum = cumsum(time) ans_list = [] for i in range(oneday * 2 - 20000): ans_list.append(timesum[i + 10800] - timesum[i]) print(max(ans_list))
Statement Takahashi recorded his daily life for the last few days as a integer sequence of length 2N, as follows: * a_1, b_1, a_2, b_2, ... , a_N, b_N This means that, starting from a certain time T, he was: * sleeping for exactly a_1 seconds * then awake for exactly b_1 seconds * then sleeping for exactly a_2 seconds * : * then sleeping for exactly a_N seconds * then awake for exactly b_N seconds In this record, he waked up N times. Takahashi is wondering how many times he waked up early during the recorded period. Here, he is said to _wake up early_ if he wakes up between 4:00 AM and 7:00 AM, inclusive. If he wakes up more than once during this period, each of these awakenings is counted as waking up early. Unfortunately, he forgot the time T. Find the maximum possible number of times he waked up early during the recorded period. For your information, a day consists of 86400 seconds, and the length of the period between 4:00 AM and 7:00 AM is 10800 seconds.
[{"input": "3\n 28800 57600\n 28800 57600\n 57600 28800", "output": "2\n \n\n* * *"}, {"input": "10\n 28800 57600\n 4800 9600\n 6000 1200\n 600 600\n 300 600\n 5400 600\n 6000 5760\n 6760 2880\n 6000 12000\n 9000 600", "output": "5"}]
Print the maximum possible number of times he waked up early during the recorded period. * * *
s923319911
Wrong Answer
p03895
The input is given from Standard Input in the following format: N a_1 b_1 a_2 b_2 : a_N b_N
n = int(input()) x, num = [], 0 for i in range(n): a, b = (int(j) for j in input().split()) x.append((num + a) % 86400) num = (num + a + b) % 86400 x, ans = sorted(x), 0 from bisect import bisect for i in range(n): ans = max(ans, bisect(x, x[i] + 10800) - i) print(ans)
Statement Takahashi recorded his daily life for the last few days as a integer sequence of length 2N, as follows: * a_1, b_1, a_2, b_2, ... , a_N, b_N This means that, starting from a certain time T, he was: * sleeping for exactly a_1 seconds * then awake for exactly b_1 seconds * then sleeping for exactly a_2 seconds * : * then sleeping for exactly a_N seconds * then awake for exactly b_N seconds In this record, he waked up N times. Takahashi is wondering how many times he waked up early during the recorded period. Here, he is said to _wake up early_ if he wakes up between 4:00 AM and 7:00 AM, inclusive. If he wakes up more than once during this period, each of these awakenings is counted as waking up early. Unfortunately, he forgot the time T. Find the maximum possible number of times he waked up early during the recorded period. For your information, a day consists of 86400 seconds, and the length of the period between 4:00 AM and 7:00 AM is 10800 seconds.
[{"input": "3\n 28800 57600\n 28800 57600\n 57600 28800", "output": "2\n \n\n* * *"}, {"input": "10\n 28800 57600\n 4800 9600\n 6000 1200\n 600 600\n 300 600\n 5400 600\n 6000 5760\n 6760 2880\n 6000 12000\n 9000 600", "output": "5"}]
Print the minimum total Magic Points that have to be consumed before winning. * * *
s719883303
Wrong Answer
p02787
Input is given from Standard Input in the following format: H N A_1 B_1 : A_N B_N
import unittest class TestE(unittest.TestCase): def test_1(self): self.assertEqual(think(9, [[8, 3], [4, 2], [2, 1]]), 4) def test_2(self): self.assertEqual( think(100, [[1, 1], [2, 3], [3, 9], [4, 27], [5, 81], [6, 243]]), 100 ) def test_3(self): self.assertEqual( think( 9999, [ [540, 7550], [691, 9680], [700, 9790], [510, 7150], [415, 5818], [551, 7712], [587, 8227], [619, 8671], [588, 8228], [176, 2461], ], ), 139815, ) def solve(): h, list_of_a_and_b = read() result = think(h, list_of_a_and_b) write(result) def read(): h, n = read_int(2) list_of_a_and_b = [] for _ in range(n): list_of_a_and_b.append(read_int(2)) return h, list_of_a_and_b def read_int(n): return read_type(int, n, sep=" ") def read_float(n): return read_type(float, n, sep=" ") def read_type(t, n, sep): return list(map(lambda x: t(x), read_line().split(sep)))[:n] def read_line(n=0): if n == 0: return input().rstrip() else: return input().rstrip()[:n] def think(h, list_of_a_and_b): list_of_ratio_and_a_and_b = [] for a, b in list_of_a_and_b: list_of_ratio_and_a_and_b.append((a / b, a, b)) list_of_ratio_and_a_and_b.sort(key=lambda x: -x[0]) return recursive_solve(list_of_ratio_and_a_and_b, 0, h) def write(result): print(result) def recursive_solve(list_of_ratio_and_a_and_b, index, remain): min_of_a = 1 max_of_b = 10**4 max_of_h = 10**4 inf = (max_of_h // min_of_a) * max_of_b + 1 if index >= len(list_of_ratio_and_a_and_b): return inf ratio_and_a_and_b = list_of_ratio_and_a_and_b[index] # (a / b, a, b) a, b = ratio_and_a_and_b[1], ratio_and_a_and_b[2] if remain % a == 0: return b * (remain // a) else: ret = inf if remain <= a: ret = b next_remain = remain - a * (remain // a) ret = min( ret, b * (remain // a + 1), b * (remain // a) + recursive_solve(list_of_ratio_and_a_and_b, index + 1, next_remain), ) return ret if __name__ == "__main__": # unittest.main() solve()
Statement Ibis is fighting with a monster. The _health_ of the monster is H. Ibis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points. The same spell can be cast multiple times. There is no way other than spells to decrease the monster's health. Ibis wins when the health of the monster becomes 0 or below. Find the minimum total Magic Points that have to be consumed before winning.
[{"input": "9 3\n 8 3\n 4 2\n 2 1", "output": "4\n \n\nFirst, let us cast the first spell to decrease the monster's health by 8, at\nthe cost of 3 Magic Points. The monster's health is now 1.\n\nThen, cast the third spell to decrease the monster's health by 2, at the cost\nof 1 Magic Point. The monster's health is now -1.\n\nIn this way, we can win at the total cost of 4 Magic Points.\n\n* * *"}, {"input": "100 6\n 1 1\n 2 3\n 3 9\n 4 27\n 5 81\n 6 243", "output": "100\n \n\nIt is optimal to cast the first spell 100 times.\n\n* * *"}, {"input": "9999 10\n 540 7550\n 691 9680\n 700 9790\n 510 7150\n 415 5818\n 551 7712\n 587 8227\n 619 8671\n 588 8228\n 176 2461", "output": "139815"}]
Print the minimum total Magic Points that have to be consumed before winning. * * *
s324120136
Runtime Error
p02787
Input is given from Standard Input in the following format: H N A_1 B_1 : A_N B_N
import sys def solve(h, n, ab): ab.sort(key=lambda x: x[1] / x[0]) INF = 10**18 cache = {} # とりあえず一番コスパいいやつだけを使った結果を暫定最良値としておく best = ((h - 1) // ab[0][0] + 1) * ab[0][1] def dp(k, i=0, cost=0): nonlocal best if k <= 0: return cost if (k, i) in cache: return cache[k, i] + cost a, b = ab[i] if k / a * b + cost >= best: # どう足掻いても残りでbestより良い結果は得られない return INF c = (k - 1) // a + 1 if i == n - 1: ret = cost + b * c else: ret = min(dp(k - a * j, i + 1, cost + b * j) for j in range(c + 1)) cache[k, i] = ret - cost best = min(best, ret) return ret dp(h) return best sys.setrecursionlimit(1001) h, n = map(int, input().split()) ab = [tuple(map(int, line.split())) for line in sys.stdin] print(solve(h, n, ab))
Statement Ibis is fighting with a monster. The _health_ of the monster is H. Ibis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points. The same spell can be cast multiple times. There is no way other than spells to decrease the monster's health. Ibis wins when the health of the monster becomes 0 or below. Find the minimum total Magic Points that have to be consumed before winning.
[{"input": "9 3\n 8 3\n 4 2\n 2 1", "output": "4\n \n\nFirst, let us cast the first spell to decrease the monster's health by 8, at\nthe cost of 3 Magic Points. The monster's health is now 1.\n\nThen, cast the third spell to decrease the monster's health by 2, at the cost\nof 1 Magic Point. The monster's health is now -1.\n\nIn this way, we can win at the total cost of 4 Magic Points.\n\n* * *"}, {"input": "100 6\n 1 1\n 2 3\n 3 9\n 4 27\n 5 81\n 6 243", "output": "100\n \n\nIt is optimal to cast the first spell 100 times.\n\n* * *"}, {"input": "9999 10\n 540 7550\n 691 9680\n 700 9790\n 510 7150\n 415 5818\n 551 7712\n 587 8227\n 619 8671\n 588 8228\n 176 2461", "output": "139815"}]
Print the minimum total Magic Points that have to be consumed before winning. * * *
s867703252
Accepted
p02787
Input is given from Standard Input in the following format: H N A_1 B_1 : A_N B_N
def main(): h, n = map(int, input().split()) ab = sorted( [tuple(map(int, input().split())) for _ in range(n)], key=lambda x: x[1] ) mn = [0] for i, j in ab: if i > len(mn) - 1: mn.extend([j] * (i - len(mn) + 1)) for i in range(1, len(mn)): for j in range(1, i): x = mn[j] cost = (i // j) * x + mn[i - (i // j) * j] if cost < mn[i]: mn[i] = cost if h <= len(mn) - 1: print(mn[h]) else: c = len(mn) while True: s = 10**9 for i in range(1, len(mn)): s = min(s, mn[i] + mn[-i]) mn.append(s) if c == h: print(mn[-1]) break else: c += 1 if __name__ == "__main__": main()
Statement Ibis is fighting with a monster. The _health_ of the monster is H. Ibis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points. The same spell can be cast multiple times. There is no way other than spells to decrease the monster's health. Ibis wins when the health of the monster becomes 0 or below. Find the minimum total Magic Points that have to be consumed before winning.
[{"input": "9 3\n 8 3\n 4 2\n 2 1", "output": "4\n \n\nFirst, let us cast the first spell to decrease the monster's health by 8, at\nthe cost of 3 Magic Points. The monster's health is now 1.\n\nThen, cast the third spell to decrease the monster's health by 2, at the cost\nof 1 Magic Point. The monster's health is now -1.\n\nIn this way, we can win at the total cost of 4 Magic Points.\n\n* * *"}, {"input": "100 6\n 1 1\n 2 3\n 3 9\n 4 27\n 5 81\n 6 243", "output": "100\n \n\nIt is optimal to cast the first spell 100 times.\n\n* * *"}, {"input": "9999 10\n 540 7550\n 691 9680\n 700 9790\n 510 7150\n 415 5818\n 551 7712\n 587 8227\n 619 8671\n 588 8228\n 176 2461", "output": "139815"}]
Print the minimum total Magic Points that have to be consumed before winning. * * *
s393036677
Accepted
p02787
Input is given from Standard Input in the following format: H N A_1 B_1 : A_N B_N
h, n = map(int, input().split()) p = [list(map(int, input().split())) for _ in range(n)] m = 10**4 dp = [0] * (h + m + 1) for i in range(m + 1, h + m + 1): dp[i] = min(dp[i - a] + b for a, b in p) print(dp[h + m])
Statement Ibis is fighting with a monster. The _health_ of the monster is H. Ibis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points. The same spell can be cast multiple times. There is no way other than spells to decrease the monster's health. Ibis wins when the health of the monster becomes 0 or below. Find the minimum total Magic Points that have to be consumed before winning.
[{"input": "9 3\n 8 3\n 4 2\n 2 1", "output": "4\n \n\nFirst, let us cast the first spell to decrease the monster's health by 8, at\nthe cost of 3 Magic Points. The monster's health is now 1.\n\nThen, cast the third spell to decrease the monster's health by 2, at the cost\nof 1 Magic Point. The monster's health is now -1.\n\nIn this way, we can win at the total cost of 4 Magic Points.\n\n* * *"}, {"input": "100 6\n 1 1\n 2 3\n 3 9\n 4 27\n 5 81\n 6 243", "output": "100\n \n\nIt is optimal to cast the first spell 100 times.\n\n* * *"}, {"input": "9999 10\n 540 7550\n 691 9680\n 700 9790\n 510 7150\n 415 5818\n 551 7712\n 587 8227\n 619 8671\n 588 8228\n 176 2461", "output": "139815"}]
Print the minimum total Magic Points that have to be consumed before winning. * * *
s971165360
Accepted
p02787
Input is given from Standard Input in the following format: H N A_1 B_1 : A_N B_N
#!/bin/bash """:' docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro pypy:3-2.4.0 \ /bin/bash -c "pypy3 /vo/$(basename $0) < /vo/g.inp" exit $? """ import sys import math def _ia(): return [int(x) for x in sys.stdin.readline().strip().split()] h, n = _ia() ab = [_ia() for _ in range(n)] m_max = math.ceil(h / ab[0][0]) * ab[0][1] h1 = h + 1 dp = [[0] + [m_max + 1] * h for i in range(n + 1)] for i in range(n): ai, bi = ab[i] for j in range(1, h1): if j >= ai: dp[i + 1][j] = min(dp[i][j], dp[i][j - ai] + bi, dp[i + 1][j - ai] + bi) else: dp[i + 1][j] = min(dp[i][j], bi) print(dp[n][h])
Statement Ibis is fighting with a monster. The _health_ of the monster is H. Ibis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points. The same spell can be cast multiple times. There is no way other than spells to decrease the monster's health. Ibis wins when the health of the monster becomes 0 or below. Find the minimum total Magic Points that have to be consumed before winning.
[{"input": "9 3\n 8 3\n 4 2\n 2 1", "output": "4\n \n\nFirst, let us cast the first spell to decrease the monster's health by 8, at\nthe cost of 3 Magic Points. The monster's health is now 1.\n\nThen, cast the third spell to decrease the monster's health by 2, at the cost\nof 1 Magic Point. The monster's health is now -1.\n\nIn this way, we can win at the total cost of 4 Magic Points.\n\n* * *"}, {"input": "100 6\n 1 1\n 2 3\n 3 9\n 4 27\n 5 81\n 6 243", "output": "100\n \n\nIt is optimal to cast the first spell 100 times.\n\n* * *"}, {"input": "9999 10\n 540 7550\n 691 9680\n 700 9790\n 510 7150\n 415 5818\n 551 7712\n 587 8227\n 619 8671\n 588 8228\n 176 2461", "output": "139815"}]
Print the minimum total Magic Points that have to be consumed before winning. * * *
s794585691
Wrong Answer
p02787
Input is given from Standard Input in the following format: H N A_1 B_1 : A_N B_N
h, n = list(map(int, input().split(" "))) d = {} for i in range(n): a, b = list(map(int, input().split(" "))) d[b] = max(a, d.get(b, 0)) # print(d) best = 0 best_k = 0 best_v = 0 for k in sorted(d): v = d[k] if best < v / k: best = v / k best_k = k best_v = v temp = 0 while h >= best_v: h -= best_v temp += best_k # print(h, temp, best_k, best, best * best_k) ans = 9999999999999999999999 memo = {} sorted_d = sorted(d)[::-1] def f(current, damage): # print(current, damage, h) global ans if damage and memo.get(current, 0) >= damage: return memo.get(current, 0) memo[current] = damage if damage >= h: ans = min(ans, current) return ans hoge = 0 for k in sorted_d: hoge = max(hoge, f(current + k, damage + d[k])) return hoge f(0, 0) # print(temp, (ans if ans != 9999999999999999999999 else 0)) print(temp + (ans if ans != 9999999999999999999999 else 0))
Statement Ibis is fighting with a monster. The _health_ of the monster is H. Ibis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points. The same spell can be cast multiple times. There is no way other than spells to decrease the monster's health. Ibis wins when the health of the monster becomes 0 or below. Find the minimum total Magic Points that have to be consumed before winning.
[{"input": "9 3\n 8 3\n 4 2\n 2 1", "output": "4\n \n\nFirst, let us cast the first spell to decrease the monster's health by 8, at\nthe cost of 3 Magic Points. The monster's health is now 1.\n\nThen, cast the third spell to decrease the monster's health by 2, at the cost\nof 1 Magic Point. The monster's health is now -1.\n\nIn this way, we can win at the total cost of 4 Magic Points.\n\n* * *"}, {"input": "100 6\n 1 1\n 2 3\n 3 9\n 4 27\n 5 81\n 6 243", "output": "100\n \n\nIt is optimal to cast the first spell 100 times.\n\n* * *"}, {"input": "9999 10\n 540 7550\n 691 9680\n 700 9790\n 510 7150\n 415 5818\n 551 7712\n 587 8227\n 619 8671\n 588 8228\n 176 2461", "output": "139815"}]
Print the minimum total Magic Points that have to be consumed before winning. * * *
s006244348
Accepted
p02787
Input is given from Standard Input in the following format: H N A_1 B_1 : A_N B_N
n, m = map(int, input().split()) s = [list(map(int, input().split())) for i in range(m)] x = max(a for a, b in s) dp = [0] * (n + x) for i in range(0, n + x): if i > 0: dp[i] = min(dp[i - a] + b for a, b in s) print(min(dp[n:]))
Statement Ibis is fighting with a monster. The _health_ of the monster is H. Ibis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points. The same spell can be cast multiple times. There is no way other than spells to decrease the monster's health. Ibis wins when the health of the monster becomes 0 or below. Find the minimum total Magic Points that have to be consumed before winning.
[{"input": "9 3\n 8 3\n 4 2\n 2 1", "output": "4\n \n\nFirst, let us cast the first spell to decrease the monster's health by 8, at\nthe cost of 3 Magic Points. The monster's health is now 1.\n\nThen, cast the third spell to decrease the monster's health by 2, at the cost\nof 1 Magic Point. The monster's health is now -1.\n\nIn this way, we can win at the total cost of 4 Magic Points.\n\n* * *"}, {"input": "100 6\n 1 1\n 2 3\n 3 9\n 4 27\n 5 81\n 6 243", "output": "100\n \n\nIt is optimal to cast the first spell 100 times.\n\n* * *"}, {"input": "9999 10\n 540 7550\n 691 9680\n 700 9790\n 510 7150\n 415 5818\n 551 7712\n 587 8227\n 619 8671\n 588 8228\n 176 2461", "output": "139815"}]
Print the minimum total Magic Points that have to be consumed before winning. * * *
s683909031
Wrong Answer
p02787
Input is given from Standard Input in the following format: H N A_1 B_1 : A_N B_N
h, n = list(map(int, input().split())) hp_and_magic = [list(map(int, input().split())) for _ in range(n)] arr = [0] * (h + 1) # arr[k] := hpがkの敵を倒すのに必要な最小魔力 arr[1] = min([ele[1] for ele in hp_and_magic]) for i in range(2, h + 1): arr[i] = 10**9 for ele in hp_and_magic: if i - ele[0] >= 0: arr[i] = min(arr[i], arr[i - ele[0]] + ele[1]) # print(arr[i-ele[0]], ele[1]) print(arr[h])
Statement Ibis is fighting with a monster. The _health_ of the monster is H. Ibis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points. The same spell can be cast multiple times. There is no way other than spells to decrease the monster's health. Ibis wins when the health of the monster becomes 0 or below. Find the minimum total Magic Points that have to be consumed before winning.
[{"input": "9 3\n 8 3\n 4 2\n 2 1", "output": "4\n \n\nFirst, let us cast the first spell to decrease the monster's health by 8, at\nthe cost of 3 Magic Points. The monster's health is now 1.\n\nThen, cast the third spell to decrease the monster's health by 2, at the cost\nof 1 Magic Point. The monster's health is now -1.\n\nIn this way, we can win at the total cost of 4 Magic Points.\n\n* * *"}, {"input": "100 6\n 1 1\n 2 3\n 3 9\n 4 27\n 5 81\n 6 243", "output": "100\n \n\nIt is optimal to cast the first spell 100 times.\n\n* * *"}, {"input": "9999 10\n 540 7550\n 691 9680\n 700 9790\n 510 7150\n 415 5818\n 551 7712\n 587 8227\n 619 8671\n 588 8228\n 176 2461", "output": "139815"}]
Print the minimum total Magic Points that have to be consumed before winning. * * *
s640359350
Wrong Answer
p02787
Input is given from Standard Input in the following format: H N A_1 B_1 : A_N B_N
H, N = map(int, input().split()) A = [0] * N # damage B = [0] * N # MP for i in range(N): A[i], B[i] = map(int, input().split()) # H = 9999 # N = 10 # A = [540,691,700,510,] # B = [3,2,1] ans = 0 # ------------------------------------------------ ansAmari = float("inf") def saiki(damage, consumedMP): global ansAmari if damage >= Hamari: ansAmari = min(ansAmari, consumedMP) return for j in range(N): saiki(damage + A[j], consumedMP + B[j]) # ------------------------------------------------ cospa = 0 cospaList = [] for x in range(N): cospaList.append(A[x] / B[x]) cospa = max(A[x] / B[x], cospa) # print(cospa) # print(cospaList) cospaBanchi = [] for x in range(N): if cospaList[x] == cospa: cospaBanchi.append(x) saisyoDamage = 0 saisyoConsumeMP = float("inf") for y in cospaBanchi: saisyoConsumeMP = min(saisyoConsumeMP, B[y]) if saisyoConsumeMP == B[y]: saisyoDamage = A[y] # shou = H // saisyoConsumeMP # print(shou) ans += (H // saisyoDamage) * saisyoConsumeMP Hamari = H % saisyoDamage # print(amari) if Hamari == 0: print(ans) else: saiki(0, 0) print(ans + ansAmari)
Statement Ibis is fighting with a monster. The _health_ of the monster is H. Ibis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points. The same spell can be cast multiple times. There is no way other than spells to decrease the monster's health. Ibis wins when the health of the monster becomes 0 or below. Find the minimum total Magic Points that have to be consumed before winning.
[{"input": "9 3\n 8 3\n 4 2\n 2 1", "output": "4\n \n\nFirst, let us cast the first spell to decrease the monster's health by 8, at\nthe cost of 3 Magic Points. The monster's health is now 1.\n\nThen, cast the third spell to decrease the monster's health by 2, at the cost\nof 1 Magic Point. The monster's health is now -1.\n\nIn this way, we can win at the total cost of 4 Magic Points.\n\n* * *"}, {"input": "100 6\n 1 1\n 2 3\n 3 9\n 4 27\n 5 81\n 6 243", "output": "100\n \n\nIt is optimal to cast the first spell 100 times.\n\n* * *"}, {"input": "9999 10\n 540 7550\n 691 9680\n 700 9790\n 510 7150\n 415 5818\n 551 7712\n 587 8227\n 619 8671\n 588 8228\n 176 2461", "output": "139815"}]
Print the minimum total Magic Points that have to be consumed before winning. * * *
s369729011
Runtime Error
p02787
Input is given from Standard Input in the following format: H N A_1 B_1 : A_N B_N
import math line = input().split(" ") H = int(line[0]) N = int(line[1]) min_m = 100000 t = 0 As = [] Ms = [] mins = 100000 for i in range(N): line = input().split(" ") As.append(int(line[0])) Ms.append(int(line[1])) if min_m > Ms[i] / As[i]: min_m = Ms[i] / As[i] t = i for i in range(t, N): if min_m == Ms[i] / As[i] and Ms[i] < Ms[t]: t = i ans = math.floor(H / As[t]) * Ms[t] k = H % As[t] if k == 0: print(ans) else: while k > 0: p = [] for i in range(N): if Ms[i] >= Ms[t]: continue elif As[i] < k: p.append(k) continue else: t = i for i in p: if ( Ms[i] / As[i] < Ms[t] / As[t] and math.ceil(k / As[i]) * Ms[i] < math.ceil(k / Ms[t]) * Ms[t] ): t = i ans += math.floor(H / As[t]) * Ms[t] k = H % As[t] print(ans)
Statement Ibis is fighting with a monster. The _health_ of the monster is H. Ibis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points. The same spell can be cast multiple times. There is no way other than spells to decrease the monster's health. Ibis wins when the health of the monster becomes 0 or below. Find the minimum total Magic Points that have to be consumed before winning.
[{"input": "9 3\n 8 3\n 4 2\n 2 1", "output": "4\n \n\nFirst, let us cast the first spell to decrease the monster's health by 8, at\nthe cost of 3 Magic Points. The monster's health is now 1.\n\nThen, cast the third spell to decrease the monster's health by 2, at the cost\nof 1 Magic Point. The monster's health is now -1.\n\nIn this way, we can win at the total cost of 4 Magic Points.\n\n* * *"}, {"input": "100 6\n 1 1\n 2 3\n 3 9\n 4 27\n 5 81\n 6 243", "output": "100\n \n\nIt is optimal to cast the first spell 100 times.\n\n* * *"}, {"input": "9999 10\n 540 7550\n 691 9680\n 700 9790\n 510 7150\n 415 5818\n 551 7712\n 587 8227\n 619 8671\n 588 8228\n 176 2461", "output": "139815"}]
Print the minimum total Magic Points that have to be consumed before winning. * * *
s765096857
Runtime Error
p02787
Input is given from Standard Input in the following format: H N A_1 B_1 : A_N B_N
H, N = map(int, input().split()) AB = [map(int, input().split()) for _ in range(N)] A, B = [list(i) for i in zip(*AB)] A_min = min(A) eff_list = [0 for i in range(N)] for i in range(N): eff_list[i] = A[i] / B[i] eff_max_index_list = [] eff_max = max(eff_list) for i in range(N): if eff_list[i] == eff_max: eff_max_index_list.append(i) total_mp_min_list = [] for i in range(len(eff_max_index_list)): index = eff_max_index_list[i] count = H // A[index] mod = H - A[index] * count min_mp = B[index] if mod == 0: total_mp = B[index] * count else: index_tmp = index for j in range(N): count_tmp = mod // A[j] if mod % A[j] == 0: mp_tmp = B[j] * count_tmp else: mp_tmp = B[j] * (count_tmp + 1) if mp_tmp < min_mp: min_tmp = mp_tmp index_tmp = j total_mp = B[index] * count + min_tmp total_mp_min_list.append(total_mp) print(min(total_mp_min_list))
Statement Ibis is fighting with a monster. The _health_ of the monster is H. Ibis can cast N kinds of spells. Casting the i-th spell decreases the monster's health by A_i, at the cost of B_i Magic Points. The same spell can be cast multiple times. There is no way other than spells to decrease the monster's health. Ibis wins when the health of the monster becomes 0 or below. Find the minimum total Magic Points that have to be consumed before winning.
[{"input": "9 3\n 8 3\n 4 2\n 2 1", "output": "4\n \n\nFirst, let us cast the first spell to decrease the monster's health by 8, at\nthe cost of 3 Magic Points. The monster's health is now 1.\n\nThen, cast the third spell to decrease the monster's health by 2, at the cost\nof 1 Magic Point. The monster's health is now -1.\n\nIn this way, we can win at the total cost of 4 Magic Points.\n\n* * *"}, {"input": "100 6\n 1 1\n 2 3\n 3 9\n 4 27\n 5 81\n 6 243", "output": "100\n \n\nIt is optimal to cast the first spell 100 times.\n\n* * *"}, {"input": "9999 10\n 540 7550\n 691 9680\n 700 9790\n 510 7150\n 415 5818\n 551 7712\n 587 8227\n 619 8671\n 588 8228\n 176 2461", "output": "139815"}]
For each query, print the above mentioned status.
s886573421
Accepted
p02292
xp0 yp0 xp1 yp1 q xp20 yp20 xp21 yp21 ... xp2q-1 yp2q-1 In the first line, integer coordinates of p0 and p1 are given. Then, q queries are given for integer coordinates of p2.
import math from typing import Union class Point(object): __slots__ = ["x", "y"] def __init__(self, x, y): self.x = x self.y = y def __add__(self, other): return Point(self.x + other.x, self.y + other.y) def __sub__(self, other): return Point(self.x - other.x, self.y - other.y) def __mul__(self, other: Union[int, float]): return Point(self.x * other, self.y * other) def __repr__(self): return f"({self.x},{self.y})" class Vector(Point): __slots__ = ["x", "y", "pt1", "pt2"] def __init__(self, pt1: Point, pt2: Point): from_pt1_to_pt2 = pt2 - pt1 super().__init__(from_pt1_to_pt2.x, from_pt1_to_pt2.y) self.pt1 = pt1 self.pt2 = pt2 def dot(self, other): return self.x * other.x + self.y * other.y def cross(self, other): return self.x * other.y - self.y * other.x def norm(self): return pow(self.x, 2) + pow(self.y, 2) def abs(self): return math.sqrt(self.norm()) def __repr__(self): return f"{self.pt1},{self.pt2}" class Segment(Vector): __slots__ = ["x", "y", "pt1", "pt2"] def __init__(self, pt1: Point, pt2: Point): super().__init__(pt1, pt2) def projection(self, pt: Point) -> Point: t = self.dot(Vector(self.pt1, pt)) / pow(self.abs(), 2) return Point(self.pt1.x + t * self.x, self.pt1.y + t * self.y) def reflection(self, pt: Point) -> Point: return self.projection(pt) * 2 - pt def point_geometry(self, pt: Point): vec_pt1_to_pt = Vector(self.pt1, pt) cross = self.cross(vec_pt1_to_pt) if cross > 0: print("COUNTER_CLOCKWISE") return elif cross < 0: print("CLOCKWISE") return else: # cross == 0 dot = self.dot(vec_pt1_to_pt) if dot < 0: print("ONLINE_BACK") return else: # dot > 0 if self.abs() < vec_pt1_to_pt.abs(): print("ONLINE_FRONT") return else: print("ON_SEGMENT") return def __repr__(self): return f"{self.pt1},{self.pt2}" def main(): p0_x, p0_y, p1_x, p1_y = map(int, input().split()) p0 = Point(p0_x, p0_y) seg = Segment(p0, Point(p1_x, p1_y)) num_query = int(input()) for i in range(num_query): p2_x, p2_y = map(int, input().split()) seg.point_geometry(Point(p2_x, p2_y)) return main()
Counter-Clockwise ![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_CGL_CGL_1_C) For given three points p0, p1, p2, print COUNTER_CLOCKWISE if p0, p1, p2 make a counterclockwise turn (1), CLOCKWISE if p0, p1, p2 make a clockwise turn (2), ONLINE_BACK if p2 is on a line p2, p0, p1 in this order (3), ONLINE_FRONT if p2 is on a line p0, p1, p2 in this order (4), ON_SEGMENT if p2 is on a segment p0p1 (5).
[{"input": "0 0 2 0\n 2\n -1 1\n -1 -1", "output": "COUNTER_CLOCKWISE\n CLOCKWISE"}, {"input": "0 0 2 0\n 3\n -1 0\n 0 0\n 3 0", "output": "ONLINE_BACK\n ON_SEGMENT\n ONLINE_FRONT"}]
For each dataset, output the largest possible number of unit panels in the united panel at the upper left corner with the target color after five times of color changes of the panel at the upper left corner. No extra characters should occur in the output.
s673990055
Runtime Error
p00755
The input consists of multiple datasets, each being in the following format. > _h_ _w_ _c_ > _p_ 1,1 _p_ 1,2 ... _p_ 1,_w_ > _p_ 2,1 _p_ 2,2 ... _p_ 2,_w_ > ... > _p_ _h_ ,1 _p_ _h_ ,2 ... _p_ _h_ ,_w_ > _h_ and _w_ are positive integers no more than 8 that represent the height and the width of the given rectangle. _c_ is a positive integer no more than 6 that represents the target color of the finally united panel. _p_ _i_ ,_j_ is a positive integer no more than 6 that represents the initial color of the panel at the position (_i_ , _j_). The end of the input is indicated by a line that consists of three zeros separated by single spaces.
import copy import itertools drc = [(-1, 0), (0, 1), (1, 0), (0, -1)] C_NUM = 6 while True: H, W, C = map(int, input().split()) if not (H | W | C): break board = [[int(x) - 1 for x in input().split()] for _ in range(H)] ans = 0 for ope in itertools.product(range(C_NUM), repeat=4): # print(ope) tmp_board = copy.deepcopy(board) for color in itertools.chain(ope, (C - 1,)): now_c = tmp_board[0][0] if now_c == color: continue stack = [(0, 0)] while stack: r, c = stack.pop() if tmp_board[r][c] == color: continue tmp_board[r][c] = color for dr, dc in drc: nr, nc = r + dr, c + dc if 0 <= nr < H and 0 <= nc < W and tmp_board[nr][nc] == now_c: stack.append((nr, nc)) stack = [(0, 0)] while stack: r, c = stack.pop() if tmp_board[r][c] == -1: continue tmp_board[r][c] = -1 for dr, dc in drc: nr, nc = r + dr, c + dc if 0 <= nr < H and 0 <= nc < W and tmp_board[nr][nc] == C - 1: stack.append((nr, nc)) ans = max(ans, sum(row.count(-1) for row in tmp_board)) print(ans)
_Identically Colored Panels Connection_ Dr. Fukuoka has invented fancy panels. Each panel has a square shape of a unit size and has one of the six colors, namely, yellow, pink, red, purple, green and blue. The panel has two remarkable properties. One property is that, when two or more panels with the same color are placed adjacently, their touching edges melt a little and they are fused each other. The fused panels are united into a polygonally shaped panel. The other property is that the color of a panel can be changed to one of six colors by giving an electrical shock. The resulting color can be controlled by its waveform. The electrical shock to an already united panel changes the color of the whole to a specified single color. Since he wants to investigate the strength with respect to the color and the size of a united panel compared to unit panels, he tries to unite panels into a polygonal panel with a specified color. ![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_1174_1) Figure C-1: panels and their initial colors Since many panels are simultaneously synthesized and generated on a base plate through some complex chemical processes, the fabricated panels are randomly colored and they are arranged in a rectangular shape on the base plate (Figure C-1). Note that the two purple (color 4) panels in Figure C-1 are already united at the initial state since they are adjacent to each other. Installing electrodes to a panel, and changing its color several times by giving electrical shocks according to an appropriate sequence for a specified target color, he can make a united panel merge the adjacent panels to unite them step by step and can obtain a larger panel with the target color. Unfortunately, panels will be broken when they are struck by the sixth electrical shock. That is, he can change the color of a panel or a united panel only five times. Let us consider a case where the panel at the upper left corner of the panel configuration (Figure C-1) is attached with the electrodes. First, changing the color of the panel from yellow to blue, the two adjacent panels are fused into a united panel (Figure C-2). ![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_1174_2) Figure C-2: Change of the color of the panel at the upper left corner, from yellow (color 1) to blue (color 6). Second, changing the color of the upper left united panel from blue to red, a united red panel that consists of three unit panels is newly formed (Figure C-3). Then, changing the color of the united panel from red to purple, panels are united again to form a united panel of five unit panels (Figure C-4). ![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_1174_3) Figure C-3: Change of the color of the panel at the upper left corner, from blue (color 6) to red (color 3). ![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_1174_4) Figure C-4: Change of the color of the panel at the upper left corner, from red (color 3) to purple (color 4). Furthermore, through making a pink united panel in Figure C-5 by changing the color from purple to pink, then, the green united panel in Figure C-6 is obtained by changing the color from pink to green. The green united panel consists of ten unit panels. ![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_1174_5) Figure C-5: Change of the color of the panel at the upper left corner, from purple (color 4) to pink (color 2). ![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_1174_6) Figure C-6: Change of the color of the panel at the upper left corner, from pink (color 2) to green (color 5). In order to check the strength of united panels with various sizes and colors, he needs to unite as many panels as possible with the target color. Your job is to write a program that finds a sequence to change the colors five times in order to get the largest united panel with the target color. Note that the electrodes are fixed to the panel at the upper left corner.
[{"input": "5 5\n 1 6 3 2 5\n 2 5 4 6 1\n 1 2 4 1 5\n 4 5 6\n 1 5 6 1 2\n 1 4 6 3 2\n 1 5 2 3 2\n 1 1 2 3 2\n 1 1 5\n 1\n 1 8 6\n 1 2 3 4 5 1 2 3\n 8 1 1\n 1\n 2\n 3\n 4\n 5\n 1\n 2\n 3\n 8 8 6\n 5 2 5 2 6 5 4 2\n 4 2 2 2 5 2 2 2\n 4 4 4 2 5 2 2 2\n 6 4 5 2 2 2 6 6\n 6 6 5 5 2 2 6 6\n 6 2 5 4 2 2 6 6\n 2 4 4 4 6 2 2 6\n 2 2 2 5 5 2 2 2\n 8 8 2\n 3 3 5 4 1 6 2 3\n 2 3 6 4 3 6 2 2\n 4 1 6 6 6 4 4 4\n 2 5 3 6 3 6 3 5\n 3 1 3 4 1 5 6 3\n 1 6 6 3 5 1 5 3\n 2 4 2 2 2 6 5 3\n 4 1 3 6 1 5 5 4\n 0 0 0", "output": "18\n 1\n 5\n 6\n 64\n 33"}]
Print the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print `0`.) * * *
s665354607
Accepted
p02768
Input is given from Standard Input in the following format: n a b
class Mint: MOD = 10**9 + 7 def __init__(self, x=0): self.x = (x % self.MOD + self.MOD) % self.MOD def __iadd__(self, other): self.x += other.x if self.x >= self.MOD: self.x -= self.MOD return self def __isub__(self, other): self.x += self.MOD - other.x if self.x >= self.MOD: self.x -= self.MOD return self def __imul__(self, other): self.x *= other.x self.x %= self.MOD return self def __add__(self, other): ans = Mint(self.x) ans += other return ans def __sub__(self, other): ans = Mint(self.x) ans -= other return ans def __mul__(self, other): ans = Mint(self.x) ans *= other return ans def __pow__(self, n): if n == 0: return Mint(1) a = self.__pow__(n >> 1) a *= a if n & 1: a *= self return a def inv(self): return self ** (self.MOD - 2) def __ifloordiv__(self, other): self *= other.inv() return self def __floordiv__(self, other): ans = Mint(self.x) ans //= other return ans class Comb: def __init__(self): pass def comb(self, n, k): assert n < Mint.MOD if k < 0 or k > n: return 0 numerator = Mint(n - k + 1) for i in range(n - k + 2, n + 1): numerator *= Mint(i) d = Mint(1) for i in range(2, k + 1): d *= Mint(i) denominator = d.inv() return numerator * denominator def Main(N, A, B): ans = Mint(2) ** N - Mint(1) - Comb().comb(N, A) - Comb().comb(N, B) return ans.x def main(): N, A, B = list(map(int, input().split())) print(Main(N, A, B)) if __name__ == "__main__": main()
Statement Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
[{"input": "4 1 3", "output": "7\n \n\nIn this case, Akari can choose 2 or 4 flowers to make the bouquet.\n\nThere are 6 ways to choose 2 out of the 4 flowers, and 1 way to choose 4, so\nthere are a total of 7 different bouquets that Akari can make.\n\n* * *"}, {"input": "1000000000 141421 173205", "output": "34076506\n \n\nPrint the count modulo (10^9 + 7)."}]
Print the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print `0`.) * * *
s711495990
Accepted
p02768
Input is given from Standard Input in the following format: n a b
mod = 10**9 + 7 n, a, b = map(int, input().split()) pows = [2] for _ in range(40): pows.append((pows[-1] ** 2) % mod) ans = 1 flag = format(n, "b") if len(flag) < 31: flag = (31 - len(flag)) * "0" + flag flag = flag[::-1] for i in range(31): if flag[i] == "1": ans *= pows[i] ans %= mod ans -= 1 rfacts = [pow(1, mod - 2, mod) % mod, pow(1, mod - 2, mod) % mod] for i in range(2, 2 * (10**5) + 1): rfacts.append((rfacts[-1] * pow(i, mod - 2, mod)) % mod) if n <= 2 * 10**5: fact = 1 for i in range(2, n + 1): fact *= i fact %= mod ans -= (fact * rfacts[a] * rfacts[n - a]) % mod ans %= mod ans -= (fact * rfacts[b] * rfacts[n - b]) % mod ans %= mod else: fact1 = 1 for i in range(n, n - a, -1): fact1 *= i fact1 %= mod ans -= (fact1 * rfacts[a]) % mod ans %= mod fact2 = 1 for i in range(n, n - b, -1): fact2 *= i fact2 %= mod ans -= (fact2 * rfacts[b]) % mod ans %= mod print(ans)
Statement Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
[{"input": "4 1 3", "output": "7\n \n\nIn this case, Akari can choose 2 or 4 flowers to make the bouquet.\n\nThere are 6 ways to choose 2 out of the 4 flowers, and 1 way to choose 4, so\nthere are a total of 7 different bouquets that Akari can make.\n\n* * *"}, {"input": "1000000000 141421 173205", "output": "34076506\n \n\nPrint the count modulo (10^9 + 7)."}]
Print the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print `0`.) * * *
s686694566
Accepted
p02768
Input is given from Standard Input in the following format: n a b
n, a, b = list(map(int, input().split(" "))) # 二項係数 mod [検索] mmm = 1000000000 + 7 fac = [] inv = [] inv_fac = [] def init(n): fac.append(1) fac.append(1) inv.append(0) inv.append(1) inv_fac.append(1) inv_fac.append(1) for i in range(2, n): fac.append(fac[-1] * i % mmm) inv.append(mmm - inv[mmm % i] * (mmm // i) % mmm) inv_fac.append(inv_fac[-1] * inv[-1] % mmm) def choice(a, b): if a < b: return 0 v = 1 for i in range(b): v = ( v * (a - i) ) % mmm # 偶然通っていたけどここはnではなくa (eの途中で気づいた) return v * inv_fac[b] init(int(2e5) + 1) ans = pow(2, n, mmm) - 1 # v, e, mod bunshi = 1 for i in range(a): bunshi = (bunshi * (n - i)) % mmm ans -= choice(n, a) ans -= choice(n, b) print(ans % mmm) """ 4, 1, 3 => 4c2 + 4c4 -> 6+1 = 7 4 + 6 + 4 + 1 - 4c1 - 4c2 1 1 11 2 121 4 1331 8 14641 16, 0が無いので-1, 大きい combination -> 二項係数 mod [検索] """
Statement Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
[{"input": "4 1 3", "output": "7\n \n\nIn this case, Akari can choose 2 or 4 flowers to make the bouquet.\n\nThere are 6 ways to choose 2 out of the 4 flowers, and 1 way to choose 4, so\nthere are a total of 7 different bouquets that Akari can make.\n\n* * *"}, {"input": "1000000000 141421 173205", "output": "34076506\n \n\nPrint the count modulo (10^9 + 7)."}]
Print the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print `0`.) * * *
s737192518
Wrong Answer
p02768
Input is given from Standard Input in the following format: n a b
a, b, c = map(int, input().split()) print(7)
Statement Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
[{"input": "4 1 3", "output": "7\n \n\nIn this case, Akari can choose 2 or 4 flowers to make the bouquet.\n\nThere are 6 ways to choose 2 out of the 4 flowers, and 1 way to choose 4, so\nthere are a total of 7 different bouquets that Akari can make.\n\n* * *"}, {"input": "1000000000 141421 173205", "output": "34076506\n \n\nPrint the count modulo (10^9 + 7)."}]
Print the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print `0`.) * * *
s117380777
Wrong Answer
p02768
Input is given from Standard Input in the following format: n a b
a = pow(2, 10**7, 10**9 + 7) print(a)
Statement Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
[{"input": "4 1 3", "output": "7\n \n\nIn this case, Akari can choose 2 or 4 flowers to make the bouquet.\n\nThere are 6 ways to choose 2 out of the 4 flowers, and 1 way to choose 4, so\nthere are a total of 7 different bouquets that Akari can make.\n\n* * *"}, {"input": "1000000000 141421 173205", "output": "34076506\n \n\nPrint the count modulo (10^9 + 7)."}]
Print the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print `0`.) * * *
s085843217
Accepted
p02768
Input is given from Standard Input in the following format: n a b
# TODO: P3: Create modint library with Python """ 【競プロ】繰り返し二乗法と再帰関数 https://math.nakaken88.com/textbook/cp-binary-exponentiation-and-recursive-function/ 「1000000007 で割ったあまり」の求め方を総特集! 〜 逆元から離散対数まで 〜 https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a Pythonでmodintを実装してみた https://qiita.com/wotsushi/items/c936838df992b706084c """ # No mod # def pow(a,n): # """ # 繰り返し二乗法 (半分の数の 2 乗) # a の n 乗を O(logN) で計算する # """ # if n == 0: # return 1 # x = pow(a, n//2) # x *= x # if n%2 == 1: # x *= a # return x # def choose(n, a): # """ # nCa (n 個から a 個選ぶ組み合わせ) # 分子: n! # 分母: a! * (n-a)! # 約分して # 分子: n * (n-1) * ... * (n-a+1) = (n-i) の積の和 (i=0 ~ a-1) # 分母: a! # 逆元 # フェルマーの小定理より # 1 ≡ x**(p-1) (mod p) # => 1/x ≡ x**(p-2) (mod p) # => 1/x%p = x**(p-2)%2 # """ # x = 1 # 分子 # y = 1 # 分母 # for i in range(a): # x *= n-i # y *= i+1 # pow # return x / y def pow(a, n, MOD): """ 繰り返し二乗法 (半分の数の 2 乗) Compute nth power of a -- O(logn) """ if n == 0: return 1 x = pow(a, n // 2, MOD) x = (x % MOD * x % MOD) % MOD if n % 2 == 1: x = (x % MOD * a % MOD) % MOD return x def choose(n, a, MOD): """ nCa (Choose a from n) numerator (分子): n! denominator(分母): a! * (n-a)! Reduce... (約分) numerator:: n * (n-1) * ... * (n-a+1) = (n-i) の積の和 (i=0 ~ a-1) denominator: a! iverse (逆元) フェルマーの小定理 1 ≡ x**(p-1) (mod p) => 1/x ≡ x**(p-2) (mod p) => 1/x%p = x**(p-2)%2 """ x = 1 # numerator y = 1 # denominator for i in range(a): x = (x % MOD * (n - i) % MOD) % MOD y = (y % MOD * (i + 1) % MOD) % MOD return (x * pow(y, MOD - 2, MOD)) % MOD """ AC: https://atcoder.jp/contests/abc156/submissions/10294982 N**2 - 1 - nCa - nCb pow(2,n) 140625001 nCa -483404860 nCb 589953354 """ n, a, b = map(int, input().split()) MOD = 1000000007 # n,a,b = 4,1,3 # n,a,b = 1000000000,141421,173205 ans = pow(2, n, MOD) ans -= 1 ans = (ans % MOD - choose(n, a, MOD)) % MOD ans = (ans % MOD - choose(n, b, MOD)) % MOD print(ans)
Statement Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
[{"input": "4 1 3", "output": "7\n \n\nIn this case, Akari can choose 2 or 4 flowers to make the bouquet.\n\nThere are 6 ways to choose 2 out of the 4 flowers, and 1 way to choose 4, so\nthere are a total of 7 different bouquets that Akari can make.\n\n* * *"}, {"input": "1000000000 141421 173205", "output": "34076506\n \n\nPrint the count modulo (10^9 + 7)."}]
Print the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print `0`.) * * *
s061108673
Runtime Error
p02768
Input is given from Standard Input in the following format: n a b
n, a, b = (int(x) for x in input().split()) mod = 1000000007 n1 = int(n / 2) list = [1] for i in range(n1): k = list[i] * (n - i) / (i + 1) k %= mod list.append(k) su = sum(list) % mod su *= 2 if n % 2 == 0: su -= list[n1] if 2 * a >= n: a = n1 - (a / 2) if 2 * b >= n: b = n1 - int(b / 2) su -= list[a] su -= list[b] su -= 1 print(int(su % mod))
Statement Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
[{"input": "4 1 3", "output": "7\n \n\nIn this case, Akari can choose 2 or 4 flowers to make the bouquet.\n\nThere are 6 ways to choose 2 out of the 4 flowers, and 1 way to choose 4, so\nthere are a total of 7 different bouquets that Akari can make.\n\n* * *"}, {"input": "1000000000 141421 173205", "output": "34076506\n \n\nPrint the count modulo (10^9 + 7)."}]
Print the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print `0`.) * * *
s829886575
Runtime Error
p02768
Input is given from Standard Input in the following format: n a b
n, a, b = map(int, input().split()) counts = [0] * (n + 1) counts[1] = n mod = 10**9 + 7 for i in range(2, n + 1): counts[i] = counts[i - 1] * (n - i + 1) // i % mod counts[a] = 0 counts[b] = 0 print(sum(counts))
Statement Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
[{"input": "4 1 3", "output": "7\n \n\nIn this case, Akari can choose 2 or 4 flowers to make the bouquet.\n\nThere are 6 ways to choose 2 out of the 4 flowers, and 1 way to choose 4, so\nthere are a total of 7 different bouquets that Akari can make.\n\n* * *"}, {"input": "1000000000 141421 173205", "output": "34076506\n \n\nPrint the count modulo (10^9 + 7)."}]
Print the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print `0`.) * * *
s355927444
Wrong Answer
p02768
Input is given from Standard Input in the following format: n a b
#!/usr/bin/env python n, a, b = (int(val) for val in input().split()) ans = 1 noa = 1 nob = 1 mod = 1000000007 kaijo = 1 for i in range(n): ans *= 2 ans %= mod if i < a: noa *= n - i noa %= mod if i == a - 1: noa /= kaijo if i < b: kaijo *= i + 1 kaijo %= mod nob *= n - i nob %= mod if i == b - 1: nob /= kaijo ans -= 1 # ans = ans - noa - nob # while ans < 0: # ans += mod print((ans - noa - nob) % mod)
Statement Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
[{"input": "4 1 3", "output": "7\n \n\nIn this case, Akari can choose 2 or 4 flowers to make the bouquet.\n\nThere are 6 ways to choose 2 out of the 4 flowers, and 1 way to choose 4, so\nthere are a total of 7 different bouquets that Akari can make.\n\n* * *"}, {"input": "1000000000 141421 173205", "output": "34076506\n \n\nPrint the count modulo (10^9 + 7)."}]
Print the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print `0`.) * * *
s581715419
Wrong Answer
p02768
Input is given from Standard Input in the following format: n a b
n, a, b = [int(i) for i in input().split()] mod = 10**9 + 7 def mpow(a, n): if n == 1: return a x = mpow(a, n // 2) ans = x * x % mod if n % 2 == 1: ans *= a return ans def comb(n, a, b): if a < b: s, l = a, b else: s, l = b, a rs = 1 for i in range(s): rs = rs * (n - i) % mod rl = rs for i in range(s, l): rl = rl * (n - i) % mod for i in range(1, s + 1): rs = rs * mpow(i, mod - 2) % mod rl = rl for i in range(s + 1, l + 1): rl = rl * mpow(i, mod - 2) % mod if a < b: nCa, nCb = rs, rl else: nCa, nCb = rl, rs return nCa, nCb nCa, nCb = comb(n, a, b) print((mpow(2, n) - 1 - nCa - nCb) % mod) print(nCa, nCb)
Statement Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
[{"input": "4 1 3", "output": "7\n \n\nIn this case, Akari can choose 2 or 4 flowers to make the bouquet.\n\nThere are 6 ways to choose 2 out of the 4 flowers, and 1 way to choose 4, so\nthere are a total of 7 different bouquets that Akari can make.\n\n* * *"}, {"input": "1000000000 141421 173205", "output": "34076506\n \n\nPrint the count modulo (10^9 + 7)."}]
Print the number of ways modulo $10^9+7$ in a line.
s691344720
Accepted
p02338
$n$ $k$ The first line will contain two integers $n$ and $k$.
class Twelvefold: # n <= 1000程度 def __init__(self, n, mod, build=True): self.mod = mod self.fct = [0 for _ in range(n + 1)] self.inv = [0 for _ in range(n + 1)] self.fct[0] = 1 self.inv[0] = 1 for i in range(n): self.fct[i + 1] = self.fct[i] * (i + 1) % mod self.inv[n] = pow(self.fct[n], mod - 2, mod) for i in range(n)[::-1]: self.inv[i] = self.inv[i + 1] * (i + 1) % mod if build: self.build(n) def build(self, n): self.stl = [[0 for j in range(n + 1)] for i in range(n + 1)] self.bel = [[0 for j in range(n + 1)] for i in range(n + 1)] self.prt = [[0 for j in range(n + 1)] for i in range(n + 1)] self.stl[0][0] = 1 self.bel[0][0] = 1 for i in range(n): for j in range(n): self.stl[i + 1][j + 1] = self.stl[i][j] + (j + 1) * self.stl[i][j + 1] self.stl[i + 1][j + 1] %= self.mod for i in range(n): for j in range(n): self.bel[i + 1][j + 1] = ( self.bel[i + 1][j] + self.stl[i + 1][j + 1] % self.mod ) self.bel[i + 1][j + 1] %= self.mod for j in range(n): self.prt[0][j] = 1 for i in range(n): for j in range(n): if i - j >= 0: self.prt[i + 1][j + 1] = self.prt[i + 1][j] + self.prt[i - j][j + 1] else: self.prt[i + 1][j + 1] = self.prt[i + 1][j] self.prt[i + 1][j + 1] %= self.mod def solve( self, element, subset, equate_element=False, equate_subset=False, less_than_1=False, more_than_1=False, ): assert not less_than_1 or not more_than_1 n = element k = subset a = equate_element b = equate_subset c = less_than_1 d = more_than_1 id = a * 3 + b * 6 + c + d * 2 tw = [ self.tw1, self.tw2, self.tw3, self.tw4, self.tw5, self.tw6, self.tw7, self.tw8, self.tw9, self.tw10, self.tw11, self.tw12, ] return tw[id](n, k) def tw1(self, n, k): return pow(k, n, self.mod) def tw2(self, n, k): if k - n < 0: return 0 return self.fct[k] * self.inv[k - n] % self.mod def tw3(self, n, k): return self.stl[n][k] * self.fct[k] % self.mod def tw4(self, n, k): if k == 0: return 0 return self.fct[n + k - 1] * self.inv[n] * self.inv[k - 1] % self.mod def tw5(self, n, k): if k - n < 0: return 0 return self.fct[k] * self.inv[n] * self.inv[k - n] % self.mod def tw6(self, n, k): if n - k < 0 or k == 0: return 0 return self.fct[n - 1] * self.inv[k - 1] * self.inv[n - k] % self.mod def tw7(self, n, k): return self.bel[n][k] def tw8(self, n, k): if k - n < 0: return 0 return 1 def tw9(self, n, k): return self.stl[n][k] def tw10(self, n, k): return self.prt[n][k] def tw11(self, n, k): if k - n < 0: return 0 return 1 def tw12(self, n, k): if n - k < 0: return 0 return self.prt[n - k][k] n, k = map(int, input().split()) t = Twelvefold(1000, 10**9 + 7, 0) print(t.solve(n, k, 0, 1, 1, 0))
You have $n$ balls and $k$ boxes. You want to put these balls into the boxes. Find the number of ways to put the balls under the following conditions: * Each ball is distinguished from the other. * Each box is **not** distinguished from the other. * Each ball can go into only one box and no one remains outside of the boxes. * Each box can contain at most one ball. Note that you must print this count modulo $10^9+7$.
[{"input": "5 10", "output": "1"}, {"input": "200 100", "output": "0"}]
Print the number of ways modulo $10^9+7$ in a line.
s818110281
Accepted
p02338
$n$ $k$ The first line will contain two integers $n$ and $k$.
a, b = map(int, input().split(" ")) print(int(a <= b))
You have $n$ balls and $k$ boxes. You want to put these balls into the boxes. Find the number of ways to put the balls under the following conditions: * Each ball is distinguished from the other. * Each box is **not** distinguished from the other. * Each ball can go into only one box and no one remains outside of the boxes. * Each box can contain at most one ball. Note that you must print this count modulo $10^9+7$.
[{"input": "5 10", "output": "1"}, {"input": "200 100", "output": "0"}]
If we cannot turn S into a palindrome, print `-1`. Otherwise, print the minimum required number of operations. * * *
s182816021
Wrong Answer
p03483
Input is given from Standard Input in the following format: S
import sys sys.setrecursionlimit(10**6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") class BitSum: def __init__(self, n): self.n = n + 3 self.table = [0] * (self.n + 1) def update(self, i, x): i += 1 while i <= self.n: self.table[i] += x i += i & -i def sum(self, i): i += 1 res = 0 while i > 0: res += self.table[i] i -= i & -i return res def InversionNumber(lst): bit = BitSum(max(lst)) res = 0 for i, a in enumerate(lst): res += i - bit.sum(a) bit.update(a, 1) return res def main(): s = input() n = len(s) ord_a = ord("a") cnts = [0] * 26 s_code = [] flag_odd = False for c in s: code = ord(c) - ord_a s_code.append(code) cnts[code] += 1 odd_code = -1 for code, cnt in enumerate(cnts): if cnt % 2 == 1: if flag_odd: print(-1) exit() else: odd_code = code flag_odd = True cnts[code] = cnt // 2 tois = [[] for _ in range(26)] to_sort_idx = [] new_idx = 1 for code in s_code: if cnts[code] > 0: to_sort_idx.append(new_idx) tois[code].append(n + 1 - new_idx) cnts[code] -= 1 new_idx += 1 else: if flag_odd and code == odd_code: to_sort_idx.append(n // 2 + 1) else: to_sort_idx.append(tois[code].pop()) # print(to_sort_idx) print(InversionNumber(to_sort_idx)) main()
Statement You are given a string S consisting of lowercase English letters. Determine whether we can turn S into a palindrome by repeating the operation of swapping two adjacent characters. If it is possible, find the minimum required number of operations.
[{"input": "eel", "output": "1\n \n\nWe can turn S into a palindrome by the following operation:\n\n * Swap the 2-nd and 3-rd characters. S is now `ele`.\n\n* * *"}, {"input": "ataatmma", "output": "4\n \n\nWe can turn S into a palindrome by the following operation:\n\n * Swap the 5-th and 6-th characters. S is now `ataamtma`.\n * Swap the 4-th and 5-th characters. S is now `atamatma`.\n * Swap the 3-rd and 4-th characters. S is now `atmaatma`.\n * Swap the 2-nd and 3-rd characters. S is now `amtaatma`.\n\n* * *"}, {"input": "snuke", "output": "-1\n \n\nWe cannot turn S into a palindrome."}]
If we cannot turn S into a palindrome, print `-1`. Otherwise, print the minimum required number of operations. * * *
s515342071
Wrong Answer
p03483
Input is given from Standard Input in the following format: S
from collections import Counter class fenwick_tree(object): def __init__(self, n): self.n = n self.data = [0] * n def __sum(self, r): s = 0 while r > 0: s += self.data[r - 1] r -= r & -r return s def add(self, p, x): """a[p] += xを行う""" assert 0 <= p and p < self.n p += 1 while p <= self.n: self.data[p - 1] += x p += p & -p def sum(self, l, r): """a[l] + a[l+1] + .. + a[r-1]を返す""" assert 0 <= l and l <= r and r <= self.n return self.__sum(r) - self.__sum(l) def calc_inversion(arr): N = len(arr) bit = fenwick_tree(N) atoi = {a: i for i, a in enumerate(arr)} res = 0 for a in reversed(range(N)): i = atoi[a] res += bit.sum(0, i) bit.add(i, 1) return res def main(): S = input() N = len(S) C = Counter(S) odd = 0 mid = "" for k, v in C.items(): if v & 1: odd += 1 mid = k if N % 2 == 0: # 偶数 if odd: return -1 ans = 0 half = {k: v // 2 for k, v in C.items()} memo = {k: [] for k in C.keys()} cnt = 0 bit = fenwick_tree(N) right = [] for i, s in enumerate(S): if len(memo[s]) >= half[s]: # 右 bit.add(i, 1) right.append(s) else: # 左 memo[s].append(cnt) cnt += 1 ans += bit.sum(0, i) arr = [] for s in right: arr.append(memo[s].pop()) ans += calc_inversion(arr[::-1]) return ans else: # 奇数 if odd != 1: return -1 ans = 0 half = {k: v // 2 for k, v in C.items()} memo = {k: [] for k in C.keys()} right = [] cnt = 0 LL = 0 # midより右にあるLの数 RR = 0 # midより左にあるRの数 seen = 0 # midが登場したか bit = fenwick_tree(N) for i, s in enumerate(S): if s == mid and len(memo[s]) == half[s]: seen = 1 memo[s].append(cnt) elif len(memo[s]) >= half[s]: # 右 bit.add(i, 1) right.append(s) if not seen: RR += 1 else: memo[s].append(cnt) cnt += 1 ans += bit.sum(0, i) if seen: LL += 1 ans += abs(RR - LL) arr = [] memo[mid].pop() for s in right: arr.append(memo[s].pop()) ans += calc_inversion(arr[::-1]) return ans print(main())
Statement You are given a string S consisting of lowercase English letters. Determine whether we can turn S into a palindrome by repeating the operation of swapping two adjacent characters. If it is possible, find the minimum required number of operations.
[{"input": "eel", "output": "1\n \n\nWe can turn S into a palindrome by the following operation:\n\n * Swap the 2-nd and 3-rd characters. S is now `ele`.\n\n* * *"}, {"input": "ataatmma", "output": "4\n \n\nWe can turn S into a palindrome by the following operation:\n\n * Swap the 5-th and 6-th characters. S is now `ataamtma`.\n * Swap the 4-th and 5-th characters. S is now `atamatma`.\n * Swap the 3-rd and 4-th characters. S is now `atmaatma`.\n * Swap the 2-nd and 3-rd characters. S is now `amtaatma`.\n\n* * *"}, {"input": "snuke", "output": "-1\n \n\nWe cannot turn S into a palindrome."}]
If we cannot turn S into a palindrome, print `-1`. Otherwise, print the minimum required number of operations. * * *
s972516010
Accepted
p03483
Input is given from Standard Input in the following format: S
def count_inversions(L): def helper(A, B): lA, lB = len(A), len(B) if lA == 0: return B, 0 elif lB == 0: return A, 0 A, c1 = helper(A[: lA // 2], A[lA // 2 :]) B, c2 = helper(B[: lB // 2], B[lB // 2 :]) cnt = c1 + c2 i = 0 j = 0 C = [None] * (lA + lB) while i < lA and j < lB: if A[i] > B[j]: cnt += lA - i C[i + j] = B[j] j += 1 else: C[i + j] = A[i] i += 1 if i < lA: C[i + j :] = A[i:] else: C[i + j :] = B[j:] return C, cnt return helper(L[: len(L) // 2], L[len(L) // 2 :])[1] from collections import deque ALPHABETS = 26 indices = [deque() for _ in range(26)] S = list(map(lambda c: ord(c) - ord("a"), input())) for i, c in enumerate(S): indices[c] += [i] odd = None for c, l in enumerate(indices): if len(l) % 2 == 1: if odd is None: odd = c else: odd = -1 break if odd == -1: print(-1) exit() target = [None] * len(S) assigned = [False] * len(S) if odd is not None: l = list(indices[odd]) i = l[len(l) // 2] target[len(target) // 2] = i assigned[i] = True l = deque(l[: len(l) // 2] + l[len(l) // 2 + 1 :]) j = 0 for i in range(len(S) // 2): while assigned[j]: j += 1 l = indices[S[j]] a = l.popleft() b = l.pop() assert a == j target[i] = a target[len(S) - i - 1] = b assigned[a] = True assigned[b] = True print(count_inversions(target))
Statement You are given a string S consisting of lowercase English letters. Determine whether we can turn S into a palindrome by repeating the operation of swapping two adjacent characters. If it is possible, find the minimum required number of operations.
[{"input": "eel", "output": "1\n \n\nWe can turn S into a palindrome by the following operation:\n\n * Swap the 2-nd and 3-rd characters. S is now `ele`.\n\n* * *"}, {"input": "ataatmma", "output": "4\n \n\nWe can turn S into a palindrome by the following operation:\n\n * Swap the 5-th and 6-th characters. S is now `ataamtma`.\n * Swap the 4-th and 5-th characters. S is now `atamatma`.\n * Swap the 3-rd and 4-th characters. S is now `atmaatma`.\n * Swap the 2-nd and 3-rd characters. S is now `amtaatma`.\n\n* * *"}, {"input": "snuke", "output": "-1\n \n\nWe cannot turn S into a palindrome."}]
If we cannot turn S into a palindrome, print `-1`. Otherwise, print the minimum required number of operations. * * *
s182394482
Wrong Answer
p03483
Input is given from Standard Input in the following format: S
print(-1)
Statement You are given a string S consisting of lowercase English letters. Determine whether we can turn S into a palindrome by repeating the operation of swapping two adjacent characters. If it is possible, find the minimum required number of operations.
[{"input": "eel", "output": "1\n \n\nWe can turn S into a palindrome by the following operation:\n\n * Swap the 2-nd and 3-rd characters. S is now `ele`.\n\n* * *"}, {"input": "ataatmma", "output": "4\n \n\nWe can turn S into a palindrome by the following operation:\n\n * Swap the 5-th and 6-th characters. S is now `ataamtma`.\n * Swap the 4-th and 5-th characters. S is now `atamatma`.\n * Swap the 3-rd and 4-th characters. S is now `atmaatma`.\n * Swap the 2-nd and 3-rd characters. S is now `amtaatma`.\n\n* * *"}, {"input": "snuke", "output": "-1\n \n\nWe cannot turn S into a palindrome."}]
If we cannot turn S into a palindrome, print `-1`. Otherwise, print the minimum required number of operations. * * *
s079763884
Runtime Error
p03483
Input is given from Standard Input in the following format: S
def main(): X, Y = [int(i) for i in input().split()] ans = 1 pre = X while True: pre *= 2 if pre <= Y: ans += 1 else: break print(ans) if __name__ == "__main__": main()
Statement You are given a string S consisting of lowercase English letters. Determine whether we can turn S into a palindrome by repeating the operation of swapping two adjacent characters. If it is possible, find the minimum required number of operations.
[{"input": "eel", "output": "1\n \n\nWe can turn S into a palindrome by the following operation:\n\n * Swap the 2-nd and 3-rd characters. S is now `ele`.\n\n* * *"}, {"input": "ataatmma", "output": "4\n \n\nWe can turn S into a palindrome by the following operation:\n\n * Swap the 5-th and 6-th characters. S is now `ataamtma`.\n * Swap the 4-th and 5-th characters. S is now `atamatma`.\n * Swap the 3-rd and 4-th characters. S is now `atmaatma`.\n * Swap the 2-nd and 3-rd characters. S is now `amtaatma`.\n\n* * *"}, {"input": "snuke", "output": "-1\n \n\nWe cannot turn S into a palindrome."}]
If we cannot turn S into a palindrome, print `-1`. Otherwise, print the minimum required number of operations. * * *
s224964620
Runtime Error
p03483
Input is given from Standard Input in the following format: S
import string def main(): l = list(input()) N = len(l) count = 0 flag = True middle_letter = None i = 0 dic = {i: l.count(i) for i in string.ascii_lowercase} while i <= N >> 1: if l[i] != l[N - i - 1]: if dic[l[i]] % 2 and N % 2: if flag: middle_letter = l[i] tar_index = N >> 1 f_index = i count += tar_index - f_index l[f_index:tar_index] = l[f_index + 1 : tar_index + 1] l[tar_index] = middle_letter flag = False elif not flag and l[i] == middle_letter: pos = list(reversed(l)).index(l[i], i, N - i) temp = l[i] tar_index = N - 1 - i f_index = N - pos - 1 count += tar_index - f_index l[f_index:tar_index] = l[f_index + 1 : tar_index + 1] l[tar_index] = temp i += 1 else: print(-1) exit() else: pos = list(reversed(l)).index(l[i], i, N - i) temp = l[i] tar_index = N - 1 - i f_index = N - pos - 1 count += tar_index - f_index l[f_index:tar_index] = l[f_index + 1 : tar_index + 1] l[tar_index] = temp i += 1 else: i += 1 print(count) if __name__ == "__main__": main()
Statement You are given a string S consisting of lowercase English letters. Determine whether we can turn S into a palindrome by repeating the operation of swapping two adjacent characters. If it is possible, find the minimum required number of operations.
[{"input": "eel", "output": "1\n \n\nWe can turn S into a palindrome by the following operation:\n\n * Swap the 2-nd and 3-rd characters. S is now `ele`.\n\n* * *"}, {"input": "ataatmma", "output": "4\n \n\nWe can turn S into a palindrome by the following operation:\n\n * Swap the 5-th and 6-th characters. S is now `ataamtma`.\n * Swap the 4-th and 5-th characters. S is now `atamatma`.\n * Swap the 3-rd and 4-th characters. S is now `atmaatma`.\n * Swap the 2-nd and 3-rd characters. S is now `amtaatma`.\n\n* * *"}, {"input": "snuke", "output": "-1\n \n\nWe cannot turn S into a palindrome."}]
If we cannot turn S into a palindrome, print `-1`. Otherwise, print the minimum required number of operations. * * *
s771258746
Wrong Answer
p03483
Input is given from Standard Input in the following format: S
S = input().strip() flips = 0 impossible = False while len(S) > 1: ind1 = 0 ind2 = len(S) - 1 for i in range(len(S)): indi = ind2 - i if ind1 == indi: if not impossible: impossible = True S = S[1:] break else: print("-1") exit() if S[ind1] == S[indi]: if indi == ind2: S = S[1:-1] break else: S = S[1:indi] + S[indi + 1 :] break flips += 1 print(flips)
Statement You are given a string S consisting of lowercase English letters. Determine whether we can turn S into a palindrome by repeating the operation of swapping two adjacent characters. If it is possible, find the minimum required number of operations.
[{"input": "eel", "output": "1\n \n\nWe can turn S into a palindrome by the following operation:\n\n * Swap the 2-nd and 3-rd characters. S is now `ele`.\n\n* * *"}, {"input": "ataatmma", "output": "4\n \n\nWe can turn S into a palindrome by the following operation:\n\n * Swap the 5-th and 6-th characters. S is now `ataamtma`.\n * Swap the 4-th and 5-th characters. S is now `atamatma`.\n * Swap the 3-rd and 4-th characters. S is now `atmaatma`.\n * Swap the 2-nd and 3-rd characters. S is now `amtaatma`.\n\n* * *"}, {"input": "snuke", "output": "-1\n \n\nWe cannot turn S into a palindrome."}]
Print the number of permutations that satisfy the condition, modulo 10^9 + 7. * * *
s922232703
Accepted
p03179
Input is given from Standard Input in the following format: N s
#!/usr/bin/env python3 # from collections import defaultdict # from heapq import heappush, heappop # import numpy as np from itertools import accumulate import sys sys.setrecursionlimit(10**6) input = sys.stdin.buffer.readline INF = 10**9 + 1 # sys.maxsize # float("inf") MOD = 10**9 + 7 debug_indent = 0 def debug(*x): global debug_indent x = list(x) indent = 0 if x[0].startswith("enter") or x[0][0] == ">": indent = 1 if x[0].startswith("leave") or x[0][0] == "<": debug_indent -= 1 x[0] = " " * debug_indent + x[0] print(*x, file=sys.stderr) debug_indent += indent def solve(N, lessthan): k = 1 table = [0] * (k + 1) if lessthan[-1]: for i in range(k + 1): table[i] = k - i else: for i in range(k + 1): table[i] = i for k in range(2, N): newtable = [0] * (k + 1) acc = [0] + list(accumulate(table)) if lessthan[-k]: for i in range(k + 1): # for j in range(k - i): # newtable[i] += table[j + i] newtable[i] += acc[k] - acc[i] else: for i in range(k + 1): # for j in range(i): # newtable[i] += table[j] newtable[i] += acc[i] table = [x % MOD for x in newtable] return sum(table) % MOD def main(): # parse input N = int(input()) lessthan = [c == ord("<") for c in input().strip()] print(solve(N, lessthan)) # tests T0 = """ 2 > """ def test_T0(): """ >>> as_input(T0) >>> main() 1 """ T01 = """ 3 << """ def test_T01(): """ >>> as_input(T01) >>> main() 1 """ T02 = """ 3 >> """ def test_T02(): """ >>> as_input(T02) >>> main() 1 """ T03 = """ 3 <> """ def test_T03(): """ >>> as_input(T03) >>> main() 2 """ T1 = """ 4 <>< """ def test_T1(): """ >>> as_input(T1) >>> main() 5 """ T2 = """ 5 <<<< """ def test_T2(): """ >>> as_input(T2) >>> main() 1 """ T3 = """ 20 >>>><>>><>><>>><<>> """ def test_T3(): """ >>> as_input(T3) >>> main() 217136290 """ # add tests above def _test(): import doctest doctest.testmod() def as_input(s): "use in test, use given string as input file" import io global read, input f = io.StringIO(s.strip()) def input(): return bytes(f.readline(), "ascii") def read(): return bytes(f.read(), "ascii") USE_NUMBA = False if (USE_NUMBA and sys.argv[-1] == "ONLINE_JUDGE") or sys.argv[-1] == "-c": print("compiling") from numba.pycc import CC cc = CC("my_module") cc.export("solve", solve.__doc__.strip().split()[0])(solve) cc.compile() exit() else: input = sys.stdin.buffer.readline read = sys.stdin.buffer.read if (USE_NUMBA and sys.argv[-1] != "-p") or sys.argv[-1] == "--numba": # -p: pure python mode # if not -p, import compiled module from my_module import solve # pylint: disable=all elif sys.argv[-1] == "-t": print("testing") _test() sys.exit() elif sys.argv[-1] != "-p" and len(sys.argv) == 2: # input given as file input_as_file = open(sys.argv[1]) input = input_as_file.buffer.readline read = input_as_file.buffer.read main()
Statement Let N be a positive integer. You are given a string s of length N - 1, consisting of `<` and `>`. Find the number of permutations (p_1, p_2, \ldots, p_N) of (1, 2, \ldots, N) that satisfy the following condition, modulo 10^9 + 7: * For each i (1 \leq i \leq N - 1), p_i < p_{i + 1} if the i-th character in s is `<`, and p_i > p_{i + 1} if the i-th character in s is `>`.
[{"input": "4\n <><", "output": "5\n \n\nThere are five permutations that satisfy the condition, as follows:\n\n * (1, 3, 2, 4)\n * (1, 4, 2, 3)\n * (2, 3, 1, 4)\n * (2, 4, 1, 3)\n * (3, 4, 1, 2)\n\n* * *"}, {"input": "5\n <<<<", "output": "1\n \n\nThere is one permutation that satisfies the condition, as follows:\n\n * (1, 2, 3, 4, 5)\n\n* * *"}, {"input": "20\n >>>><>>><>><>>><<>>", "output": "217136290\n \n\nBe sure to print the number modulo 10^9 + 7."}]
Print the number of permutations that satisfy the condition, modulo 10^9 + 7. * * *
s540825907
Wrong Answer
p03179
Input is given from Standard Input in the following format: N s
temp = 1 MOD = 10**9 + 7 fact = [1] infact = [1] for i in range(1, 5000): temp *= i temp %= MOD fact += [temp] infact += [pow(temp, MOD - 2, MOD)] def binomial(a, b): up = fact[a] down = (infact[a - b] * infact[b]) % MOD return (up * down) % MOD def find(s): N = len(s) + 1 dp = [[0 for i in range(N)] for j in range(N)] for length in range(1, N + 1): if length == 1: for start in range(0, N): dp[start][start] = 1 continue if length == 2: for start in range(0, N - 1): dp[start][start + 1] = 1 continue for start in range(0, N - length + 1): left = start right = start + length - 1 if right > N - 1: break if s[left] == ">": dp[left][right] += dp[left + 1][right] if s[right - 1] == "<": dp[left][right] += dp[left][right - 1] for j in range(left, right): if s[j] == "<" and s[j + 1] == ">": need = j + 1 dp[left][right] += ( binomial(length - 1, need - left) * dp[left][need - 1] * dp[need + 1][right] ) % MOD # print(dp) return dp[0][N - 1] % MOD
Statement Let N be a positive integer. You are given a string s of length N - 1, consisting of `<` and `>`. Find the number of permutations (p_1, p_2, \ldots, p_N) of (1, 2, \ldots, N) that satisfy the following condition, modulo 10^9 + 7: * For each i (1 \leq i \leq N - 1), p_i < p_{i + 1} if the i-th character in s is `<`, and p_i > p_{i + 1} if the i-th character in s is `>`.
[{"input": "4\n <><", "output": "5\n \n\nThere are five permutations that satisfy the condition, as follows:\n\n * (1, 3, 2, 4)\n * (1, 4, 2, 3)\n * (2, 3, 1, 4)\n * (2, 4, 1, 3)\n * (3, 4, 1, 2)\n\n* * *"}, {"input": "5\n <<<<", "output": "1\n \n\nThere is one permutation that satisfies the condition, as follows:\n\n * (1, 2, 3, 4, 5)\n\n* * *"}, {"input": "20\n >>>><>>><>><>>><<>>", "output": "217136290\n \n\nBe sure to print the number modulo 10^9 + 7."}]
Print the number of permutations that satisfy the condition, modulo 10^9 + 7. * * *
s473202984
Wrong Answer
p03179
Input is given from Standard Input in the following format: N s
n = int(input()) S = input() p = 10**9 + 7 DP = [[0 for j in range(n + 1)] for i in range(n + 1)] for i in range(2, n + 1): A = [0] for j in range(n): A.append(A[-1] + DP[i - 1][j]) for j in range(n - i + 1): if S[i - 2] == "<": DP[i][j] = (A[n - (i - 1) + 1] - A[j + 1]) % p else: DP[i][j] = A[j + 1] % p print(DP[n][0])
Statement Let N be a positive integer. You are given a string s of length N - 1, consisting of `<` and `>`. Find the number of permutations (p_1, p_2, \ldots, p_N) of (1, 2, \ldots, N) that satisfy the following condition, modulo 10^9 + 7: * For each i (1 \leq i \leq N - 1), p_i < p_{i + 1} if the i-th character in s is `<`, and p_i > p_{i + 1} if the i-th character in s is `>`.
[{"input": "4\n <><", "output": "5\n \n\nThere are five permutations that satisfy the condition, as follows:\n\n * (1, 3, 2, 4)\n * (1, 4, 2, 3)\n * (2, 3, 1, 4)\n * (2, 4, 1, 3)\n * (3, 4, 1, 2)\n\n* * *"}, {"input": "5\n <<<<", "output": "1\n \n\nThere is one permutation that satisfies the condition, as follows:\n\n * (1, 2, 3, 4, 5)\n\n* * *"}, {"input": "20\n >>>><>>><>><>>><<>>", "output": "217136290\n \n\nBe sure to print the number modulo 10^9 + 7."}]
Print the number of permutations that satisfy the condition, modulo 10^9 + 7. * * *
s321259797
Accepted
p03179
Input is given from Standard Input in the following format: N s
from collections import defaultdict, deque, Counter from heapq import heappush, heappop, heapify from bisect import bisect_right, bisect_left import random from itertools import permutations, accumulate, combinations, product import sys import string from bisect import bisect_left, bisect_right from math import factorial, ceil, floor, gamma, log from operator import mul from functools import reduce from copy import deepcopy sys.setrecursionlimit(2147483647) INF = 10**20 def LI(): return list(map(int, sys.stdin.readline().split())) def I(): return int(sys.stdin.readline()) def LS(): return sys.stdin.buffer.readline().rstrip().split() def S(): return sys.stdin.buffer.readline().rstrip().decode("utf-8") def IR(n): return [I() for i in range(n)] def LIR(n): return [LI() for i in range(n)] def SR(n): pass def LSR(n): return [LS() for i in range(n)] def SRL(n): return [list(S()) for i in range(n)] def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)] mod = 10**9 + 7 n = I() fac = [1] * (n + 1) inv = [1] * (n + 1) for j in range(1, n + 1): fac[j] = fac[j - 1] * j % mod inv[n] = pow(fac[n], mod - 2, mod) for j in range(n - 1, -1, -1): inv[j] = inv[j + 1] * (j + 1) % mod def comb(n, r): if r > n or n < 0 or r < 0: return 0 return fac[n] * inv[n - r] * inv[r] % mod s = input() dp = [[0] * n for _ in range(n)] dp[0][0] = 1 for i in range(1, n): ret = 0 if s[i - 1] == "<": for j in range(i - 1, -1, -1): ret += dp[i - 1][j] ret %= mod dp[i][j] = ret else: for j in range(i): ret += dp[i - 1][j] dp[i][j + 1] = ret dp[i][i] = ret print(sum(dp[-1]) % mod)
Statement Let N be a positive integer. You are given a string s of length N - 1, consisting of `<` and `>`. Find the number of permutations (p_1, p_2, \ldots, p_N) of (1, 2, \ldots, N) that satisfy the following condition, modulo 10^9 + 7: * For each i (1 \leq i \leq N - 1), p_i < p_{i + 1} if the i-th character in s is `<`, and p_i > p_{i + 1} if the i-th character in s is `>`.
[{"input": "4\n <><", "output": "5\n \n\nThere are five permutations that satisfy the condition, as follows:\n\n * (1, 3, 2, 4)\n * (1, 4, 2, 3)\n * (2, 3, 1, 4)\n * (2, 4, 1, 3)\n * (3, 4, 1, 2)\n\n* * *"}, {"input": "5\n <<<<", "output": "1\n \n\nThere is one permutation that satisfies the condition, as follows:\n\n * (1, 2, 3, 4, 5)\n\n* * *"}, {"input": "20\n >>>><>>><>><>>><<>>", "output": "217136290\n \n\nBe sure to print the number modulo 10^9 + 7."}]
Print the number of permutations that satisfy the condition, modulo 10^9 + 7. * * *
s901300258
Accepted
p03179
Input is given from Standard Input in the following format: N s
N = int(input()) S = str(input()) P = 10**9 + 7 DP = [[0] * (N + 1) for _ in range(N + 1)] # 初期 for index1 in range(N): DP[1][index1] = 1 for i in range(2, N): # 累積和 C = [0] * (N + 1) C[0] = DP[i - 1][0] % P for index2 in range(1, N + 1): C[index2] = (C[index2 - 1] + DP[i - 1][index2]) % P for j in range(N - i + 1): if S[i - 2] == ">": DP[i][j] = (C[N - i + 1] - C[j]) % P else: DP[i][j] = C[j] if S[N - 2] == ">": DP[N][0] = DP[N - 1][1] else: DP[N][0] = DP[N - 1][0] print(DP[N][0] % P)
Statement Let N be a positive integer. You are given a string s of length N - 1, consisting of `<` and `>`. Find the number of permutations (p_1, p_2, \ldots, p_N) of (1, 2, \ldots, N) that satisfy the following condition, modulo 10^9 + 7: * For each i (1 \leq i \leq N - 1), p_i < p_{i + 1} if the i-th character in s is `<`, and p_i > p_{i + 1} if the i-th character in s is `>`.
[{"input": "4\n <><", "output": "5\n \n\nThere are five permutations that satisfy the condition, as follows:\n\n * (1, 3, 2, 4)\n * (1, 4, 2, 3)\n * (2, 3, 1, 4)\n * (2, 4, 1, 3)\n * (3, 4, 1, 2)\n\n* * *"}, {"input": "5\n <<<<", "output": "1\n \n\nThere is one permutation that satisfies the condition, as follows:\n\n * (1, 2, 3, 4, 5)\n\n* * *"}, {"input": "20\n >>>><>>><>><>>><<>>", "output": "217136290\n \n\nBe sure to print the number modulo 10^9 + 7."}]
Print the total amount Mr. Takaha will pay. * * *
s945400738
Runtime Error
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
n=int(input()) p=[int(input()) for i in range(n)] print(int(sum(p)-(max(p)/2))
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s748813165
Wrong Answer
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
def chrieve(): num = int(input("品物の個数を入力してください。")) if 2 > num or 10 < num: return print("入力値は2~10です。") cost = [] expensive = 0 sum = 0 for i in range(num): cost.append(int(input("品物の価格を入力してください。"))) if 100 <= cost[i] <= 10000 and cost[i] % 2 == 0: if expensive <= cost[i]: expensive = cost[i] sum += cost[i] else: return print("商品の価格を守り、正しく入力してください。") sum -= expensive / 2 return print(int(sum)) chrieve()
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s508187578
Runtime Error
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
n, k = map(int, input().split()) l = [] for _ in range(n): l.append(int(input())) l.sort() a = 0 for i in range(n - k + 1): if i == 0: a = l[i + k - 1] - l[i] else: a = min(a, abs(l[i + k - 1] - l[i])) print(a) n, k = map(int, input().split()) l = [] for _ in range(n): l.append(int(input())) l.sort() a = 0 for i in range(n - k + 1): if i == 0: a = l[i + k - 1] - l[i] else: a = min(a, abs(l[i + k - 1] - l[i])) print(a)
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s108361019
Wrong Answer
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
items = input() items = items.split() items2 = [] for i in items: items2.append(int(i)) maxitem = max(items2) print(sum(items2) - maxitem / 2)
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s880948651
Runtime Error
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
N = int(input()) P = [] for i in range(N): P.append(int(input()) print(sum(P) - max(P) // 2)
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s854074314
Runtime Error
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
n = int(input()) items = [] for i in range(n): items.append(int(input()) print(sum(items)-max(items)/2)
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s364447385
Wrong Answer
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
S = input() if S[0] != "A": print("WA") exit() if S[2:].count("C") != 1: print("WA") exit() for i in range(len(S)): if i in [0, 2]: if S[i] != S[i].upper(): print("WA") exit() continue if S[i] != S[i].lower(): print("WA") exit() print("AC")
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s665386457
Accepted
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
A = int(input()) B = [int(input()) for _ in range(A)] p = 0 B = sorted(B) b = B.pop(-1) for i in B: p += i print(b // 2 + p)
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s484017039
Runtime Error
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
l=[int(input()) for range(int(input())] print(sum(l)-int(max(l)/2))
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s916230471
Accepted
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
#!/usr/bin/env python3 import sys # import math # from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits # import re # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s) # from operator import itemgetter # itemgetter(1), itemgetter('key') # from collections import deque # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate() # from collections import defaultdict # subclass of dict. defaultdict(facroty) # from collections import Counter # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter) # from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn). # from heapq import nlargest, nsmallest # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn). # from itertools import count, cycle, repeat # count(start[,step]), cycle(iter), repeat(elm[,n]) # from itertools import groupby # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])] # from itertools import starmap # starmap(pow, [[2,5], [3,2]]) returns [32, 9] # from itertools import product, permutations # product(iter, repeat=n), permutations(iter[,r]) # from itertools import combinations, combinations_with_replacement # from itertools import accumulate # accumulate(iter[, f]) # from functools import reduce # reduce(f, iter[, init]) # from functools import lru_cache # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed) # from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]). # from copy import deepcopy # to copy multi-dimentional matrix without reference # from fractions import gcd # for Python 3.4 (previous contest @AtCoder) def main(): mod = 1000000007 # 10^9+7 inf = float("inf") # sys.float_info.max = 1.79...e+308 # inf = 2 ** 64 - 1 # (for fast JIT compile in PyPy) 1.84...e+19 sys.setrecursionlimit(10**6) # 1000 -> 1000000 def input(): return sys.stdin.readline().rstrip() def ii(): return int(input()) def mi(): return map(int, input().split()) def mi_0(): return map(lambda x: int(x) - 1, input().split()) def lmi(): return list(map(int, input().split())) def lmi_0(): return list(map(lambda x: int(x) - 1, input().split())) def li(): return list(input()) n = ii() p = [ii() for _ in range(n)] print(sum(p) - max(p) // 2) if __name__ == "__main__": main()
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s878731549
Runtime Error
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
A, B = map(int, input().split()) C = [int(input()) for _ in range(A)] c = [] p = 0 C = sorted(C) for i in range(B, A + 1): c.append(max(C[i - (B) : i]) - min(C[i - (B) : i])) print(C[i - (B) : i]) print(min(c))
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s439447932
Runtime Error
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
N = int(input()) p = int([input() for i in range(N)]) max = 100 for i in range(N): if p(i) > max: max = p(i) m = i p(m) = p(m) / 2 for i in range(N): A += p(i) print(A)
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s220161604
Accepted
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
L = [int(input()) for _ in range(int(input()))] print(sum(L) - int(max(L) / 2))
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s796777583
Wrong Answer
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
4 4320 4320 4320 4320
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s258404262
Wrong Answer
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
a, *n = map(int, open(0)) print(sum(n) - max(n) / 2)
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s874434109
Wrong Answer
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
(*a,) = map(int, open(0)) print(sum(a) - max(a) // 2 - 4)
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s602873560
Runtime Error
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
n = int(input()) p=[int,input() for i in range(n)] print(sum(p)-max(p)//2)
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s389922308
Wrong Answer
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
n = int(input()) t = [int(input()) for i in range(n)] kk = max(t) print(sum(t) - kk / 2)
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s376683038
Runtime Error
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
n = int(input()) p = [int(input()) for in range(n)] print(sum(p) - max(p)//2)
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s112412216
Runtime Error
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
n=int(input()) a=list(map(int,input()) b=sum(a)-max(a)/2 print(b)
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s244036084
Runtime Error
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
print(sum(p) - max([int(input()) for i in range(int(input()))]) // 2)
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s218544445
Runtime Error
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
n=int(input()) s=[list(map(int,list(input()))) for i in range(h)] print(sum(s)-1/2max(s))
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s288982550
Wrong Answer
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
l = int(input()) b = [int(i) for i in range(l)] print(sum(b) - max(b) / 2)
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s523992999
Wrong Answer
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
3 4980 7980 6980
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s624556859
Runtime Error
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
n = int(input()) p = [int(input()) for _ in range(n)] print(int(sum(p) - max(p)/2)
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s443570757
Runtime Error
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
n = int(input()) p = [int(input()) for in range(n)] print(sum(p) - max(p)//2)
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s981455929
Runtime Error
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
fun main(args:Array<String>) { val itemCount = readLine()!!.toInt() val items = (1..itemCount).map { readLine()!!.toInt() }.sortedDescending() val ans = items[0] / 2 + items.drop(1).sum() println(ans) }
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s719479264
Runtime Error
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
import numpy as np N = int(input()) price = [] for i in range(N): price.append(int(input())) price = np.array(price) max_index = np.argmax(price) print(int(np.sum(price) - price[max_index] / 2
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s848825466
Runtime Error
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
n = int(input()) max = 0 sum = 0 for i in range(n) data = int(input()) if max < data: max = data sum = sum + data print(sum - max//2)
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s039932107
Runtime Error
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
N = int(input()) price = [] p = 0 for i in range(N): price.append(int(input()) m = price.index(max(price)) for j in range(len(price)): if j != m: p += price[j] else: p += price[j]//2 print(p)
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s178581383
Runtime Error
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
#! /usr/bin/env python3 # -*- coding: utf-8 -*- N = int(input()) p = [] for _ in range(N): p.append(int(input()) pmax = max(p) ans = int(sum(p)-pmax/2) print(ans)
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s971606339
Runtime Error
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
n = int(input()) max = 0 sum = 0 for i in range(n): data = int(input()) if max < data: max = data sum = sum + data print(sum - max//2)
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s710831084
Runtime Error
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
a = int(input()) b = [int(input()) for _ in range(a)] b = sorted(b, key=lambda, x: x[0], reverse=True) c = 1 for i in range(a): if i == 0: c += b[i] // 2 else: c += b[i] print(c)
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s420630405
Runtime Error
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
N = int(input()) p = [0] * N max_value = 0 for i in range(N): p[i] = int(input()) max_value = max(max_value, p[i]) price = sum(p) - max_value / 2 print(int(price)
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s394360402
Runtime Error
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
N = int(input()) num = N+1price = [] for i in range (1,num): price.append(int(input())) else: exp = max(price)//2 total = sum(price) - exp print(total)
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s681840058
Runtime Error
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
n = int(input()) max = 0 sum = 0 #print ("START") for i in range(n): data = (input() # print("aaa") data = int(data) # print(data) if max < data: max = data sum = sum + data print(sum - max//2)
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s494475701
Wrong Answer
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
d = int(input()) x = "Christmas" y = "Eve" if d == 25: print(x) elif d == 24: print("{} {}".format(x, y)) elif d == 23: print("{} {} {}".format(x, y, y)) else: print("{} {} {} {}".format(x, y, y, y))
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s847829719
Runtime Error
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
a = 0 c = 0 for i in range(int(input())): b = int(input()) if b > a: a = b c += a else: c += b c += (a/2) print (round(c))
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s292156420
Runtime Error
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
times = int(input()) prices = [] for i in range(times): prices.append(int(input()) max_price = max(prices) prices.delete(max_prices) prices.append(max_price/2) print(sum(prices))
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s359940240
Runtime Error
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
= int(input()) highest_price = 0 sum = 0 for i in range(n): product = int(input()) if highest_price < product: sum += highest_price/2 highest_price = product sum += highest_price/2 else: sum += product print(int(sum))
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s239349065
Runtime Error
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
N = int(input()) price_list = [] append = pricelist.append for i in range(N): p = int(input) append(p) pricelist.sort(reverse=True) pricelist[0] = pricelist[0] / 2 print(sum(pricelist))
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s028434684
Runtime Error
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
N = int(input()), sum = 0, mx = 0 for i in range(N): P = int(input()) sum += P mx = max(mx, P) print(sum - mx / 2)
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s877002216
Runtime Error
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
n=int(input()) l=[] p=0 for I in range(1,n+1): l.append(int(input()) l.sort() for I in l: p+=I print(p+max(l))
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s289746732
Runtime Error
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
N = int(input()) table = [] for i in range(N): table.append(int(input())) print(sum(table[:]) - max(table) * // 2)
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s082790341
Runtime Error
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
N = int(input()) S = [int(input()) for _ in range(N)] A = sorted(S, reverse=True) S[0] = S[0]/2 print(sum(int(S))
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]
Print the total amount Mr. Takaha will pay. * * *
s843108733
Wrong Answer
p03207
Input is given from Standard Input in the following format: N p_1 p_2 : p_N
N = int(input()) num = N + 1 pre = 1 for i in range(1, num): total = i * pre pre = total % (10**9 + 7) else: print(pre)
Statement In some other world, today is the day before Christmas Eve. Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \leq i \leq N) is p_i yen (the currency of Japan). He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N-1 items cost their regular prices. What is the total amount he will pay?
[{"input": "3\n 4980\n 7980\n 6980", "output": "15950\n \n\nThe 7980-yen item gets the discount and the total is 4980 + 7980 / 2 + 6980 =\n15950 yen.\n\nNote that outputs such as `15950.0` will be judged as Wrong Answer.\n\n* * *"}, {"input": "4\n 4320\n 4320\n 4320\n 4320", "output": "15120\n \n\nOnly one of the four items gets the discount and the total is 4320 / 2 + 4320\n+ 4320 + 4320 = 15120 yen."}]