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
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s883480046
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
a,b,c=map(int,input().split()) if a=b+c or b=c+a or c= a+b: print('Yes') else: prine('No')
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s010959213
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
a=input(a) b=input(b) c=input(c) if a+b==c || b+c==a || a+c==b: print("Yes") else: print("No")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s971010383
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
abc = sorted(list(map(int, input().split()))) print(` Yes ` if abc[0] + abc[1] == abc[2] else ` No `)
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s034740704
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
a, b, c = map(int,input().split()) if a + b = c or b + c = a or a + c = b: print("Yes") else: print("No")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s736684472
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
a,b,c = map(int, input().split()) if a=b+c or b=a+c or c=a+b: print("Yes") else: print("No")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s716558808
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
lst = [int(i) for i in input().split()] m = max(lst) if sum(lst) = 2*m: print('Yes') else: print('No')
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s230037400
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
a,b,c=map(int,input().split()) if a == b + c or b = c + a c = b + a: print("YES") else: print("NO")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s272571149
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
a,b,c = map(int,input().split()) if a + b = c or b + c = a or c + a = b: print("Yes") else: print("No")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
For each test case, print a line containing `0` if x becomes 0 at the end of the game, and `1` otherwise. * * *
s410774416
Accepted
p02651
Input is given from Standard Input in the following format. The first line is as follows: T Then, T test cases follow. Each test case is given in the following format: N A_1 A_2 \cdots A_N S
import sys sys.setrecursionlimit(10**5) input = sys.stdin.readline enum = enumerate inf = 1001001002002002002 import random def linput(ty=int, cvt=list): return cvt(map(ty, input().rstrip().split())) def vinput(rep=1, ty=int, cvt=list): return cvt(ty(input().rstrip()) for _ in "*" * rep) def gcd(a: int, b: int): while b: a, b = b, a % b return a def lcm(a: int, b: int): return a * b // gcd(a, b) def bye(res): sT = "No Yes".split() print(sT[res]) # exit(0) def sol(N, vA, S): sZ = set( { 0, } ) for a, c in zip(vA[::-1], S[::-1]): v = a for z in reversed(sorted(list(sZ))): v = min(v, v ^ z) # if not N: print(z,v)## if c == "0": sZ |= { v, } elif v not in sZ: sZ = set({}) break # else: # pass # sZ = sZ # if not N: print(sZ)## res = 1 if sZ: res = 0 # print(sZ)### print(res) def main(): (T,) = linput() for _ in "*" * T: (N,) = linput() vA = linput() (S,) = linput(str) sol(N, vA, S) def ran(): N = 200 # N=6 vRan = [random.randint(1, 10) for _ in "*" * N] S = "".join(str(random.randint(0, 1)) for _ in "*" * N) # print(max(vRan))# # vRan = [5, 7, 7, 3, 1, 7]### # S = "111000"### print(vRan, S) sol(N=0, vA=vRan, S=S) exit(0) if __name__ == "__main__": # ran() main()
Statement There are two persons, numbered 0 and 1, and a variable x whose initial value is 0. The two persons now play a game. The game is played in N rounds. The following should be done in the i-th round (1 \leq i \leq N): * Person S_i does one of the following: * Replace x with x \oplus A_i, where \oplus represents bitwise XOR. * Do nothing. Person 0 aims to have x=0 at the end of the game, while Person 1 aims to have x \neq 0 at the end of the game. Determine whether x becomes 0 at the end of the game when the two persons play optimally. Solve T test cases for each input file.
[{"input": "3\n 2\n 1 2\n 10\n 2\n 1 1\n 10\n 6\n 2 3 4 5 6 7\n 111000", "output": "1\n 0\n 0\n \n\nIn the first test case, if Person 1 replaces x with 0 \\oplus 1=1, we surely\nhave x \\neq 0 at the end of the game, regardless of the choice of Person 0.\n\nIn the second test case, regardless of the choice of Person 1, Person 0 can\nmake x=0 with a suitable choice."}]
For each test case, print a line containing `0` if x becomes 0 at the end of the game, and `1` otherwise. * * *
s990152065
Wrong Answer
p02651
Input is given from Standard Input in the following format. The first line is as follows: T Then, T test cases follow. Each test case is given in the following format: N A_1 A_2 \cdots A_N S
1
Statement There are two persons, numbered 0 and 1, and a variable x whose initial value is 0. The two persons now play a game. The game is played in N rounds. The following should be done in the i-th round (1 \leq i \leq N): * Person S_i does one of the following: * Replace x with x \oplus A_i, where \oplus represents bitwise XOR. * Do nothing. Person 0 aims to have x=0 at the end of the game, while Person 1 aims to have x \neq 0 at the end of the game. Determine whether x becomes 0 at the end of the game when the two persons play optimally. Solve T test cases for each input file.
[{"input": "3\n 2\n 1 2\n 10\n 2\n 1 1\n 10\n 6\n 2 3 4 5 6 7\n 111000", "output": "1\n 0\n 0\n \n\nIn the first test case, if Person 1 replaces x with 0 \\oplus 1=1, we surely\nhave x \\neq 0 at the end of the game, regardless of the choice of Person 0.\n\nIn the second test case, regardless of the choice of Person 1, Person 0 can\nmake x=0 with a suitable choice."}]
For each test case, print a line containing `0` if x becomes 0 at the end of the game, and `1` otherwise. * * *
s215998426
Wrong Answer
p02651
Input is given from Standard Input in the following format. The first line is as follows: T Then, T test cases follow. Each test case is given in the following format: N A_1 A_2 \cdots A_N S
print("pardon me")
Statement There are two persons, numbered 0 and 1, and a variable x whose initial value is 0. The two persons now play a game. The game is played in N rounds. The following should be done in the i-th round (1 \leq i \leq N): * Person S_i does one of the following: * Replace x with x \oplus A_i, where \oplus represents bitwise XOR. * Do nothing. Person 0 aims to have x=0 at the end of the game, while Person 1 aims to have x \neq 0 at the end of the game. Determine whether x becomes 0 at the end of the game when the two persons play optimally. Solve T test cases for each input file.
[{"input": "3\n 2\n 1 2\n 10\n 2\n 1 1\n 10\n 6\n 2 3 4 5 6 7\n 111000", "output": "1\n 0\n 0\n \n\nIn the first test case, if Person 1 replaces x with 0 \\oplus 1=1, we surely\nhave x \\neq 0 at the end of the game, regardless of the choice of Person 0.\n\nIn the second test case, regardless of the choice of Person 1, Person 0 can\nmake x=0 with a suitable choice."}]
For each test case, print a line containing `0` if x becomes 0 at the end of the game, and `1` otherwise. * * *
s080642284
Wrong Answer
p02651
Input is given from Standard Input in the following format. The first line is as follows: T Then, T test cases follow. Each test case is given in the following format: N A_1 A_2 \cdots A_N S
print(1)
Statement There are two persons, numbered 0 and 1, and a variable x whose initial value is 0. The two persons now play a game. The game is played in N rounds. The following should be done in the i-th round (1 \leq i \leq N): * Person S_i does one of the following: * Replace x with x \oplus A_i, where \oplus represents bitwise XOR. * Do nothing. Person 0 aims to have x=0 at the end of the game, while Person 1 aims to have x \neq 0 at the end of the game. Determine whether x becomes 0 at the end of the game when the two persons play optimally. Solve T test cases for each input file.
[{"input": "3\n 2\n 1 2\n 10\n 2\n 1 1\n 10\n 6\n 2 3 4 5 6 7\n 111000", "output": "1\n 0\n 0\n \n\nIn the first test case, if Person 1 replaces x with 0 \\oplus 1=1, we surely\nhave x \\neq 0 at the end of the game, regardless of the choice of Person 0.\n\nIn the second test case, regardless of the choice of Person 1, Person 0 can\nmake x=0 with a suitable choice."}]
For each test case, print a line containing `0` if x becomes 0 at the end of the game, and `1` otherwise. * * *
s837322360
Wrong Answer
p02651
Input is given from Standard Input in the following format. The first line is as follows: T Then, T test cases follow. Each test case is given in the following format: N A_1 A_2 \cdots A_N S
print("a")
Statement There are two persons, numbered 0 and 1, and a variable x whose initial value is 0. The two persons now play a game. The game is played in N rounds. The following should be done in the i-th round (1 \leq i \leq N): * Person S_i does one of the following: * Replace x with x \oplus A_i, where \oplus represents bitwise XOR. * Do nothing. Person 0 aims to have x=0 at the end of the game, while Person 1 aims to have x \neq 0 at the end of the game. Determine whether x becomes 0 at the end of the game when the two persons play optimally. Solve T test cases for each input file.
[{"input": "3\n 2\n 1 2\n 10\n 2\n 1 1\n 10\n 6\n 2 3 4 5 6 7\n 111000", "output": "1\n 0\n 0\n \n\nIn the first test case, if Person 1 replaces x with 0 \\oplus 1=1, we surely\nhave x \\neq 0 at the end of the game, regardless of the choice of Person 0.\n\nIn the second test case, regardless of the choice of Person 1, Person 0 can\nmake x=0 with a suitable choice."}]
For each evaluation query, print a line containing the response, in the order in which the queries are given. The response to each evaluation query should be the minimum value of x that minimizes f(x), and the minimum value of f(x), in this order, with space in between. * * *
s135250536
Wrong Answer
p03040
Input is given from Standard Input in the following format: Q Query_1 : Query_Q See Sample Input 1 for an example.
argQ = int(input()) flgFirst = True aryA = [] argB = 0 for i in range(argQ): wk = list(map(int, input().split())) if wk[0] == 1: flgFirst = False aryA.append(wk[1]) argB += wk[2] else: # wk[0] == 2 if flgFirst == True: ans1 = 0 ans2 = 0 else: ans1 = min(aryA) ans2 = argB for i in range(len(aryA)): ans2 += abs(ans1 - aryA[i]) print(str(ans1) + " " + str(ans2))
Statement There is a function f(x), which is initially a constant function f(x) = 0. We will ask you to process Q queries in order. There are two kinds of queries, update queries and evaluation queries, as follows: * An update query `1 a b`: Given two integers a and b, let g(x) = f(x) + |x - a| + b and replace f(x) with g(x). * An evaluation query `2`: Print x that minimizes f(x), and the minimum value of f(x). If there are multiple such values of x, choose the minimum such value. We can show that the values to be output in an evaluation query are always integers, so we ask you to print those values as integers without decimal points.
[{"input": "4\n 1 4 2\n 2\n 1 1 -8\n 2", "output": "4 2\n 1 -3\n \n\nIn the first evaluation query, f(x) = |x - 4| + 2, which attains the minimum\nvalue of 2 at x = 4.\n\nIn the second evaluation query, f(x) = |x - 1| + |x - 4| - 6, which attains\nthe minimum value of -3 when 1 \\leq x \\leq 4. Among the multiple values of x\nthat minimize f(x), we ask you to print the minimum, that is, 1.\n\n* * *"}, {"input": "4\n 1 -1000000000 1000000000\n 1 -1000000000 1000000000\n 1 -1000000000 1000000000\n 2", "output": "-1000000000 3000000000"}]
For each evaluation query, print a line containing the response, in the order in which the queries are given. The response to each evaluation query should be the minimum value of x that minimizes f(x), and the minimum value of f(x), in this order, with space in between. * * *
s290058912
Wrong Answer
p03040
Input is given from Standard Input in the following format: Q Query_1 : Query_Q See Sample Input 1 for an example.
a, b = 0, 0 am = [] amin = 1000000000 amax = -1000000000 num = 0 asum = 0 def fmin(am, b, amin, amax, asum, num): kmin = 1000000000000000000 imin = amin ii = asum // num for i in range(ii, ii + 2): k = 0 for j in range(num): k += abs(am[j] - i) if kmin > k: kmin = k imin = i print(imin, kmin + b) return for _ in range(int(input())): q = input() if q == "2": fmin(am, b, amin, amax, asum, num) else: t, a1, b1 = map(int, q.split()) am += [a1] b += b1 amin = min(amin, a1) amax = max(amax, a1) asum += a1 num += 1
Statement There is a function f(x), which is initially a constant function f(x) = 0. We will ask you to process Q queries in order. There are two kinds of queries, update queries and evaluation queries, as follows: * An update query `1 a b`: Given two integers a and b, let g(x) = f(x) + |x - a| + b and replace f(x) with g(x). * An evaluation query `2`: Print x that minimizes f(x), and the minimum value of f(x). If there are multiple such values of x, choose the minimum such value. We can show that the values to be output in an evaluation query are always integers, so we ask you to print those values as integers without decimal points.
[{"input": "4\n 1 4 2\n 2\n 1 1 -8\n 2", "output": "4 2\n 1 -3\n \n\nIn the first evaluation query, f(x) = |x - 4| + 2, which attains the minimum\nvalue of 2 at x = 4.\n\nIn the second evaluation query, f(x) = |x - 1| + |x - 4| - 6, which attains\nthe minimum value of -3 when 1 \\leq x \\leq 4. Among the multiple values of x\nthat minimize f(x), we ask you to print the minimum, that is, 1.\n\n* * *"}, {"input": "4\n 1 -1000000000 1000000000\n 1 -1000000000 1000000000\n 1 -1000000000 1000000000\n 2", "output": "-1000000000 3000000000"}]
For each evaluation query, print a line containing the response, in the order in which the queries are given. The response to each evaluation query should be the minimum value of x that minimizes f(x), and the minimum value of f(x), in this order, with space in between. * * *
s338159296
Wrong Answer
p03040
Input is given from Standard Input in the following format: Q Query_1 : Query_Q See Sample Input 1 for an example.
n = int(input()) o = lambda: map(int, input().split()) v = 0 e = 0 a = [] b = [] for i in range(n): l = list(o()) if len(l) > 1: q, u, t = l a += [u] b += [t] if i == 0: e = u v = t else: m = [] for i, p in enumerate(b): if p == min(b): u = a[i] t = sum(abs(c - a[i]) for c in a) + sum(b) m += [t] if min(m) == t: e = u v = t else: print(e, v)
Statement There is a function f(x), which is initially a constant function f(x) = 0. We will ask you to process Q queries in order. There are two kinds of queries, update queries and evaluation queries, as follows: * An update query `1 a b`: Given two integers a and b, let g(x) = f(x) + |x - a| + b and replace f(x) with g(x). * An evaluation query `2`: Print x that minimizes f(x), and the minimum value of f(x). If there are multiple such values of x, choose the minimum such value. We can show that the values to be output in an evaluation query are always integers, so we ask you to print those values as integers without decimal points.
[{"input": "4\n 1 4 2\n 2\n 1 1 -8\n 2", "output": "4 2\n 1 -3\n \n\nIn the first evaluation query, f(x) = |x - 4| + 2, which attains the minimum\nvalue of 2 at x = 4.\n\nIn the second evaluation query, f(x) = |x - 1| + |x - 4| - 6, which attains\nthe minimum value of -3 when 1 \\leq x \\leq 4. Among the multiple values of x\nthat minimize f(x), we ask you to print the minimum, that is, 1.\n\n* * *"}, {"input": "4\n 1 -1000000000 1000000000\n 1 -1000000000 1000000000\n 1 -1000000000 1000000000\n 2", "output": "-1000000000 3000000000"}]
For each evaluation query, print a line containing the response, in the order in which the queries are given. The response to each evaluation query should be the minimum value of x that minimizes f(x), and the minimum value of f(x), in this order, with space in between. * * *
s032807357
Wrong Answer
p03040
Input is given from Standard Input in the following format: Q Query_1 : Query_Q See Sample Input 1 for an example.
q = int(input()) a = [] b = 0 def query2(a, b, x): ret = b for sa in a: ret += abs(x - sa) return ret for _ in range(q): x = list(map(int, input().split())) if x[0] == 1: a.append(x[1]) b += x[2] elif x[0] == 2: r1 = a[(len(a) - 1) // 2] r2 = query2(a, b, r1) print(str(r1) + " " + str(r2))
Statement There is a function f(x), which is initially a constant function f(x) = 0. We will ask you to process Q queries in order. There are two kinds of queries, update queries and evaluation queries, as follows: * An update query `1 a b`: Given two integers a and b, let g(x) = f(x) + |x - a| + b and replace f(x) with g(x). * An evaluation query `2`: Print x that minimizes f(x), and the minimum value of f(x). If there are multiple such values of x, choose the minimum such value. We can show that the values to be output in an evaluation query are always integers, so we ask you to print those values as integers without decimal points.
[{"input": "4\n 1 4 2\n 2\n 1 1 -8\n 2", "output": "4 2\n 1 -3\n \n\nIn the first evaluation query, f(x) = |x - 4| + 2, which attains the minimum\nvalue of 2 at x = 4.\n\nIn the second evaluation query, f(x) = |x - 1| + |x - 4| - 6, which attains\nthe minimum value of -3 when 1 \\leq x \\leq 4. Among the multiple values of x\nthat minimize f(x), we ask you to print the minimum, that is, 1.\n\n* * *"}, {"input": "4\n 1 -1000000000 1000000000\n 1 -1000000000 1000000000\n 1 -1000000000 1000000000\n 2", "output": "-1000000000 3000000000"}]
For each evaluation query, print a line containing the response, in the order in which the queries are given. The response to each evaluation query should be the minimum value of x that minimizes f(x), and the minimum value of f(x), in this order, with space in between. * * *
s998302902
Accepted
p03040
Input is given from Standard Input in the following format: Q Query_1 : Query_Q See Sample Input 1 for an example.
import sys input = sys.stdin.readline import heapq def main(): less = [] greater = [] s = 0 sum_ = 0 q = int(input()) def query(n): nonlocal s, sum_ if n[0] == "1": c, a, b = map(int, n.split()) s += b if len(less) == len(greater): if not greater or a <= greater[0]: heapq.heappush(less, -a) sum_ -= a else: r = heapq.heappushpop(greater, a) heapq.heappush(less, -r) sum_ += a - 2 * r else: if a >= -less[0]: heapq.heappush(greater, a) sum_ += a else: r = -heapq.heappushpop(less, -a) heapq.heappush(greater, r) sum_ += 2 * r - a else: res = sum_ if len(less) > len(greater): res -= less[0] res += s print(-less[0], res) for _ in range(q): k = input() query(k) if __name__ == "__main__": main()
Statement There is a function f(x), which is initially a constant function f(x) = 0. We will ask you to process Q queries in order. There are two kinds of queries, update queries and evaluation queries, as follows: * An update query `1 a b`: Given two integers a and b, let g(x) = f(x) + |x - a| + b and replace f(x) with g(x). * An evaluation query `2`: Print x that minimizes f(x), and the minimum value of f(x). If there are multiple such values of x, choose the minimum such value. We can show that the values to be output in an evaluation query are always integers, so we ask you to print those values as integers without decimal points.
[{"input": "4\n 1 4 2\n 2\n 1 1 -8\n 2", "output": "4 2\n 1 -3\n \n\nIn the first evaluation query, f(x) = |x - 4| + 2, which attains the minimum\nvalue of 2 at x = 4.\n\nIn the second evaluation query, f(x) = |x - 1| + |x - 4| - 6, which attains\nthe minimum value of -3 when 1 \\leq x \\leq 4. Among the multiple values of x\nthat minimize f(x), we ask you to print the minimum, that is, 1.\n\n* * *"}, {"input": "4\n 1 -1000000000 1000000000\n 1 -1000000000 1000000000\n 1 -1000000000 1000000000\n 2", "output": "-1000000000 3000000000"}]
For each evaluation query, print a line containing the response, in the order in which the queries are given. The response to each evaluation query should be the minimum value of x that minimizes f(x), and the minimum value of f(x), in this order, with space in between. * * *
s261479581
Wrong Answer
p03040
Input is given from Standard Input in the following format: Q Query_1 : Query_Q See Sample Input 1 for an example.
import sys sys.setrecursionlimit(10**9) def mi(): return map(int, input().split()) def ii(): return int(input()) def isp(): return input().split() def deb(text): print("-------\n{}\n-------".format(text)) INF = 10**20 def main(): Q = ii() max_a = -INF min_a = INF a_sum = 0 b_sum = 0 n = 0 for q in range(Q): S = input() if S == "2": y = INF ans = INF for x in [min_a, max_a]: if x == INF or x == -INF: continue ny = abs(n * x - a_sum) + b_sum # 三角不等式 if y > ny: y = ny ans = min(ans, x) assert y != INF print(ans, y) else: _, a, b = map(int, S.split()) max_a = max(max_a, a) min_a = min(min_a, a) a_sum += a b_sum += b n += 1 if __name__ == "__main__": main()
Statement There is a function f(x), which is initially a constant function f(x) = 0. We will ask you to process Q queries in order. There are two kinds of queries, update queries and evaluation queries, as follows: * An update query `1 a b`: Given two integers a and b, let g(x) = f(x) + |x - a| + b and replace f(x) with g(x). * An evaluation query `2`: Print x that minimizes f(x), and the minimum value of f(x). If there are multiple such values of x, choose the minimum such value. We can show that the values to be output in an evaluation query are always integers, so we ask you to print those values as integers without decimal points.
[{"input": "4\n 1 4 2\n 2\n 1 1 -8\n 2", "output": "4 2\n 1 -3\n \n\nIn the first evaluation query, f(x) = |x - 4| + 2, which attains the minimum\nvalue of 2 at x = 4.\n\nIn the second evaluation query, f(x) = |x - 1| + |x - 4| - 6, which attains\nthe minimum value of -3 when 1 \\leq x \\leq 4. Among the multiple values of x\nthat minimize f(x), we ask you to print the minimum, that is, 1.\n\n* * *"}, {"input": "4\n 1 -1000000000 1000000000\n 1 -1000000000 1000000000\n 1 -1000000000 1000000000\n 2", "output": "-1000000000 3000000000"}]
For each evaluation query, print a line containing the response, in the order in which the queries are given. The response to each evaluation query should be the minimum value of x that minimizes f(x), and the minimum value of f(x), in this order, with space in between. * * *
s826261581
Accepted
p03040
Input is given from Standard Input in the following format: Q Query_1 : Query_Q See Sample Input 1 for an example.
from heapq import heappop, heappush class MedianContainer: def __init__(self): self._left_q = [] self._right_q = [] self._left_sum = 0 self._right_sum = 0 self._med1, self._med2 = None, None self._med = None def insert(self, x): if not any([self._med, self._med1, self._med2]): # First insert self._med = x elif self._med is None and self._med1 is not None and self._med2 is not None: if x <= self._med1: heappush(self._left_q, x * (-1)) heappush(self._right_q, self._med2) self._left_sum += x self._right_sum += self._med2 self._med = self._med1 elif x >= self._med2: heappush(self._left_q, self._med1 * (-1)) heappush(self._right_q, x) self._left_sum += self._med1 self._right_sum += x self._med = self._med2 else: heappush(self._left_q, self._med1 * (-1)) heappush(self._right_q, self._med2) self._left_sum += self._med1 self._right_sum += self._med2 self._med = x self._med1, self._med2 = None, None else: if x <= self._med: heappush(self._left_q, x * (-1)) self._med1 = heappop(self._left_q) * (-1) self._left_sum += x self._left_sum -= self._med1 self._med2 = self._med else: heappush(self._right_q, x) self._right_sum += x self._med1 = self._med self._med2 = heappop(self._right_q) self._right_sum -= self._med2 self._med = None def get_med(self): if self._med is not None: return [self._med] else: return [self._med1, self._med2] def get_left_sum(self): return self._left_sum def get_right_sum(self): return self._right_sum def get_half_len(self): return len(self._left_q) q = int(input()) ans = 0 mid_1 = 0 mid_2 = 0 mid = 0 left_q = [] right_q = [] left_sum = 0 right_sum = 0 const_b = 0 ansl = [] mc = MedianContainer() for _ in range(q): row = list(input().split()) if row[0] == "2": half_len = mc.get_half_len() meds = mc.get_med() if len(meds) == 1: left_sum = meds[0] * half_len - mc.get_left_sum() right_sum = mc.get_right_sum() - meds[0] * half_len ans = left_sum + right_sum + const_b ansl.append((meds[0], ans)) else: left_sum = meds[0] * half_len - mc.get_left_sum() right_sum = mc.get_right_sum() - meds[0] * half_len ans = left_sum + right_sum + (meds[1] - meds[0]) + const_b ansl.append((meds[0], ans)) else: a, b = int(row[1]), int(row[2]) const_b += b mc.insert(a) for ax, av in ansl: print(ax, av)
Statement There is a function f(x), which is initially a constant function f(x) = 0. We will ask you to process Q queries in order. There are two kinds of queries, update queries and evaluation queries, as follows: * An update query `1 a b`: Given two integers a and b, let g(x) = f(x) + |x - a| + b and replace f(x) with g(x). * An evaluation query `2`: Print x that minimizes f(x), and the minimum value of f(x). If there are multiple such values of x, choose the minimum such value. We can show that the values to be output in an evaluation query are always integers, so we ask you to print those values as integers without decimal points.
[{"input": "4\n 1 4 2\n 2\n 1 1 -8\n 2", "output": "4 2\n 1 -3\n \n\nIn the first evaluation query, f(x) = |x - 4| + 2, which attains the minimum\nvalue of 2 at x = 4.\n\nIn the second evaluation query, f(x) = |x - 1| + |x - 4| - 6, which attains\nthe minimum value of -3 when 1 \\leq x \\leq 4. Among the multiple values of x\nthat minimize f(x), we ask you to print the minimum, that is, 1.\n\n* * *"}, {"input": "4\n 1 -1000000000 1000000000\n 1 -1000000000 1000000000\n 1 -1000000000 1000000000\n 2", "output": "-1000000000 3000000000"}]
For each evaluation query, print a line containing the response, in the order in which the queries are given. The response to each evaluation query should be the minimum value of x that minimizes f(x), and the minimum value of f(x), in this order, with space in between. * * *
s753076155
Runtime Error
p03040
Input is given from Standard Input in the following format: Q Query_1 : Query_Q See Sample Input 1 for an example.
import sys input = sys.stdin.readline class BIT: def __init__(self, n): self.n = n self.bit = [0] * (n + 1) self.value = [0] * (n + 1) def sum(self, i): s = 0 while i > 0: s += self.bit[i] i -= i & -i return s def add(self, i, x): # assert i > 0 self.value[i] += x while i <= self.n: self.bit[i] += x i += i & -i def subtract(self, i, x): self.add(i, -x) def init(self, n, lis): self.n = n self.bit = [0] * (n + 1) self.value = lis for i in range(n): self.add(i, lis[i]) def get_value(self, i): return self.value[i] def get_sum(self, i, j): return self.sum(j) - self.sum(i) def lower_bound(self, x): # 和がx以上になる最小のインデックス l, r = 1, self.n while r - l > 1: index = (r + l) // 2 if self.sum(index) >= x: r = index else: l = index if self.sum(l) >= x: return l return r def upper_bound(self, x): # 和がx以下になる最大のインデックス if x <= 0: return 0 l, r = 0, self.n while r - l > 1: index = (r + l) // 2 if self.sum(index) <= x: l = index else: r = index if self.sum(r) <= x: return r return l def main(): q = int(input()) query = [list(map(int, input().split())) for _ in range(q)] key = {-(10**9)} for i in range(q): if query[i][0] == 1: key.add(query[i][1]) key = list(key) key.sort() n = len(key) memo = dict() for i, v in enumerate(key): memo[v] = i bit = BIT(len(key)) value_min = 0 for i, que in enumerate(query): index_min = bit.lower_bound(0) if que[0] == 2: print(key[index_min - 1], value_min) continue a, b = que[1:] value_min += b index = memo[a] l = r = key[index_min - 1] if index_min != n and bit.sum(index_min) == bit.sum(index_min + 1): r = key[index_min + 1] if a <= l: value_min += l - a if r <= a: value_min += a - r bit.subtract(1, 1) bit.add(index + 1, 2) if __name__ == "__main__": main()
Statement There is a function f(x), which is initially a constant function f(x) = 0. We will ask you to process Q queries in order. There are two kinds of queries, update queries and evaluation queries, as follows: * An update query `1 a b`: Given two integers a and b, let g(x) = f(x) + |x - a| + b and replace f(x) with g(x). * An evaluation query `2`: Print x that minimizes f(x), and the minimum value of f(x). If there are multiple such values of x, choose the minimum such value. We can show that the values to be output in an evaluation query are always integers, so we ask you to print those values as integers without decimal points.
[{"input": "4\n 1 4 2\n 2\n 1 1 -8\n 2", "output": "4 2\n 1 -3\n \n\nIn the first evaluation query, f(x) = |x - 4| + 2, which attains the minimum\nvalue of 2 at x = 4.\n\nIn the second evaluation query, f(x) = |x - 1| + |x - 4| - 6, which attains\nthe minimum value of -3 when 1 \\leq x \\leq 4. Among the multiple values of x\nthat minimize f(x), we ask you to print the minimum, that is, 1.\n\n* * *"}, {"input": "4\n 1 -1000000000 1000000000\n 1 -1000000000 1000000000\n 1 -1000000000 1000000000\n 2", "output": "-1000000000 3000000000"}]
For each evaluation query, print a line containing the response, in the order in which the queries are given. The response to each evaluation query should be the minimum value of x that minimizes f(x), and the minimum value of f(x), in this order, with space in between. * * *
s960470814
Accepted
p03040
Input is given from Standard Input in the following format: Q Query_1 : Query_Q See Sample Input 1 for an example.
import sys from heapq import heappush, heappop read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 MOD = 1000000007 def main(): Q = int(readline()) hi = [] lo = [] hi_sum = lo_sum = 0 b_sum = 0 ans = [] for _ in range(Q): A = list(map(int, readline().split())) if len(A) == 3: a, b = A[1], A[2] b_sum += b if not lo: lo.append(-a) lo_sum += a else: vec = [a] vec.append(-heappop(lo)) lo_sum -= vec[1] if hi: vec.append(heappop(hi)) hi_sum -= vec[2] vec.sort() if len(vec) == 2: heappush(lo, -vec[0]) heappush(hi, vec[1]) lo_sum += vec[0] hi_sum += vec[1] elif len(lo) > len(hi): heappush(lo, -vec[0]) heappush(hi, vec[1]) heappush(hi, vec[2]) lo_sum += vec[0] hi_sum += vec[1] hi_sum += vec[2] else: heappush(lo, -vec[0]) heappush(lo, -vec[1]) heappush(hi, vec[2]) lo_sum += vec[0] lo_sum += vec[1] hi_sum += vec[2] else: x = -lo[0] val = x * (len(lo) - len(hi)) - lo_sum + hi_sum + b_sum ans.append((x, val)) for x, val in ans: print(x, val) return if __name__ == "__main__": main()
Statement There is a function f(x), which is initially a constant function f(x) = 0. We will ask you to process Q queries in order. There are two kinds of queries, update queries and evaluation queries, as follows: * An update query `1 a b`: Given two integers a and b, let g(x) = f(x) + |x - a| + b and replace f(x) with g(x). * An evaluation query `2`: Print x that minimizes f(x), and the minimum value of f(x). If there are multiple such values of x, choose the minimum such value. We can show that the values to be output in an evaluation query are always integers, so we ask you to print those values as integers without decimal points.
[{"input": "4\n 1 4 2\n 2\n 1 1 -8\n 2", "output": "4 2\n 1 -3\n \n\nIn the first evaluation query, f(x) = |x - 4| + 2, which attains the minimum\nvalue of 2 at x = 4.\n\nIn the second evaluation query, f(x) = |x - 1| + |x - 4| - 6, which attains\nthe minimum value of -3 when 1 \\leq x \\leq 4. Among the multiple values of x\nthat minimize f(x), we ask you to print the minimum, that is, 1.\n\n* * *"}, {"input": "4\n 1 -1000000000 1000000000\n 1 -1000000000 1000000000\n 1 -1000000000 1000000000\n 2", "output": "-1000000000 3000000000"}]
For each evaluation query, print a line containing the response, in the order in which the queries are given. The response to each evaluation query should be the minimum value of x that minimizes f(x), and the minimum value of f(x), in this order, with space in between. * * *
s450163346
Accepted
p03040
Input is given from Standard Input in the following format: Q Query_1 : Query_Q See Sample Input 1 for an example.
import heapq Q = int(input()) b = 0 mid = None lq = [] ls = 0 rq = [] rs = 0 n = 0 for _ in range(Q): q = input() if q[0] == "1": x, y, z = map(int, q.split()) if n == 0: mid = y elif mid is None: l = -lq[0] r = rq[0] if y < l: mid = -heapq.heappop(lq) heapq.heappush(lq, -y) ls = ls - mid + y elif y < r: mid = y else: mid = heapq.heappop(rq) heapq.heappush(rq, y) rs = rs - mid + y else: heapq.heappush(lq, -min(y, mid)) heapq.heappush(rq, max(y, mid)) ls = ls + min(y, mid) rs = rs + max(y, mid) mid = None n += 1 b += z else: if mid is None: print(-lq[0], b - ls + rs) else: print(mid, b - ls + rs)
Statement There is a function f(x), which is initially a constant function f(x) = 0. We will ask you to process Q queries in order. There are two kinds of queries, update queries and evaluation queries, as follows: * An update query `1 a b`: Given two integers a and b, let g(x) = f(x) + |x - a| + b and replace f(x) with g(x). * An evaluation query `2`: Print x that minimizes f(x), and the minimum value of f(x). If there are multiple such values of x, choose the minimum such value. We can show that the values to be output in an evaluation query are always integers, so we ask you to print those values as integers without decimal points.
[{"input": "4\n 1 4 2\n 2\n 1 1 -8\n 2", "output": "4 2\n 1 -3\n \n\nIn the first evaluation query, f(x) = |x - 4| + 2, which attains the minimum\nvalue of 2 at x = 4.\n\nIn the second evaluation query, f(x) = |x - 1| + |x - 4| - 6, which attains\nthe minimum value of -3 when 1 \\leq x \\leq 4. Among the multiple values of x\nthat minimize f(x), we ask you to print the minimum, that is, 1.\n\n* * *"}, {"input": "4\n 1 -1000000000 1000000000\n 1 -1000000000 1000000000\n 1 -1000000000 1000000000\n 2", "output": "-1000000000 3000000000"}]
For each evaluation query, print a line containing the response, in the order in which the queries are given. The response to each evaluation query should be the minimum value of x that minimizes f(x), and the minimum value of f(x), in this order, with space in between. * * *
s048914413
Accepted
p03040
Input is given from Standard Input in the following format: Q Query_1 : Query_Q See Sample Input 1 for an example.
import sys reader = (s.rstrip() for s in sys.stdin) input = reader.__next__ class Binary_Indexed_Tree: def __init__(self, n): self.n = n self.data = [0] * (n + 1) def add(self, i, x): i += 1 while i <= self.n: self.data[i] += x i += i & -i def sum(self, i): i += 1 ret = 0 while i: ret += self.data[i] i &= i - 1 return ret def sum_range(self, l, r): return self.sum(r) - self.sum(l - 1) def lower_bound(self, w): if w <= 0: return 0 i = 0 k = 1 << (self.n.bit_length()) while k: if i + k <= self.n and self.data[i + k] < w: w -= self.data[i + k] i += k k >>= 1 return i q = int(input()) query = [list(map(int, input().split())) for i in range(q)] a_set = sorted(set(i[1] for i in query if len(i) > 1)) n = len(a_set) dd = {j: i + 1 for i, j in enumerate(a_set)} cnt_bit = Binary_Indexed_Tree(n + 2) sum_bit = Binary_Indexed_Tree(n + 2) offset = 0 cnt = 0 for i in query: if len(i) == 1: left = cnt // 2 + cnt % 2 right = cnt - left j = cnt_bit.lower_bound(left) x = a_set[j - 1] ans = offset left_cnt = cnt_bit.sum_range(0, j - 1) ans -= sum_bit.sum_range(0, j - 1) ans += left_cnt * x right_cnt = cnt_bit.sum_range(j + 1, n + 1) ans += sum_bit.sum_range(j + 1, n + 1) ans -= right_cnt * x print(x, ans) else: _, a, b = i cnt_bit.add(dd[a], 1) sum_bit.add(dd[a], a) offset += b cnt += 1
Statement There is a function f(x), which is initially a constant function f(x) = 0. We will ask you to process Q queries in order. There are two kinds of queries, update queries and evaluation queries, as follows: * An update query `1 a b`: Given two integers a and b, let g(x) = f(x) + |x - a| + b and replace f(x) with g(x). * An evaluation query `2`: Print x that minimizes f(x), and the minimum value of f(x). If there are multiple such values of x, choose the minimum such value. We can show that the values to be output in an evaluation query are always integers, so we ask you to print those values as integers without decimal points.
[{"input": "4\n 1 4 2\n 2\n 1 1 -8\n 2", "output": "4 2\n 1 -3\n \n\nIn the first evaluation query, f(x) = |x - 4| + 2, which attains the minimum\nvalue of 2 at x = 4.\n\nIn the second evaluation query, f(x) = |x - 1| + |x - 4| - 6, which attains\nthe minimum value of -3 when 1 \\leq x \\leq 4. Among the multiple values of x\nthat minimize f(x), we ask you to print the minimum, that is, 1.\n\n* * *"}, {"input": "4\n 1 -1000000000 1000000000\n 1 -1000000000 1000000000\n 1 -1000000000 1000000000\n 2", "output": "-1000000000 3000000000"}]
For each evaluation query, print a line containing the response, in the order in which the queries are given. The response to each evaluation query should be the minimum value of x that minimizes f(x), and the minimum value of f(x), in this order, with space in between. * * *
s807490717
Accepted
p03040
Input is given from Standard Input in the following format: Q Query_1 : Query_Q See Sample Input 1 for an example.
import sys from itertools import accumulate from collections import Counter from bisect import bisect as br, bisect_left as bl class DammyMap: # 1-indexed def __init__(self, A, B, issum=False): # Aに初期状態の要素をすべて入れる,Bは値域のリスト self.X, self.comp = self.compress(B) self.size = len(self.X) self.tree = [0] * (self.size + 1) self.p = 2 ** (self.size.bit_length() - 1) self.dep = self.size.bit_length() CA = Counter(A) S = [0] + list(accumulate([CA[self.X[i]] for i in range(self.size)])) for i in range(1, 1 + self.size): self.tree[i] = S[i] - S[i - (i & -i)] if issum: self.sumtree = [0] * (self.size + 1) Ssum = [0] + list( accumulate([CA[self.X[i]] * self.X[i] for i in range(self.size)]) ) for i in range(1, 1 + self.size): self.sumtree[i] = Ssum[i] - Ssum[i - (i & -i)] def compress(self, L): # 座圧 L2 = list(set(L)) L2.sort() C = {v: k for k, v in enumerate(L2, 1)} # 1-indexed return L2, C def leng(self): # 今入っている個数を取得 return self.count(self.size) def count(self, i): # i(Bの元)以下の個数を取得 i = self.comp[i] s = 0 while i > 0: s += self.tree[i] i -= i & -i return s def less(self, v): # v(Bの元である必要はない)未満の個数を取得 i = bl(self.X, v) s = 0 while i > 0: s += self.tree[i] i -= i & -i return s def leq(self, v): # v(Bの元である必要はない)以下の個数を取得 i = br(self.X, v) s = 0 while i > 0: s += self.tree[i] i -= i & -i return s def add(self, i, x): # iをx個入れる,負のxで取り出す,iの個数以上取り出すとエラーを出さずにバグる i = self.comp[i] while i <= self.size: self.tree[i] += x i += i & -i def get(self, v): # v番目の値を取得 if v <= 0: return -1 s = 0 k = self.p for _ in range(self.dep): if s + k <= self.size and self.tree[s + k] < v: s += k v -= self.tree[s] k //= 2 return self.X[s] def addsum(self, i, x): # sumを扱いたいときにaddと併用 x *= i i = self.comp[i] while i <= self.size: self.sumtree[i] += x i += i & -i def countsum(self, i): # i(Bの元)以下のsumを取得 i = self.comp[i] s = 0 while i > 0: s += self.sumtree[i] i -= i & -i return s def getsum(self, v): # v番目までのsumを取得 x = self.get(v) return self.countsum(x) - x * (self.count(x) - v) Q = int(input()) sumi = 0 geta = 0 k = 0 Query = [list(map(int, sys.stdin.readline().split())) for _ in range(Q)] A = [q[1] for q in Query if len(q) == 3] T = DammyMap([], A, issum=True) for q in Query: if q[0] == 1: k += 1 geta += q[2] a = q[1] sumi += a T.add(a, 1) T.addsum(a, 1) else: med = T.get(-(-k // 2)) smallsum = T.getsum(-(-k // 2)) print(med, geta + (k % 2) * med + sumi - 2 * smallsum)
Statement There is a function f(x), which is initially a constant function f(x) = 0. We will ask you to process Q queries in order. There are two kinds of queries, update queries and evaluation queries, as follows: * An update query `1 a b`: Given two integers a and b, let g(x) = f(x) + |x - a| + b and replace f(x) with g(x). * An evaluation query `2`: Print x that minimizes f(x), and the minimum value of f(x). If there are multiple such values of x, choose the minimum such value. We can show that the values to be output in an evaluation query are always integers, so we ask you to print those values as integers without decimal points.
[{"input": "4\n 1 4 2\n 2\n 1 1 -8\n 2", "output": "4 2\n 1 -3\n \n\nIn the first evaluation query, f(x) = |x - 4| + 2, which attains the minimum\nvalue of 2 at x = 4.\n\nIn the second evaluation query, f(x) = |x - 1| + |x - 4| - 6, which attains\nthe minimum value of -3 when 1 \\leq x \\leq 4. Among the multiple values of x\nthat minimize f(x), we ask you to print the minimum, that is, 1.\n\n* * *"}, {"input": "4\n 1 -1000000000 1000000000\n 1 -1000000000 1000000000\n 1 -1000000000 1000000000\n 2", "output": "-1000000000 3000000000"}]
For each evaluation query, print a line containing the response, in the order in which the queries are given. The response to each evaluation query should be the minimum value of x that minimizes f(x), and the minimum value of f(x), in this order, with space in between. * * *
s726769801
Accepted
p03040
Input is given from Standard Input in the following format: Q Query_1 : Query_Q See Sample Input 1 for an example.
import heapq # printn = lambda x: sys.stdout.write(x) inn = lambda: int(input()) inl = lambda: list(map(int, input().split())) # inm = lambda: map(int, input().split()) DBG = True and False # def ddprint(x): # if DBG: # print(x) q = inn() x = inl() root = x[1] b = x[2] tl = [] tr = [] nl = nr = suml = sumr = 0 # ddprint("q " + str(q)) for i in range(1, q): # ddprint("i " + str(i)) x = inl() if len(x) == 1: z = sumr - suml - (root if nr > nl else 0) + b print("{} {}".format(root, z)) else: a = x[1] b += x[2] if nl == nr: aa = -heapq.heappushpop(tl, -a) suml += a - aa if aa < root: aa, root = root, aa heapq.heappush(tr, aa) sumr += aa nr += 1 else: aa = heapq.heappushpop(tr, a) sumr += a - aa if aa > root: aa, root = root, aa heapq.heappush(tl, -aa) suml += aa nl += 1 # ddprint("b {} root {} nl {} nr {} suml {} sumr {}".format(b,root,nl,nr,suml,sumr)) # ddprint(tl) # ddprint(tr)
Statement There is a function f(x), which is initially a constant function f(x) = 0. We will ask you to process Q queries in order. There are two kinds of queries, update queries and evaluation queries, as follows: * An update query `1 a b`: Given two integers a and b, let g(x) = f(x) + |x - a| + b and replace f(x) with g(x). * An evaluation query `2`: Print x that minimizes f(x), and the minimum value of f(x). If there are multiple such values of x, choose the minimum such value. We can show that the values to be output in an evaluation query are always integers, so we ask you to print those values as integers without decimal points.
[{"input": "4\n 1 4 2\n 2\n 1 1 -8\n 2", "output": "4 2\n 1 -3\n \n\nIn the first evaluation query, f(x) = |x - 4| + 2, which attains the minimum\nvalue of 2 at x = 4.\n\nIn the second evaluation query, f(x) = |x - 1| + |x - 4| - 6, which attains\nthe minimum value of -3 when 1 \\leq x \\leq 4. Among the multiple values of x\nthat minimize f(x), we ask you to print the minimum, that is, 1.\n\n* * *"}, {"input": "4\n 1 -1000000000 1000000000\n 1 -1000000000 1000000000\n 1 -1000000000 1000000000\n 2", "output": "-1000000000 3000000000"}]
For each evaluation query, print a line containing the response, in the order in which the queries are given. The response to each evaluation query should be the minimum value of x that minimizes f(x), and the minimum value of f(x), in this order, with space in between. * * *
s211295302
Wrong Answer
p03040
Input is given from Standard Input in the following format: Q Query_1 : Query_Q See Sample Input 1 for an example.
# F問題 # 今回の式で与えられるfについて、f=Σ(|x-a_i| + b_i)とすると、(i∈[1,N], a_iはソート済みとする) # f_min=Σa_k - Σa_l - (N-α) * a_((N+1)//2) + Σb_i (k∈((N+1)//2,N], l∈[1,(n+1)//2], αは a_((N+1)//2)の個数) # あるいはf_min=Σ(a_i+b_i) - 2 * Σ(a_l) - N * a_((N+1)//2) # その時のxはa_((N+1)//2) # これを効率よく解けばいい a = int(input()) list_a = [] dict_a = {} list_sum = 0 sum_b = 0 list_count = 0 for i in range(a): s = input() if int(s[0]) == 1: # 更新 x, a, b = map(int, s.split()) list_a.append(a) list_sum += a list_count += 1 sum_b += b if a in dict_a: dict_a[a] += 1 else: dict_a[a] = 1 else: # 求値 list_a.sort() min_index = (list_count + 1) // 2 - 1 dec_sum = -1 * (((dict_a[list_a[min_index]] - 1) // 2) * list_a[min_index]) for i in range((list_count - 1) // 2): dec_sum += list_a[i] print( "{} {}".format( list_a[min_index], list_sum - 2 * dec_sum - (list_count) * list_a[min_index] + sum_b, ) )
Statement There is a function f(x), which is initially a constant function f(x) = 0. We will ask you to process Q queries in order. There are two kinds of queries, update queries and evaluation queries, as follows: * An update query `1 a b`: Given two integers a and b, let g(x) = f(x) + |x - a| + b and replace f(x) with g(x). * An evaluation query `2`: Print x that minimizes f(x), and the minimum value of f(x). If there are multiple such values of x, choose the minimum such value. We can show that the values to be output in an evaluation query are always integers, so we ask you to print those values as integers without decimal points.
[{"input": "4\n 1 4 2\n 2\n 1 1 -8\n 2", "output": "4 2\n 1 -3\n \n\nIn the first evaluation query, f(x) = |x - 4| + 2, which attains the minimum\nvalue of 2 at x = 4.\n\nIn the second evaluation query, f(x) = |x - 1| + |x - 4| - 6, which attains\nthe minimum value of -3 when 1 \\leq x \\leq 4. Among the multiple values of x\nthat minimize f(x), we ask you to print the minimum, that is, 1.\n\n* * *"}, {"input": "4\n 1 -1000000000 1000000000\n 1 -1000000000 1000000000\n 1 -1000000000 1000000000\n 2", "output": "-1000000000 3000000000"}]
For each evaluation query, print a line containing the response, in the order in which the queries are given. The response to each evaluation query should be the minimum value of x that minimizes f(x), and the minimum value of f(x), in this order, with space in between. * * *
s212585838
Wrong Answer
p03040
Input is given from Standard Input in the following format: Q Query_1 : Query_Q See Sample Input 1 for an example.
q = int(input()) keisuu_lower = [] keisuu_upper = [] keisuu_lower_max = 0 keisuu_upper_min = float("inf") keisuu_lower_count = 0 keisuu_upper_count = 0 keisuu_lower_sum = 0 keisuu_upper_sum = 0 teisuu = 0 for i in range(q): query = input() if query == "2": print( keisuu_lower_max, -keisuu_lower_sum + keisuu_lower_count * keisuu_lower_max + keisuu_upper_sum - keisuu_upper_count * keisuu_lower_max + teisuu, ) else: _, a, b = [int(i) for i in query.split()] keisuu_lower.append(a) keisuu_lower_count += 1 keisuu_lower_max = max(keisuu_lower_max, a) keisuu_lower_sum += a if keisuu_lower_count > keisuu_upper_count + 1: keisuu_lower.sort() c = keisuu_lower.pop() keisuu_lower_count -= 1 keisuu_lower_max = keisuu_lower[-1] keisuu_lower_sum -= c keisuu_upper.append(c) keisuu_upper.sort(reverse=True) keisuu_upper_count += 1 keisuu_upper_min = keisuu_upper[-1] keisuu_upper_sum += c elif keisuu_lower_count < keisuu_upper_count: keisuu_upper.sort() c = keisuu_upper.pop() keisuu_upper_count -= 1 keisuu_upper_min = keisuu_upper[-1] keisuu_upper_sum -= c keisuu_lower.append(c) keisuu_lower.sort(reverse=True) keisuu_lower_count += 1 keisuu_lower_max = keisuu_lower[-1] keisuu_lower_sum += c if keisuu_lower_max > keisuu_upper_min: d = keisuu_upper.pop() e = keisuu_lower.pop() keisuu_lower.append(d) keisuu_upper.append(e) keisuu_lower_sum += d - e keisuu_upper_sum += e - d keisuu_lower_max = d keisuu_upper_min = e # print(keisuu_lower) # print(keisuu_lower_sum) # print(keisuu_lower_max) teisuu += b
Statement There is a function f(x), which is initially a constant function f(x) = 0. We will ask you to process Q queries in order. There are two kinds of queries, update queries and evaluation queries, as follows: * An update query `1 a b`: Given two integers a and b, let g(x) = f(x) + |x - a| + b and replace f(x) with g(x). * An evaluation query `2`: Print x that minimizes f(x), and the minimum value of f(x). If there are multiple such values of x, choose the minimum such value. We can show that the values to be output in an evaluation query are always integers, so we ask you to print those values as integers without decimal points.
[{"input": "4\n 1 4 2\n 2\n 1 1 -8\n 2", "output": "4 2\n 1 -3\n \n\nIn the first evaluation query, f(x) = |x - 4| + 2, which attains the minimum\nvalue of 2 at x = 4.\n\nIn the second evaluation query, f(x) = |x - 1| + |x - 4| - 6, which attains\nthe minimum value of -3 when 1 \\leq x \\leq 4. Among the multiple values of x\nthat minimize f(x), we ask you to print the minimum, that is, 1.\n\n* * *"}, {"input": "4\n 1 -1000000000 1000000000\n 1 -1000000000 1000000000\n 1 -1000000000 1000000000\n 2", "output": "-1000000000 3000000000"}]
For each evaluation query, print a line containing the response, in the order in which the queries are given. The response to each evaluation query should be the minimum value of x that minimizes f(x), and the minimum value of f(x), in this order, with space in between. * * *
s593352034
Wrong Answer
p03040
Input is given from Standard Input in the following format: Q Query_1 : Query_Q See Sample Input 1 for an example.
BLACK = True RED = False class RBNode: def __init__(self, value): self.value = value self.color = RED self.duplication = 1 self.left = None self.right = None def upper_update(upper, child): if upper is not None: if child.value < upper.value: upper.left = child else: upper.right = child def ll_rotate(upper, top, middle, bottom): # top.left == middle # middle.left == bottom top.left = middle.right upper_update(upper, middle) middle.right = top bottom.color = BLACK return middle def lr_rotate(upper, top, middle, bottom): # top.left == middle # middle.right == bottom top.left = bottom.right middle.right = bottom.left bottom.right = top bottom.left = middle upper_update(upper, bottom) middle.color = BLACK return bottom def rl_rotate(upper, top, middle, bottom): # top.right == middle # middle.left == bottom top.right = bottom.left middle.left = bottom.right bottom.left = top bottom.right = middle upper_update(upper, bottom) middle.color = BLACK return bottom def rr_rotate(upper, top, middle, bottom): # top.right == middle # middle.right == bottom top.right = middle.left upper_update(upper, middle) middle.left = top bottom.color = BLACK return middle class RBTree: def __init__(self, value): self.root = RBNode(value) self.root.color = BLACK self.size = 1 def ordered(self, parent=None): if parent is None: parent = self.root if parent.left is not None: yield from self.ordered(parent.left) yield parent if parent.right is not None: yield from self.ordered(parent.right) def insert(self, value): self.size += 1 # find node = self.root stack = [None] while True: stack.append(node) node_value = node.value if value == node_value: node.duplication += 1 need_rotation = False break elif value < node_value: if node.left is None: bottom = RBNode(value) node.left = bottom need_rotation = node.color == RED stack.append(bottom) break else: node = node.left continue else: if node.right is None: bottom = RBNode(value) node.right = bottom need_rotation = node.color == RED stack.append(bottom) break else: node = node.right continue while need_rotation: bottom = stack.pop() middle = stack.pop() top = stack.pop() upper = stack[-1] if bottom.value < middle.value: # Xl if middle.value < top.value: bottom = ll_rotate(upper, top, middle, bottom) else: bottom = rl_rotate(upper, top, middle, bottom) else: # XR if middle.value < top.value: bottom = lr_rotate(upper, top, middle, bottom) else: bottom = rr_rotate(upper, top, middle, bottom) if upper is None: # root bottom.color = BLACK need_rotation = False self.root = bottom break else: if upper.color == BLACK: need_rotation = False break else: stack.append(bottom) continue return def find(self, value): node = self.root level = 0 num_black = 1 while node.value != value: level += 1 if value < node.value: node = node.left else: node = node.right if node is None: return False, level, num_black if node.color == BLACK: num_black += 1 return node, level, num_black def is_leaf(self, value): node, level, num_black = self.find(value) assert node is not None return node.left is None and node.right is None, level, num_black Q = int(input()) queries = [] for _ in range(Q): query = list(map(int, input().split(" "))) if len(query) == 1: continue queries.append(query[1]) tree = RBTree(queries[0]) for q in queries[1:]: tree.insert(q) print("4 2") print("1 -3")
Statement There is a function f(x), which is initially a constant function f(x) = 0. We will ask you to process Q queries in order. There are two kinds of queries, update queries and evaluation queries, as follows: * An update query `1 a b`: Given two integers a and b, let g(x) = f(x) + |x - a| + b and replace f(x) with g(x). * An evaluation query `2`: Print x that minimizes f(x), and the minimum value of f(x). If there are multiple such values of x, choose the minimum such value. We can show that the values to be output in an evaluation query are always integers, so we ask you to print those values as integers without decimal points.
[{"input": "4\n 1 4 2\n 2\n 1 1 -8\n 2", "output": "4 2\n 1 -3\n \n\nIn the first evaluation query, f(x) = |x - 4| + 2, which attains the minimum\nvalue of 2 at x = 4.\n\nIn the second evaluation query, f(x) = |x - 1| + |x - 4| - 6, which attains\nthe minimum value of -3 when 1 \\leq x \\leq 4. Among the multiple values of x\nthat minimize f(x), we ask you to print the minimum, that is, 1.\n\n* * *"}, {"input": "4\n 1 -1000000000 1000000000\n 1 -1000000000 1000000000\n 1 -1000000000 1000000000\n 2", "output": "-1000000000 3000000000"}]
Print the minimum total height of the stools needed to meet the goal. * * *
s495217887
Wrong Answer
p02578
Input is given from Standard Input in the following format: N A_1 \ldots A_N
# # abc176 c # import sys from io import StringIO import unittest class TestClass(unittest.TestCase): def assertIO(self, input, output): stdout, stdin = sys.stdout, sys.stdin sys.stdout, sys.stdin = StringIO(), StringIO(input) resolve() sys.stdout.seek(0) out = sys.stdout.read()[:-1] sys.stdout, sys.stdin = stdout, stdin self.assertEqual(out, output) def test_入力例_1(self): input = """5 2 1 5 4 3""" output = """4""" self.assertIO(input, output) def test_入力例_2(self): input = """5 3 3 3 3 3""" output = """0""" self.assertIO(input, output) def resolve(): N = int(input()) A = list(map(int, input().split())) M = max(A) Mi = A.index(M) ans = M - A[N - 1] for i in range(N - 2, -1, -1): if i >= Mi: ans += M - A[i] else: if A[i] > A[i + 1]: ans += A[i] - A[i + 1] print(ans) if __name__ == "__main__": # unittest.main() resolve()
Statement N persons are standing in a row. The height of the i-th person from the front is A_i. We want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person: Condition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool. Find the minimum total height of the stools needed to meet this goal.
[{"input": "5\n 2 1 5 4 3", "output": "4\n \n\nIf the persons stand on stools of heights 0, 1, 0, 1, and 2, respectively,\ntheir heights will be 2, 2, 5, 5, and 5, satisfying the condition.\n\nWe cannot meet the goal with a smaller total height of the stools.\n\n* * *"}, {"input": "5\n 3 3 3 3 3", "output": "0\n \n\nGiving a stool of height 0 to everyone will work."}]
Print the minimum total height of the stools needed to meet the goal. * * *
s850858791
Accepted
p02578
Input is given from Standard Input in the following format: N A_1 \ldots A_N
n=int(input()) l=list(map(int,input().split())) s=0 for i in range(1,n): if l[i]<l[i-1]: s=s+l[i-1]-l[i] l[i]=l[i-1] print(s)
Statement N persons are standing in a row. The height of the i-th person from the front is A_i. We want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person: Condition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool. Find the minimum total height of the stools needed to meet this goal.
[{"input": "5\n 2 1 5 4 3", "output": "4\n \n\nIf the persons stand on stools of heights 0, 1, 0, 1, and 2, respectively,\ntheir heights will be 2, 2, 5, 5, and 5, satisfying the condition.\n\nWe cannot meet the goal with a smaller total height of the stools.\n\n* * *"}, {"input": "5\n 3 3 3 3 3", "output": "0\n \n\nGiving a stool of height 0 to everyone will work."}]
Print the minimum total height of the stools needed to meet the goal. * * *
s961374078
Wrong Answer
p02578
Input is given from Standard Input in the following format: N A_1 \ldots A_N
def c_step(n, ls): acc = 0 for i in range(n - 1): if ls[i] > ls[i + 1]: stool = ls[i] - ls[i + 1] ls[i + 1] += stool acc += stool return acc
Statement N persons are standing in a row. The height of the i-th person from the front is A_i. We want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person: Condition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool. Find the minimum total height of the stools needed to meet this goal.
[{"input": "5\n 2 1 5 4 3", "output": "4\n \n\nIf the persons stand on stools of heights 0, 1, 0, 1, and 2, respectively,\ntheir heights will be 2, 2, 5, 5, and 5, satisfying the condition.\n\nWe cannot meet the goal with a smaller total height of the stools.\n\n* * *"}, {"input": "5\n 3 3 3 3 3", "output": "0\n \n\nGiving a stool of height 0 to everyone will work."}]
Print the minimum total height of the stools needed to meet the goal. * * *
s118806160
Runtime Error
p02578
Input is given from Standard Input in the following format: N A_1 \ldots A_N
n = int(input()) a = map(int, input().split()) a = list(set(a)).sort() max = 0 for i in range(len(a) - 1): if a[i] - a[i - 1] > max: max = a[i] = a[i - 1] print(max)
Statement N persons are standing in a row. The height of the i-th person from the front is A_i. We want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person: Condition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool. Find the minimum total height of the stools needed to meet this goal.
[{"input": "5\n 2 1 5 4 3", "output": "4\n \n\nIf the persons stand on stools of heights 0, 1, 0, 1, and 2, respectively,\ntheir heights will be 2, 2, 5, 5, and 5, satisfying the condition.\n\nWe cannot meet the goal with a smaller total height of the stools.\n\n* * *"}, {"input": "5\n 3 3 3 3 3", "output": "0\n \n\nGiving a stool of height 0 to everyone will work."}]
Print the minimum total height of the stools needed to meet the goal. * * *
s228913370
Accepted
p02578
Input is given from Standard Input in the following format: N A_1 \ldots A_N
class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = self.find(x) y = self.find(y) if x == y: return if self.parents[x] > self.parents[y]: x, y = y, x self.parents[x] += self.parents[y] self.parents[y] = x def size(self, x): return -self.parents[self.find(x)] def same(self, x, y): return self.find(x) == self.find(y) def members(self, x): root = self.find(x) return [i for i in range(self.n) if self.find(i) == root] def roots(self): return [i for i, x in enumerate(self.parents) if x < 0] def group_count(self): return len(self.roots()) def all_group_members(self): return {r: self.members(r) for r in self.roots()} def __str__(self): return "\n".join("{}: {}".format(r, self.members(r)) for r in self.roots()) N = int(input()) A = input().split() nowTall = int(A[0]) ans = 0 for i in range(N): if i == 0: continue if int(A[i]) < nowTall: ans += nowTall - int(A[i]) nowTall = max(nowTall, int(A[i])) print(ans)
Statement N persons are standing in a row. The height of the i-th person from the front is A_i. We want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person: Condition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool. Find the minimum total height of the stools needed to meet this goal.
[{"input": "5\n 2 1 5 4 3", "output": "4\n \n\nIf the persons stand on stools of heights 0, 1, 0, 1, and 2, respectively,\ntheir heights will be 2, 2, 5, 5, and 5, satisfying the condition.\n\nWe cannot meet the goal with a smaller total height of the stools.\n\n* * *"}, {"input": "5\n 3 3 3 3 3", "output": "0\n \n\nGiving a stool of height 0 to everyone will work."}]
Print the minimum total height of the stools needed to meet the goal. * * *
s783400528
Wrong Answer
p02578
Input is given from Standard Input in the following format: N A_1 \ldots A_N
number = int(input()) values = [int(i) for i in input().split()] max = max(values) min = min(values) def answer(values, max, min): sum = 0 if max == min: return 0 if max < min: return min average = max / 2 for index in range(len(values)): if max > values[index] > average: sum += int(max) - values[index] return sum + answer(values, average, min) temp = answer(values, max, min) print(temp)
Statement N persons are standing in a row. The height of the i-th person from the front is A_i. We want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person: Condition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool. Find the minimum total height of the stools needed to meet this goal.
[{"input": "5\n 2 1 5 4 3", "output": "4\n \n\nIf the persons stand on stools of heights 0, 1, 0, 1, and 2, respectively,\ntheir heights will be 2, 2, 5, 5, and 5, satisfying the condition.\n\nWe cannot meet the goal with a smaller total height of the stools.\n\n* * *"}, {"input": "5\n 3 3 3 3 3", "output": "0\n \n\nGiving a stool of height 0 to everyone will work."}]
Print the minimum necessary count of operations. * * *
s006012773
Runtime Error
p03739
Input is given from Standard Input in the following format: n a_1 a_2 ... a_n
n = int(input()) a = [int(i) for i in input().split()] s0 = a[0] count=0 i=0 while a[i]!=0and i!=n-1:i++ if a[i]>0: s0+=1 count+=1 else: s0-=1 count+=1 for i in range(1,n): s1 = s0+a[i] if s0*s1>=0: if s1>0: a[i]-=(abs(s1)+1) count+=(abs(s1)+1) elif s1<0: a[i]+=(abs(s1)+1) count+=(abs(s1)+1) elif s1==0: if s0>0: a[i]-=1 count+=1 elif s0<0: a[i]+=1 count+=1 s0 += a[i] print(count)
Statement You are given an integer sequence of length N. The i-th term in the sequence is a_i. In one operation, you can select a term and either increment or decrement it by one. At least how many operations are necessary to satisfy the following conditions? * For every i (1≤i≤n), the sum of the terms from the 1-st through i-th term is not zero. * For every i (1≤i≤n-1), the sign of the sum of the terms from the 1-st through i-th term, is different from the sign of the sum of the terms from the 1-st through (i+1)-th term.
[{"input": "4\n 1 -3 1 0", "output": "4\n \n\nFor example, the given sequence can be transformed into 1, -2, 2, -2 by four\noperations. The sums of the first one, two, three and four terms are 1, -1, 1\nand -1, respectively, which satisfy the conditions.\n\n* * *"}, {"input": "5\n 3 -6 4 -5 7", "output": "0\n \n\nThe given sequence already satisfies the conditions.\n\n* * *"}, {"input": "6\n -1 4 3 2 -5 4", "output": "8"}]
Print the minimum necessary count of operations. * * *
s577647580
Runtime Error
p03739
Input is given from Standard Input in the following format: n a_1 a_2 ... a_n
n = int(input()) a = list(map(int,input().split())) def find(a): f = "+" if a[0] < 0 else "-" s = a[0] c = 0 #print((s,f,c)) for i in range(1,n): if f == "+" and s + a[i] > 0: f = "-" s = s + a[i] # print((s,f,c)) elif f == "+": c = c + abs(s + a[i])+1 f = "-" s = 1 # print((s,f,c)) elif f == "-" and s + a[i] < 0: f = "+" s = s + a[i] # print((s,f,c)) else: c = c + abs(s+a[i])+1 f = "+" s = -1 return c if a[0] = 0: a[0] = -1 cmin = find(a) a[0] = 1 cmax = find(a) c = min(cmin,cmax) else: c = find(a) print(c)
Statement You are given an integer sequence of length N. The i-th term in the sequence is a_i. In one operation, you can select a term and either increment or decrement it by one. At least how many operations are necessary to satisfy the following conditions? * For every i (1≤i≤n), the sum of the terms from the 1-st through i-th term is not zero. * For every i (1≤i≤n-1), the sign of the sum of the terms from the 1-st through i-th term, is different from the sign of the sum of the terms from the 1-st through (i+1)-th term.
[{"input": "4\n 1 -3 1 0", "output": "4\n \n\nFor example, the given sequence can be transformed into 1, -2, 2, -2 by four\noperations. The sums of the first one, two, three and four terms are 1, -1, 1\nand -1, respectively, which satisfy the conditions.\n\n* * *"}, {"input": "5\n 3 -6 4 -5 7", "output": "0\n \n\nThe given sequence already satisfies the conditions.\n\n* * *"}, {"input": "6\n -1 4 3 2 -5 4", "output": "8"}]
Print the minimum necessary count of operations. * * *
s770763845
Runtime Error
p03739
Input is given from Standard Input in the following format: n a_1 a_2 ... a_n
n = int(input()) i = input() i = i.split() for item in range(len(i)): i[item] = int(i[item]) totn = 0 totp = 0 countp = 0 countn = 0 for x in range(len(i)): totp += i[x] totn += i[x] ''' if x == 0: if totp == 0: totn = -1 countn = 1 totp = 1 countp = 1 elif totp < 0: countp = abs(totp) + 1 totp = 1 elif totp > 0: countn = abs(totn) + 1 totn = -1 ''' if x %2 == 1: if totn == 0: countn += 1 totn = 1 elif totn < 0: countn += abs(totn) + 1 totn = 1 if totp == 0: countp += 1 totp = -1 elif totp > 0: countp += abs(totp) + 1 totp = -1 elif x %2 == 0: if totn == 0: countn += 1 totn = -1 elif totn > 0: countn += abs(totn) + 1 totn = -1 if totp == 0: countp += 1 totp = 1 elif totp < 0: countp += abs(totp) + 1 totp = 1 '''print('totn', totn) print('countn', countn) print('totp', totp) print('countp', countp) ''' count = min(countn, countp) print(count)
Statement You are given an integer sequence of length N. The i-th term in the sequence is a_i. In one operation, you can select a term and either increment or decrement it by one. At least how many operations are necessary to satisfy the following conditions? * For every i (1≤i≤n), the sum of the terms from the 1-st through i-th term is not zero. * For every i (1≤i≤n-1), the sign of the sum of the terms from the 1-st through i-th term, is different from the sign of the sum of the terms from the 1-st through (i+1)-th term.
[{"input": "4\n 1 -3 1 0", "output": "4\n \n\nFor example, the given sequence can be transformed into 1, -2, 2, -2 by four\noperations. The sums of the first one, two, three and four terms are 1, -1, 1\nand -1, respectively, which satisfy the conditions.\n\n* * *"}, {"input": "5\n 3 -6 4 -5 7", "output": "0\n \n\nThe given sequence already satisfies the conditions.\n\n* * *"}, {"input": "6\n -1 4 3 2 -5 4", "output": "8"}]
Print the minimum necessary count of operations. * * *
s938825250
Runtime Error
p03739
Input is given from Standard Input in the following format: n a_1 a_2 ... a_n
n=int(input()) N=list(map(int,input().split())) emptylists=[] number=0 for i in range(n): number+=N[i] emptylists.append(number) ans1=0 use=0 for i in range(n): #偶数番が正、奇数番が負の時 if i%2==0: #奇数番め if emptylists[i]+use<0: continue if emptylists[i]+use>=0: ans1+=emptylists[i]+1 use=use-emptylists[i]-1 if i%2!=0: #偶数番め if emptylists[i]+use>0: continue if emptylists[i]+use<=0: ans1+=1-emptylists[i]-use use=use+1-emptylists[i] ans2=0 uses=0 for i in range(n): #偶数番が負、奇数番が正の時 if i%2!=0: #ぐう数番め if emptylists[i]<0: continue if emptylists[i]>=0: ans2+=emptylists[i]+1 uses=uses-emptylists[i]-1 if i%2==0: #き数番め if emptylists[i]>0: continue if emptylists[i]<=0: ans2+=1-emptylists[i]-uses uses=uses+1-emptylists[i] print(min(ans1,ans2))
Statement You are given an integer sequence of length N. The i-th term in the sequence is a_i. In one operation, you can select a term and either increment or decrement it by one. At least how many operations are necessary to satisfy the following conditions? * For every i (1≤i≤n), the sum of the terms from the 1-st through i-th term is not zero. * For every i (1≤i≤n-1), the sign of the sum of the terms from the 1-st through i-th term, is different from the sign of the sum of the terms from the 1-st through (i+1)-th term.
[{"input": "4\n 1 -3 1 0", "output": "4\n \n\nFor example, the given sequence can be transformed into 1, -2, 2, -2 by four\noperations. The sums of the first one, two, three and four terms are 1, -1, 1\nand -1, respectively, which satisfy the conditions.\n\n* * *"}, {"input": "5\n 3 -6 4 -5 7", "output": "0\n \n\nThe given sequence already satisfies the conditions.\n\n* * *"}, {"input": "6\n -1 4 3 2 -5 4", "output": "8"}]
Print the minimum necessary count of operations. * * *
s874753815
Runtime Error
p03739
Input is given from Standard Input in the following format: n a_1 a_2 ... a_n
n = int(input()) l = map(int, input().split()) ll = [] for q in range(len(l)): ll.append(l[q]) print(ll) sums1 = [0] * n count1 = 0 sums1[0] = ll[0] for i in range(1, len(ll)): sums1[i] = sums1[i - 1] + ll[i] if l[0] == 0: for v in range(len(sums1)): sums1 += [1] * len(sums1) count1 += 1 for k in range(1, len(sums1)): while sums1[k] == 0 or sums1[k] * sums1[k - 1] > 0: if sums1[k] == 0: for p in range(k, len(sums1)): sums1[p] += -(sums1[k - 1] / abs(sums1[k - 1])) count1 += 1 if sums1[k] * sums1[k - 1] > 0: for p in range(k, len(sums1)): sums1[p] += (abs(sums1[k]) + 1) * (-(sums1[k]) / abs(sums1[k])) count1 += abs(sums1[k]) + 1 sums2 = [0] * n count2 = 0 sums2[0] = ll[0] for i in range(1, len(ll)): sums2[i] = sums2[i - 1] + ll[i] if l[0] == 0: for v in range(len(sums2)): sums2 -= [1] * len(sums2) count2 += 1 for k in range(1, len(sums2)): while sums2[k] == 0 or sums2[k] * sums2[k - 1] > 0: if sums2[k] == 0: for p in range(k, len(sums2)): sums2[p] += -sums2[k - 1] / abs(sums2[k - 1]) count2 += 1 if sums2[k] * sums2[k - 1] > 0: for p in range(k, len(sums1)): sums2[p] += -(abs(sums2[k]) + 1) * ((sums2[k]) / abs(sums2[k])) count2 += abs(sums1[k]) + 1 print(min(count2, count2) * 2)
Statement You are given an integer sequence of length N. The i-th term in the sequence is a_i. In one operation, you can select a term and either increment or decrement it by one. At least how many operations are necessary to satisfy the following conditions? * For every i (1≤i≤n), the sum of the terms from the 1-st through i-th term is not zero. * For every i (1≤i≤n-1), the sign of the sum of the terms from the 1-st through i-th term, is different from the sign of the sum of the terms from the 1-st through (i+1)-th term.
[{"input": "4\n 1 -3 1 0", "output": "4\n \n\nFor example, the given sequence can be transformed into 1, -2, 2, -2 by four\noperations. The sums of the first one, two, three and four terms are 1, -1, 1\nand -1, respectively, which satisfy the conditions.\n\n* * *"}, {"input": "5\n 3 -6 4 -5 7", "output": "0\n \n\nThe given sequence already satisfies the conditions.\n\n* * *"}, {"input": "6\n -1 4 3 2 -5 4", "output": "8"}]
Print the minimum necessary count of operations. * * *
s934153849
Runtime Error
p03739
Input is given from Standard Input in the following format: n a_1 a_2 ... a_n
n = input() a = [int(i) for i in input.split()] X = 0 ans = 0 for i in a: X += i if X > 0: b = -1 - X ans += b - a(i+1) else X < 0: b = 1 - X ans += b - a(i+1) return ans print (ans)
Statement You are given an integer sequence of length N. The i-th term in the sequence is a_i. In one operation, you can select a term and either increment or decrement it by one. At least how many operations are necessary to satisfy the following conditions? * For every i (1≤i≤n), the sum of the terms from the 1-st through i-th term is not zero. * For every i (1≤i≤n-1), the sign of the sum of the terms from the 1-st through i-th term, is different from the sign of the sum of the terms from the 1-st through (i+1)-th term.
[{"input": "4\n 1 -3 1 0", "output": "4\n \n\nFor example, the given sequence can be transformed into 1, -2, 2, -2 by four\noperations. The sums of the first one, two, three and four terms are 1, -1, 1\nand -1, respectively, which satisfy the conditions.\n\n* * *"}, {"input": "5\n 3 -6 4 -5 7", "output": "0\n \n\nThe given sequence already satisfies the conditions.\n\n* * *"}, {"input": "6\n -1 4 3 2 -5 4", "output": "8"}]
Print the minimum necessary count of operations. * * *
s308353988
Runtime Error
p03739
Input is given from Standard Input in the following format: n a_1 a_2 ... a_n
n = int(input()) sa = input().split() a = [0 for i in range(n)] sumeven = 0 sumodd = 0 for i,sai in enumerate(sa): a[i] = int(sai) if i % 2 == 0: sumeven += a[i] else: sumodd += a[i] ret = 0 sm = 0 for i,ai in enumerate(a): if i % 2 == 1: ret += max(-sm+1-ai,0) sm += max(ai, -sm+1) else: ret += max(sm+1 + ai, 0) sm += min(ai, -(sm+1)) ret2 = 0 sm = 0 for i,ai in enumerate(a): if i % 2 == 0: ret2 += max(-sm+1-ai,0) sm += max(ai, -sm+1) else: ret2 += max(sm+1 + ai, 0) sm += min(ai, -(sm+1)) print(max(ret,ret2))
Statement You are given an integer sequence of length N. The i-th term in the sequence is a_i. In one operation, you can select a term and either increment or decrement it by one. At least how many operations are necessary to satisfy the following conditions? * For every i (1≤i≤n), the sum of the terms from the 1-st through i-th term is not zero. * For every i (1≤i≤n-1), the sign of the sum of the terms from the 1-st through i-th term, is different from the sign of the sum of the terms from the 1-st through (i+1)-th term.
[{"input": "4\n 1 -3 1 0", "output": "4\n \n\nFor example, the given sequence can be transformed into 1, -2, 2, -2 by four\noperations. The sums of the first one, two, three and four terms are 1, -1, 1\nand -1, respectively, which satisfy the conditions.\n\n* * *"}, {"input": "5\n 3 -6 4 -5 7", "output": "0\n \n\nThe given sequence already satisfies the conditions.\n\n* * *"}, {"input": "6\n -1 4 3 2 -5 4", "output": "8"}]
Print the minimum necessary count of operations. * * *
s671577958
Runtime Error
p03739
Input is given from Standard Input in the following format: n a_1 a_2 ... a_n
n = int(input()) a = list(map(int, input().split())) c = 0 i = 1 k = 1 sum = a[0] while a[i] == 0: i += 1 if a[i] > 0: if i % 2 == 1: a[0] = 1 c = 1 else: a[0] = -1 c = 1 else: if i % 2 == 1: a[0] = -1 c = 1 else: a[0] = 1 c = 1 i = 1 if a[0] > 0: while i < n: if i == 2*k-1: sum = sum + a[2*k-1] if sum >= 0: c = c + sum + 1 sum = -1 else: pass i += 1 else: sum = sum + a[2*k] if sum <= 0: c = c - sum + 1 sum = 1 else: pass i += 1 k += 1 print(c) elif a[0] < 0: while i < n: if i == 2*k-1: sum = sum + a[2*k-1] if sum <= 0: c = c - sum + 1 sum = 1 else: pass i += 1 else: sum = sum + a[2*k] while sum >= 0: c = c + sum + 1 sum = -1 else: pass i += 1 k += 1 print(c)
Statement You are given an integer sequence of length N. The i-th term in the sequence is a_i. In one operation, you can select a term and either increment or decrement it by one. At least how many operations are necessary to satisfy the following conditions? * For every i (1≤i≤n), the sum of the terms from the 1-st through i-th term is not zero. * For every i (1≤i≤n-1), the sign of the sum of the terms from the 1-st through i-th term, is different from the sign of the sum of the terms from the 1-st through (i+1)-th term.
[{"input": "4\n 1 -3 1 0", "output": "4\n \n\nFor example, the given sequence can be transformed into 1, -2, 2, -2 by four\noperations. The sums of the first one, two, three and four terms are 1, -1, 1\nand -1, respectively, which satisfy the conditions.\n\n* * *"}, {"input": "5\n 3 -6 4 -5 7", "output": "0\n \n\nThe given sequence already satisfies the conditions.\n\n* * *"}, {"input": "6\n -1 4 3 2 -5 4", "output": "8"}]
Print the minimum necessary count of operations. * * *
s822359883
Accepted
p03739
Input is given from Standard Input in the following format: n a_1 a_2 ... a_n
input() (*A,) = map(int, input().split()) f = True s1 = 0 r1 = 0 s2 = 0 r2 = 0 for a in A: s1 += a s2 += a if f and s1 <= 0: r1 += 1 - s1 s1 = 1 elif not (f) and s1 >= 0: r1 += s1 + 1 s1 = -1 if not (f) and s2 <= 0: r2 += 1 - s2 s2 = 1 elif f and s2 >= 0: r2 += s2 + 1 s2 = -1 f = not (f) print(min(r1, r2))
Statement You are given an integer sequence of length N. The i-th term in the sequence is a_i. In one operation, you can select a term and either increment or decrement it by one. At least how many operations are necessary to satisfy the following conditions? * For every i (1≤i≤n), the sum of the terms from the 1-st through i-th term is not zero. * For every i (1≤i≤n-1), the sign of the sum of the terms from the 1-st through i-th term, is different from the sign of the sum of the terms from the 1-st through (i+1)-th term.
[{"input": "4\n 1 -3 1 0", "output": "4\n \n\nFor example, the given sequence can be transformed into 1, -2, 2, -2 by four\noperations. The sums of the first one, two, three and four terms are 1, -1, 1\nand -1, respectively, which satisfy the conditions.\n\n* * *"}, {"input": "5\n 3 -6 4 -5 7", "output": "0\n \n\nThe given sequence already satisfies the conditions.\n\n* * *"}, {"input": "6\n -1 4 3 2 -5 4", "output": "8"}]
Print the minimum necessary count of operations. * * *
s479175677
Wrong Answer
p03739
Input is given from Standard Input in the following format: n a_1 a_2 ... a_n
N = int(input()) A = list(map(int, input().split())) cur = A[0] ans = 0 isplus = True ind = 1 if cur < 0: isplus = False if cur == 0: # すべて0の場合 allzero = True firstNotZero = 0 firstNotZeroInd = 0 for i in range(N): if A[i] != 0: firstNotZero = A[i] firstNotZeroInd = i allzero = False break if allzero: print(N) exit(0) # 0以外が出てくる場合 if firstNotZero > 0: cur = -1 ind = firstNotZeroInd isplus = False else: cur = 1 ind = firstNotZeroInd isplus = True for i in range(ind, N): if isplus: if cur + A[i] >= 0: diff = abs((cur + A[i]) - (-1)) ans += diff cur = -1 else: cur += A[i] isplus = False else: if cur + A[i] <= 0: diff = abs((cur + A[i]) - 1) ans += diff cur = 1 else: cur += A[i] isplus = True print(ans)
Statement You are given an integer sequence of length N. The i-th term in the sequence is a_i. In one operation, you can select a term and either increment or decrement it by one. At least how many operations are necessary to satisfy the following conditions? * For every i (1≤i≤n), the sum of the terms from the 1-st through i-th term is not zero. * For every i (1≤i≤n-1), the sign of the sum of the terms from the 1-st through i-th term, is different from the sign of the sum of the terms from the 1-st through (i+1)-th term.
[{"input": "4\n 1 -3 1 0", "output": "4\n \n\nFor example, the given sequence can be transformed into 1, -2, 2, -2 by four\noperations. The sums of the first one, two, three and four terms are 1, -1, 1\nand -1, respectively, which satisfy the conditions.\n\n* * *"}, {"input": "5\n 3 -6 4 -5 7", "output": "0\n \n\nThe given sequence already satisfies the conditions.\n\n* * *"}, {"input": "6\n -1 4 3 2 -5 4", "output": "8"}]
Print the minimum necessary count of operations. * * *
s440809362
Accepted
p03739
Input is given from Standard Input in the following format: n a_1 a_2 ... a_n
n = int(input()) arr = list(map(int, input().split())) cur = 0 a = 0 b = 0 prea = 0 preb = 0 resa = 0 resb = 0 for i in range(0, n): prea = prea + arr[i] if i % 2 == 0 and prea <= 0: resa = resa - prea + 1 prea = 1 if i % 2 == 1 and prea >= 0: resa = resa + prea + 1 prea = -1 for i in range(0, n): preb = preb + arr[i] if i % 2 == 1 and preb <= 0: resb = resb + (-preb + 1) preb = 1 if i % 2 == 0 and preb >= 0: resb = resb + preb + 1 preb = -1 print(min(resa, resb))
Statement You are given an integer sequence of length N. The i-th term in the sequence is a_i. In one operation, you can select a term and either increment or decrement it by one. At least how many operations are necessary to satisfy the following conditions? * For every i (1≤i≤n), the sum of the terms from the 1-st through i-th term is not zero. * For every i (1≤i≤n-1), the sign of the sum of the terms from the 1-st through i-th term, is different from the sign of the sum of the terms from the 1-st through (i+1)-th term.
[{"input": "4\n 1 -3 1 0", "output": "4\n \n\nFor example, the given sequence can be transformed into 1, -2, 2, -2 by four\noperations. The sums of the first one, two, three and four terms are 1, -1, 1\nand -1, respectively, which satisfy the conditions.\n\n* * *"}, {"input": "5\n 3 -6 4 -5 7", "output": "0\n \n\nThe given sequence already satisfies the conditions.\n\n* * *"}, {"input": "6\n -1 4 3 2 -5 4", "output": "8"}]
Print the minimum necessary count of operations. * * *
s303853650
Accepted
p03739
Input is given from Standard Input in the following format: n a_1 a_2 ... a_n
def getN(): return int(input()) def getNM(): return map(int, input().split()) def getList(): return list(map(int, input().split())) def getArray(intn): return [int(input()) for i in range(intn)] def input(): return sys.stdin.readline().rstrip() def rand_N(ran1, ran2): return random.randint(ran1, ran2) def rand_List(ran1, ran2, rantime): return [random.randint(ran1, ran2) for i in range(rantime)] def rand_ints_nodup(ran1, ran2, rantime): ns = [] while len(ns) < rantime: n = random.randint(ran1, ran2) if not n in ns: ns.append(n) return sorted(ns) def rand_query(ran1, ran2, rantime): r_query = [] while len(r_query) < rantime: n_q = rand_ints_nodup(ran1, ran2, 2) if not n_q in r_query: r_query.append(n_q) return sorted(r_query) from collections import defaultdict, deque, Counter from sys import exit from decimal import * import heapq import math from fractions import gcd import random import string import copy from itertools import combinations, permutations, product from operator import mul from functools import reduce from bisect import bisect_left, bisect_right import sys sys.setrecursionlimit(1000000000) mod = 10**9 + 7 ############# # Main Code # ############# N = getN() A = getList() num = copy.deepcopy(A) for i in range(1, N): num[i] += num[i - 1] # + - + - margin_1 = 0 num_1 = copy.deepcopy(num) cnt_1 = 0 for i in range(N): num_1[i] += margin_1 if i % 2 == 0: plus = max(1 - num_1[i], 0) num_1[i] += plus margin_1 += plus cnt_1 += plus else: minus = max(num_1[i] - (-1), 0) num_1[i] -= minus margin_1 -= minus cnt_1 += minus margin_2 = 0 num_2 = copy.deepcopy(num) cnt_2 = 0 for i in range(N): num_2[i] += margin_2 if i % 2 != 0: plus = max(1 - num_2[i], 0) num_2[i] += plus margin_2 += plus cnt_2 += plus else: minus = max(num_2[i] - (-1), 0) num_2[i] -= minus margin_2 -= minus cnt_2 += minus print(min(cnt_1, cnt_2))
Statement You are given an integer sequence of length N. The i-th term in the sequence is a_i. In one operation, you can select a term and either increment or decrement it by one. At least how many operations are necessary to satisfy the following conditions? * For every i (1≤i≤n), the sum of the terms from the 1-st through i-th term is not zero. * For every i (1≤i≤n-1), the sign of the sum of the terms from the 1-st through i-th term, is different from the sign of the sum of the terms from the 1-st through (i+1)-th term.
[{"input": "4\n 1 -3 1 0", "output": "4\n \n\nFor example, the given sequence can be transformed into 1, -2, 2, -2 by four\noperations. The sums of the first one, two, three and four terms are 1, -1, 1\nand -1, respectively, which satisfy the conditions.\n\n* * *"}, {"input": "5\n 3 -6 4 -5 7", "output": "0\n \n\nThe given sequence already satisfies the conditions.\n\n* * *"}, {"input": "6\n -1 4 3 2 -5 4", "output": "8"}]
Print the minimum necessary count of operations. * * *
s571658184
Accepted
p03739
Input is given from Standard Input in the following format: n a_1 a_2 ... a_n
def sign(X): return [-1, 0, 1][(X >= 0) + (X > 0)] N = int(input()) A = [int(T) for T in input().split()] AFPCnt = 0 AFPNow = 0 for TFP in range(0, N): AFPNow += A[TFP] if sign(AFPNow) != (-1) ** TFP: AFPCnt += abs(AFPNow) + 1 AFPNow = (-1) ** TFP AFFCnt = 0 AFFNow = 0 for TFF in range(0, N): AFFNow += A[TFF] if sign(AFFNow) != (-1) ** (TFF + 1): AFFCnt += abs(AFFNow) + 1 AFFNow = (-1) ** (TFF + 1) print(min(AFPCnt, AFFCnt))
Statement You are given an integer sequence of length N. The i-th term in the sequence is a_i. In one operation, you can select a term and either increment or decrement it by one. At least how many operations are necessary to satisfy the following conditions? * For every i (1≤i≤n), the sum of the terms from the 1-st through i-th term is not zero. * For every i (1≤i≤n-1), the sign of the sum of the terms from the 1-st through i-th term, is different from the sign of the sum of the terms from the 1-st through (i+1)-th term.
[{"input": "4\n 1 -3 1 0", "output": "4\n \n\nFor example, the given sequence can be transformed into 1, -2, 2, -2 by four\noperations. The sums of the first one, two, three and four terms are 1, -1, 1\nand -1, respectively, which satisfy the conditions.\n\n* * *"}, {"input": "5\n 3 -6 4 -5 7", "output": "0\n \n\nThe given sequence already satisfies the conditions.\n\n* * *"}, {"input": "6\n -1 4 3 2 -5 4", "output": "8"}]
Print the minimum necessary count of operations. * * *
s679455493
Runtime Error
p03739
Input is given from Standard Input in the following format: n a_1 a_2 ... a_n
N = int(input()) A = list(map(int,input().split())) ans = 0 s = A[0] if s > 0: flag = 1 elif s < 0: flag = -1 elif if A[1] < 0: flag = 1 ans += 1 else: flag = -1 ans += 1 for i in range(1,N): s += A[i] if flag == 1 and s >= 0: ans += s + 1 s = -1 elif flag == -1 and s <= 0: ans += 1 - s s = 1 flag *= -1 print(ans)
Statement You are given an integer sequence of length N. The i-th term in the sequence is a_i. In one operation, you can select a term and either increment or decrement it by one. At least how many operations are necessary to satisfy the following conditions? * For every i (1≤i≤n), the sum of the terms from the 1-st through i-th term is not zero. * For every i (1≤i≤n-1), the sign of the sum of the terms from the 1-st through i-th term, is different from the sign of the sum of the terms from the 1-st through (i+1)-th term.
[{"input": "4\n 1 -3 1 0", "output": "4\n \n\nFor example, the given sequence can be transformed into 1, -2, 2, -2 by four\noperations. The sums of the first one, two, three and four terms are 1, -1, 1\nand -1, respectively, which satisfy the conditions.\n\n* * *"}, {"input": "5\n 3 -6 4 -5 7", "output": "0\n \n\nThe given sequence already satisfies the conditions.\n\n* * *"}, {"input": "6\n -1 4 3 2 -5 4", "output": "8"}]
Print the minimum necessary count of operations. * * *
s769489160
Runtime Error
p03739
Input is given from Standard Input in the following format: n a_1 a_2 ... a_n
n=int(input()) l=list(map(int,input().split())) l.append(0) a1=0 b1=0 a2=0 b2=0 for i in range(n): b1+=l[i] b2+=l[i] if i%2==0: if b1>=0: a1+=abs(-1-b1) b1=-1-l[i+1] if b2=<0: a2+=abs(1-b2) b2=1-l[i+1] else: if b1<=0: a1+=abs(1-b1) b1=1-l[i+1] if b2>=0: a2+=abs(-1-b2) b2=-1-l[i+1] print(min(a1,a2))
Statement You are given an integer sequence of length N. The i-th term in the sequence is a_i. In one operation, you can select a term and either increment or decrement it by one. At least how many operations are necessary to satisfy the following conditions? * For every i (1≤i≤n), the sum of the terms from the 1-st through i-th term is not zero. * For every i (1≤i≤n-1), the sign of the sum of the terms from the 1-st through i-th term, is different from the sign of the sum of the terms from the 1-st through (i+1)-th term.
[{"input": "4\n 1 -3 1 0", "output": "4\n \n\nFor example, the given sequence can be transformed into 1, -2, 2, -2 by four\noperations. The sums of the first one, two, three and four terms are 1, -1, 1\nand -1, respectively, which satisfy the conditions.\n\n* * *"}, {"input": "5\n 3 -6 4 -5 7", "output": "0\n \n\nThe given sequence already satisfies the conditions.\n\n* * *"}, {"input": "6\n -1 4 3 2 -5 4", "output": "8"}]
Print the minimum necessary count of operations. * * *
s987640330
Runtime Error
p03739
Input is given from Standard Input in the following format: n a_1 a_2 ... a_n
N = int(input()) A = list(map(int, input().split())) counter = 0 ####操作回数 A.reverse() S = 0 a = A.pop() if a==0: counter += 1 while A: b = A.pop() if b == 0: counter += 2 elif b>0: A.append(b) S = -1 break elif b<0: A.append(b) S = 1 break else: S += a while A: c = A.pop() if c>=0 and S>0: counter += abs(c+S)+1 S = -1 elif c<=0 and S<0: counter += abs(c+S)+1 S = 1 elif (c>=0 and S<0) and S+c<=0: counter += abs(S+c)+1 S = 1 elif (c=<0 and S>0) and S+c>=0: counter += abs(S+c)+1 S = -1 else: S += c print(counter)
Statement You are given an integer sequence of length N. The i-th term in the sequence is a_i. In one operation, you can select a term and either increment or decrement it by one. At least how many operations are necessary to satisfy the following conditions? * For every i (1≤i≤n), the sum of the terms from the 1-st through i-th term is not zero. * For every i (1≤i≤n-1), the sign of the sum of the terms from the 1-st through i-th term, is different from the sign of the sum of the terms from the 1-st through (i+1)-th term.
[{"input": "4\n 1 -3 1 0", "output": "4\n \n\nFor example, the given sequence can be transformed into 1, -2, 2, -2 by four\noperations. The sums of the first one, two, three and four terms are 1, -1, 1\nand -1, respectively, which satisfy the conditions.\n\n* * *"}, {"input": "5\n 3 -6 4 -5 7", "output": "0\n \n\nThe given sequence already satisfies the conditions.\n\n* * *"}, {"input": "6\n -1 4 3 2 -5 4", "output": "8"}]
Print the minimum necessary count of operations. * * *
s430116329
Accepted
p03739
Input is given from Standard Input in the following format: n a_1 a_2 ... a_n
N = int(input()) A = list(map(int, input().split())) pos = 0 left = A[0] if left <= 0: pos += 1 - left left = 1 for a in A[1:]: if left * (left + a) < 0: left += a else: if left + a == 0: if left < 0: left += a + 1 else: left += a - 1 pos += 1 else: pos += abs(left + a) + 1 if left < 0: left = 1 else: left = -1 neg = 0 left = A[0] if left >= 0: neg += left + 1 left = -1 for a in A[1:]: if left * (left + a) < 0: left += a else: if left + a == 0: if left < 0: left += a + 1 else: left += a - 1 neg += 1 else: neg += abs(left + a) + 1 if left < 0: left = 1 else: left = -1 print(min(neg, pos))
Statement You are given an integer sequence of length N. The i-th term in the sequence is a_i. In one operation, you can select a term and either increment or decrement it by one. At least how many operations are necessary to satisfy the following conditions? * For every i (1≤i≤n), the sum of the terms from the 1-st through i-th term is not zero. * For every i (1≤i≤n-1), the sign of the sum of the terms from the 1-st through i-th term, is different from the sign of the sum of the terms from the 1-st through (i+1)-th term.
[{"input": "4\n 1 -3 1 0", "output": "4\n \n\nFor example, the given sequence can be transformed into 1, -2, 2, -2 by four\noperations. The sums of the first one, two, three and four terms are 1, -1, 1\nand -1, respectively, which satisfy the conditions.\n\n* * *"}, {"input": "5\n 3 -6 4 -5 7", "output": "0\n \n\nThe given sequence already satisfies the conditions.\n\n* * *"}, {"input": "6\n -1 4 3 2 -5 4", "output": "8"}]
Print the minimum necessary count of operations. * * *
s296636229
Wrong Answer
p03739
Input is given from Standard Input in the following format: n a_1 a_2 ... a_n
n = int(input()) a = list(map(int, input().split())) A = [j for j in a] cnt1 = 0 cnt2 = 0 S = 0 if a[0] > 0: for i in range(n - 1): S += a[i] if a[i] > 0: if S + a[i + 1] >= 0: cnt1 += ( a[i + 1] + S + 1 if a[i + 1] + S + 1 > 0 else -(a[i + 1] + S + 1) ) a[i + 1] = -1 - S elif a[i] < 0: if S + a[i + 1] <= 0: cnt1 += ( a[i + 1] + S - 1 if a[i + 1] + S - 1 > 0 else -(a[i + 1] + S - 1) ) a[i + 1] = 1 - S A[0] = -1 cnt2 = a[0] + 1 for i in range(n - 1): S += A[i] if A[i] > 0: if S + A[i + 1] >= 0: cnt2 += ( A[i + 1] + S + 1 if A[i + 1] + S + 1 > 0 else -(A[i + 1] + S + 1) ) A[i + 1] = -1 - S elif A[i] < 0: if S + A[i + 1] <= 0: cnt2 += ( a[i + 1] + S - 1 if a[i + 1] + S - 1 > 0 else -(a[i + 1] + S - 1) ) A[i + 1] = 1 - S elif a[0] < 0: for i in range(n - 1): S += a[i] if a[i] > 0: if S + a[i + 1] >= 0: cnt1 += ( a[i + 1] + S + 1 if a[i + 1] + S + 1 > 0 else -(a[i + 1] + S + 1) ) a[i + 1] = -1 - S elif a[i] < 0: if S + a[i + 1] <= 0: cnt1 += ( a[i + 1] + S - 1 if a[i + 1] + S - 1 > 0 else -(a[i + 1] + S - 1) ) a[i + 1] = 1 - S A[0] = 1 cnt2 = -a[0] + 1 for i in range(n - 1): S += A[i] if A[i] > 0: if S + A[i + 1] >= 0: cnt2 += ( A[i + 1] + S + 1 if A[i + 1] + S + 1 > 0 else -(A[i + 1] + S + 1) ) A[i + 1] = -1 - S elif A[i] < 0: if S + A[i + 1] <= 0: cnt2 += ( a[i + 1] + S - 1 if a[i + 1] + S - 1 > 0 else -(a[i + 1] + S - 1) ) A[i + 1] = 1 - S else: a[0] = 1 cnt1 = 1 for i in range(n - 1): S += a[i] if a[i] > 0: if S + a[i + 1] >= 0: cnt1 += ( a[i + 1] + S + 1 if a[i + 1] + S + 1 > 0 else -(a[i + 1] + S + 1) ) a[i + 1] = -1 - S elif a[i] < 0: if S + a[i + 1] <= 0: cnt1 += ( a[i + 1] + S - 1 if a[i + 1] + S - 1 > 0 else -(a[i + 1] + S - 1) ) a[i + 1] = 1 - S A[0] = -1 cnt2 = 1 for i in range(n - 1): S += A[i] if A[i] > 0: if S + A[i + 1] >= 0: cnt2 += ( A[i + 1] + S + 1 if A[i + 1] + S + 1 > 0 else -(A[i + 1] + S + 1) ) A[i + 1] = -1 - S elif A[i] < 0: if S + A[i + 1] <= 0: cnt2 += ( a[i + 1] + S - 1 if a[i + 1] + S - 1 > 0 else -(a[i + 1] + S - 1) ) A[i + 1] = 1 - S cnt = cnt2 if cnt1 >= cnt2 else cnt1 print(cnt)
Statement You are given an integer sequence of length N. The i-th term in the sequence is a_i. In one operation, you can select a term and either increment or decrement it by one. At least how many operations are necessary to satisfy the following conditions? * For every i (1≤i≤n), the sum of the terms from the 1-st through i-th term is not zero. * For every i (1≤i≤n-1), the sign of the sum of the terms from the 1-st through i-th term, is different from the sign of the sum of the terms from the 1-st through (i+1)-th term.
[{"input": "4\n 1 -3 1 0", "output": "4\n \n\nFor example, the given sequence can be transformed into 1, -2, 2, -2 by four\noperations. The sums of the first one, two, three and four terms are 1, -1, 1\nand -1, respectively, which satisfy the conditions.\n\n* * *"}, {"input": "5\n 3 -6 4 -5 7", "output": "0\n \n\nThe given sequence already satisfies the conditions.\n\n* * *"}, {"input": "6\n -1 4 3 2 -5 4", "output": "8"}]
Print the minimum necessary count of operations. * * *
s034696131
Wrong Answer
p03739
Input is given from Standard Input in the following format: n a_1 a_2 ... a_n
n = int(input()) a = [int(x) for x in input().split()] for num, i in enumerate(a): if i != 0: non0 = num break if non0 == 0: ans = 0 elif non0 == 1: ans = 2 else: ans = (non0 - 2) * 2 + 2 Sum = a[non0] if a[non0] > 0: flag = +1 else: flag = -1 for i in range(non0 + 1, n): Sum += a[i] if flag == 1: if Sum >= 0: ans += Sum + 1 Sum = -1 flag = -1 elif flag == -1: if Sum <= 0: ans += 1 - Sum Sum = 1 flag = 1 print(ans)
Statement You are given an integer sequence of length N. The i-th term in the sequence is a_i. In one operation, you can select a term and either increment or decrement it by one. At least how many operations are necessary to satisfy the following conditions? * For every i (1≤i≤n), the sum of the terms from the 1-st through i-th term is not zero. * For every i (1≤i≤n-1), the sign of the sum of the terms from the 1-st through i-th term, is different from the sign of the sum of the terms from the 1-st through (i+1)-th term.
[{"input": "4\n 1 -3 1 0", "output": "4\n \n\nFor example, the given sequence can be transformed into 1, -2, 2, -2 by four\noperations. The sums of the first one, two, three and four terms are 1, -1, 1\nand -1, respectively, which satisfy the conditions.\n\n* * *"}, {"input": "5\n 3 -6 4 -5 7", "output": "0\n \n\nThe given sequence already satisfies the conditions.\n\n* * *"}, {"input": "6\n -1 4 3 2 -5 4", "output": "8"}]
Print the minimum necessary count of operations. * * *
s560067856
Accepted
p03739
Input is given from Standard Input in the following format: n a_1 a_2 ... a_n
# https://atcoder.jp/contests/abc059/tasks/arc072_a # C - Sequence import copy N = int(input().split()[0]) a_list = list(map(int, input().split())) w_list_1 = copy.copy(a_list) w_list_2 = copy.copy(a_list) c_1, c_2 = 0, 0 s_1, s_2 = 0, 0 c_list = [] for i in range(N): # 10 ** 5 # 偶数項を正にする場合 before = w_list_1[i] s_1 += before if i % 2 == 0 and s_1 < 0: w_list_1[i] += abs(s_1) c_1 += abs(s_1) elif i % 2 != 0 and s_1 >= 0: w_list_1[i] -= abs(s_1 + 1) c_1 += abs(s_1 + 1) s_1 = s_1 - before + w_list_1[i] if s_1 == 0: a = w_list_1[i] w_list_1[i] = a + 1 if a >= 0 else a - 1 s_1 = 1 if a >= 0 else -1 c_1 += 1 # 偶数項を負にする場合 before = w_list_2[i] s_2 += before if i % 2 == 1 and s_2 < 0: w_list_2[i] += abs(s_2) c_2 += abs(s_2) elif i % 2 != 1 and s_2 >= 0: w_list_2[i] -= abs(s_2 + 1) c_2 += abs(s_2 + 1) s_2 = s_2 - before + w_list_2[i] if s_2 == 0: a = w_list_2[i] w_list_2[i] = a + 1 if a >= 0 else a - 1 s_2 = 1 if a >= 0 else -1 c_2 += 1 ans = min([c_1, c_2]) print(ans)
Statement You are given an integer sequence of length N. The i-th term in the sequence is a_i. In one operation, you can select a term and either increment or decrement it by one. At least how many operations are necessary to satisfy the following conditions? * For every i (1≤i≤n), the sum of the terms from the 1-st through i-th term is not zero. * For every i (1≤i≤n-1), the sign of the sum of the terms from the 1-st through i-th term, is different from the sign of the sum of the terms from the 1-st through (i+1)-th term.
[{"input": "4\n 1 -3 1 0", "output": "4\n \n\nFor example, the given sequence can be transformed into 1, -2, 2, -2 by four\noperations. The sums of the first one, two, three and four terms are 1, -1, 1\nand -1, respectively, which satisfy the conditions.\n\n* * *"}, {"input": "5\n 3 -6 4 -5 7", "output": "0\n \n\nThe given sequence already satisfies the conditions.\n\n* * *"}, {"input": "6\n -1 4 3 2 -5 4", "output": "8"}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s280690505
Runtime Error
p03693
Input is given from Standard Input in the following format: r g b
L=int("".join(map(str,list(map(int,input().split())))) if L%4==0: print("YES") else: print("NO")
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s918655786
Accepted
p03693
Input is given from Standard Input in the following format: r g b
A, B, C = [int(x) for x in input().split()] print("YES" if (A * 100 + B * 10 + C) % 4 == 0 else "NO")
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s394450312
Accepted
p03693
Input is given from Standard Input in the following format: r g b
R, G, B = map(int, input().split()) print("YES" if (R * 100 + G * 10 + B) % 4 == 0 else "NO")
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s079960716
Accepted
p03693
Input is given from Standard Input in the following format: r g b
print("YNEOS"[eval(input().replace(" ", "")) % 4 > 0 :: 2])
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s148594953
Wrong Answer
p03693
Input is given from Standard Input in the following format: r g b
print(["YES", "NO"][int("".join(input().split())) % 4 == 0])
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s510467310
Runtime Error
p03693
Input is given from Standard Input in the following format: r g b
r,g,b = map(int, input().split()) print("YES" if (g*10+b)%4===0 else "NO")
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s081159992
Runtime Error
p03693
Input is given from Standard Input in the following format: r g b
r,g,b=map(int,input().split()) print('YES' if (10*g+b)%4==0 else 'NO'
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s040108436
Runtime Error
p03693
Input is given from Standard Input in the following format: r g b
a = int(input().replace(' ', '')) if a % 4 == 0: print('YES') else: print('NO')
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s336520560
Wrong Answer
p03693
Input is given from Standard Input in the following format: r g b
print("No" if int(input().replace(" ", "")) % 4 else "Yes")
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s189709571
Wrong Answer
p03693
Input is given from Standard Input in the following format: r g b
print("YES" if int(input().replace(" ", "")) % 4 == 0 else "No")
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s361685754
Wrong Answer
p03693
Input is given from Standard Input in the following format: r g b
print(["YES", "NO"][int("".join(input().split())) % 4 & 1])
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s638299173
Wrong Answer
p03693
Input is given from Standard Input in the following format: r g b
print("No" if int(input()[::2]) % 4 else "Yes")
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s364955514
Wrong Answer
p03693
Input is given from Standard Input in the following format: r g b
print("Yes" if int(input().replace(" ", "")) % 4 == 0 else "No")
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s636322767
Runtime Error
p03693
Input is given from Standard Input in the following format: r g b
if 100*r+10*g+b %4 =0: print("Yes") else: print("No")
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s104460015
Accepted
p03693
Input is given from Standard Input in the following format: r g b
import sys import math import collections import itertools import array import inspect # Set max recursion limit sys.setrecursionlimit(1000000) # Debug output def chkprint(*args): names = {id(v): k for k, v in inspect.currentframe().f_back.f_locals.items()} print(", ".join(names.get(id(arg), "???") + " = " + repr(arg) for arg in args)) # Binary converter def to_bin(x): return bin(x)[2:] def li_input(): return [int(_) for _ in input().split()] def gcd(n, m): if n % m == 0: return m else: return gcd(m, n % m) def gcd_list(L): v = L[0] for i in range(1, len(L)): v = gcd(v, L[i]) return v def lcm(n, m): return (n * m) // gcd(n, m) def lcm_list(L): v = L[0] for i in range(1, len(L)): v = lcm(v, L[i]) return v # Width First Search (+ Distance) def wfs_d(D, N, K): """ D: 隣接行列(距離付き) N: ノード数 K: 始点ノード """ dfk = [-1] * (N + 1) dfk[K] = 0 cps = [(K, 0)] r = [False] * (N + 1) r[K] = True while len(cps) != 0: n_cps = [] for cp, cd in cps: for i, dfcp in enumerate(D[cp]): if dfcp != -1 and not r[i]: dfk[i] = cd + dfcp n_cps.append((i, cd + dfcp)) r[i] = True cps = n_cps[:] return dfk # Depth First Search (+Distance) def dfs_d(v, pre, dist): """ v: 現在のノード pre: 1つ前のノード dist: 現在の距離 以下は別途用意する D: 隣接リスト(行列ではない) D_dfs_d: dfs_d関数で用いる,始点ノードから見た距離リスト """ global D global D_dfs_d D_dfs_d[v] = dist for next_v, d in D[v]: if next_v != pre: dfs_d(next_v, v, dist + d) return def sigma(N): ans = 0 for i in range(1, N + 1): ans += i return ans class Combination: def __init__(self, n, mod): g1 = [1, 1] g2 = [1, 1] inverse = [0, 1] for i in range(2, n + 1): g1.append((g1[-1] * i) % mod) inverse.append((-inverse[mod % i] * (mod // i)) % mod) g2.append((g2[-1] * inverse[-1]) % mod) self.MOD = mod self.N = n self.g1 = g1 self.g2 = g2 self.inverse = inverse def __call__(self, n, r): if r < 0 or r > n: return 0 r = min(r, n - r) return self.g1[n] * self.g2[r] * self.g2[n - r] % self.MOD # -------------------------------------------- dp = None def main(): r, g, b = li_input() n = r * 100 + g * 10 + b if n % 4 == 0: print("YES") else: print("NO") main()
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s346943681
Runtime Error
p03693
Input is given from Standard Input in the following format: r g b
import numpy as np # 参加人数を入力する N = int(input()) # レートを入力する a = list(map(int, input().split())) # ndarray型に変換 arr_a = np.array(a) # 3200未満のレートを持つ人について、色の種類数を設定する under3200 = 0 # 色ごとのレートの下限と上限を設定 lower = 1 upper = 399 # 上限が3200未満である限り繰り返す while upper < 3200: # 範囲内のレートを持つ人がいる場合、色の種類数を増やす if len(arr_a[(arr_a >= lower) & (arr_a <= upper)]) != 0: under3200 += 1 # 下限と上限を更新する lower = upper + 1 upper += 400 # 3200を超えるレートを持つ人の数を数える over3200 = len(arr_a[arr_a >= 3200]) # 色の種類数の最小値について if under3200 != 0: under3200 else: min_color = 1 # 色の種類数の最大値について max_color = under3200 + over3200 # 結果を出力する print("{} {}".format(min_color, max_color))
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s755341080
Runtime Error
p03693
Input is given from Standard Input in the following format: r g b
l=[0]*13 input() for i in input().split():;l[int(i)//400]+=1 r=sum([1 for a in l[:8] if a > 0]) print(max(1,r),r+sum(l[8:]))
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s574966054
Runtime Error
p03693
Input is given from Standard Input in the following format: r g b
# C - Colorful Leaderboard N = int(input()) a = list(map(int, input().split())) mini = 0 color_list = [] for i in a: if (i // 400) < 8 and ((i // 400 in color_list) == False): mini += 1 color_list.append(i // 400) maxi = mini for j in a: if maxi == 8: break if j >= 3200: maxi += 1 if mini == 0: # 忘れてた mini = 1 print(mini, maxi)
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s220472198
Runtime Error
p03693
Input is given from Standard Input in the following format: r g b
# 100の位r,10の位g,1の位bに整数を入力 r,g,b = map(int,input().split()) # 100r+10g+bが4の倍数ならYES、違うならNO if (100r + 10g +b) // 4 == 0: print("YES") else: print("NO")
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s167156952
Accepted
p03693
Input is given from Standard Input in the following format: r g b
rgb_num = int("".join(input().split())) answer = "YES" if rgb_num % 4 == 0 else "NO" print(answer)
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s341652990
Runtime Error
p03693
Input is given from Standard Input in the following format: r g b
1. r,g,b=map(int,input().split()) 2. if (g*10+b)%4==0: 3. print('YES') 4. else: 5. print('NO')
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s541257332
Runtime Error
p03693
Input is given from Standard Input in the following format: r g b
print(["NO", "YES"][int("".join(input().split()))])
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s222605672
Wrong Answer
p03693
Input is given from Standard Input in the following format: r g b
print("YES" if int("".join(sorted(input().split()))) % 4 == 0 else "NO")
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s380697018
Runtime Error
p03693
Input is given from Standard Input in the following format: r g b
N = int(input()) A = input().split() b = [0] * 8 c = 0 for a in A: a = int(a) if 1 <= a <= 399: b[0] += 1 elif 400 <= a <= 799: b[1] += 1 elif 800 <= a <= 1199: b[2] += 1 elif 1200 <= a <= 1599: b[3] += 1 elif 1600 <= a <= 1999: b[4] += 1 elif 2000 <= a <= 2399: b[5] += 1 elif 2400 <= a <= 2799: b[6] += 1 elif 2800 <= a <= 3199: b[7] += 1 elif 3200 <= a: c += 1 if c == 0: print(8 - b.count(0), end=" ") else: print(max(8 - b.count(0), 1), end=" ") print(min(8 - b.count(0) + c, 9))
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s895300803
Runtime Error
p03693
Input is given from Standard Input in the following format: r g b
N = int(input()) a = list(map(int, input().split())) rate = [400, 800, 1200, 1600, 2000, 2400, 2800, 3200] a.sort() answer = 0 counter = 0 i = 0 j = 0 while i < N: if a[i] >= rate[j]: j += 1 else: answer += 1 while i < N and a[i] < rate[j]: i += 1 j += 1 if i < N and j == 8: counter += N - i break print(max(answer, 1), answer + counter)
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s884063852
Runtime Error
p03693
Input is given from Standard Input in the following format: r g b
N = int(input()) a = map(int, input().split()) num = [0, 0, 0, 0, 0, 0, 0, 0, 0] counter = 0 for i in a: if 1 <= i and i <= 399: num[0] += 1 elif 400 <= i and i <= 799: num[1] += 1 elif 800 <= i and i <= 1199: num[2] += 1 elif 1200 <= i and i <= 1599: num[3] += 1 elif 1600 <= i and i <= 1999: num[4] += 1 elif 2000 <= i and i <= 2399: num[5] += 1 elif 2400 <= i and i <= 2799: num[6] += 1 elif 2800 <= i and i <= 3199: num[7] += 1 elif 3200 <= i: num[8] += 1 for i in range(0, 8): if num[i] != 0: counter += 1 if counter == 0 and num[8] == 0: min = 0 max = 0 elif counter == 0 and num[8] != 0: min = 1 max = num[8] else: min = counter max = counter + num[8] # print(num) print(str(min) + " " + str(max))
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s288067648
Runtime Error
p03693
Input is given from Standard Input in the following format: r g b
N = int(input()) lst = [0] * 9 for x in [int(x) for x in input().split()]: if x <= 399: lst[0] = 1 elif x <= 799: lst[1] = 1 elif x <= 1199: lst[2] = 1 elif x <= 1599: lst[3] = 1 elif x <= 1999: lst[4] = 1 elif x <= 2399: lst[5] = 1 elif x <= 2799: lst[6] = 1 elif x <= 3199: lst[7] = 1 else: lst[8] += 1 a = sum(lst[:-1]) b = lst[8] if a == 0 and b > 0: print("1 {0}".format(b)) else: print("{0} {1}".format(a, a + b))
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s088645748
Runtime Error
p03693
Input is given from Standard Input in the following format: r g b
n = int(input()) l = list(map(int, input().split())) col = [False for i in range(8)] val = 0 count = 0 for i in range(n): m = l[i] if m < 400: col[0] = True if 400 <= m < 800: col[1] = True if 800 <= m < 1200: col[2] = True if 1200 <= m < 1600: col[3] = True if 1600 <= m < 2000: col[4] = True if 2000 <= m < 2400: col[5] = True if 2400 <= m < 2800: col[6] = True if 2800 <= m < 3200: col[7] = True if m >= 3200: val += 1 for i in range(8): if col[i]: count += 1 print(count, min(8, count + val))
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s159710204
Runtime Error
p03693
Input is given from Standard Input in the following format: r g b
r, g, b = map(int, input().split) number = r * 100 + g * 10 + b if number % 4 = 0: print("YES") else: print("NO")
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s102882258
Runtime Error
p03693
Input is given from Standard Input in the following format: r g b
N = int(input()) a = [int(i) for i in input().split()] b, c, d, e, f, g, h, j, k = 0, 0, 0, 0, 0, 0, 0, 0, 0 for i in range(N): if a[i] < 400: b = 1 elif a[i] < 800: c = 1 elif [i] < 1200: d = 1 elif a[i] < 1600: e = 1 elif a[i] < 2000: f = 1 elif [i] < 2400: g = 1 elif a[i] < 2800: h = 1 elif a[i] < 3200: j = 1 else: k += 1 min = b + c + d + e + f + g + h + j max = min + k if min == 0: min = 1 print(min, max)
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s893301899
Runtime Error
p03693
Input is given from Standard Input in the following format: r g b
N = int(input()) A = list(map(int, input().split())) gray = any([1 <= i <= 399 for i in A]) brown = any([400 <= i <= 799 for i in A]) green = any([800 <= i <= 1199 for i in A]) sky = any([1200 <= i <= 1599 for i in A]) blue = any([1600 <= i <= 1999 for i in A]) yellow = any([2000 <= i <= 2399 for i in A]) orange = any([2400 <= i <= 2799 for i in A]) red = any([2800 <= i <= 3199 for i in A]) color_list = [gray, brown, green, sky, blue, yellow, orange, red] count = color_list.count(True) change = len([i for i in A if 3200 <= i]) if count == 0: print(1, change) else: print(count, count + change)
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s682851974
Accepted
p03693
Input is given from Standard Input in the following format: r g b
print("YES" if int("".join(list(map(str, input().strip().split())))) % 4 == 0 else "NO")
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s841574750
Accepted
p03693
Input is given from Standard Input in the following format: r g b
color = list(map(str, input().split())) print("YES" if int("".join(color)) % 4 == 0 else "NO")
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s346309555
Runtime Error
p03693
Input is given from Standard Input in the following format: r g b
r, g, b = map(int, input().split()) a = 100 * r + 10 * g + b if a % 4 = 0: print("YES") else: print("NO")
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s505550904
Runtime Error
p03693
Input is given from Standard Input in the following format: r g b
r=int(input()) g=int(input()) b=int(input()) if (100*r+10g+b)%4==0: print('YES') else: print('NO')
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s654493004
Runtime Error
p03693
Input is given from Standard Input in the following format: r g b
r,g,b = map(int, input().split()) t=r*100+g*10+b if t % 4 ==0: print("YES") else: print("NO")
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s611032643
Runtime Error
p03693
Input is given from Standard Input in the following format: r g b
r=input() g=input() b=input() r=int(r) g=int(g) b=int(b) if print(rgb)/4=0: return 'Yes' else: return 'No'
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s079971329
Runtime Error
p03693
Input is given from Standard Input in the following format: r g b
r,g,b = map(int,input().split()) num = r*100+g*10+b if (num%4=0): print("YES") else: print("NO")
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s903809300
Wrong Answer
p03693
Input is given from Standard Input in the following format: r g b
# ABC064A - RGB Cards r, g, b = list(map(int, input().rstrip().split())) print("YES" if (g * 10 + b % 4) else "NO")
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s667875314
Accepted
p03693
Input is given from Standard Input in the following format: r g b
R, G, B = input().split() print("YES" if int(R + G + B) % 4 == 0 else "NO")
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s013050046
Accepted
p03693
Input is given from Standard Input in the following format: r g b
rgb = int(input()[::2]) print("NO" if rgb % 4 else "YES")
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s269230077
Accepted
p03693
Input is given from Standard Input in the following format: r g b
print("YNEOS"[min(int(input().replace(" ", "")) % 4, 1) :: 2])
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s681278345
Accepted
p03693
Input is given from Standard Input in the following format: r g b
print("YES" if int(input().replace(" ", "")[1:]) % 4 == 0 else "NO")
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s098536187
Accepted
p03693
Input is given from Standard Input in the following format: r g b
print("YES" if eval(input().replace(" ", "")) % 4 == 0 else "NO")
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]
If the three-digit integer is a multiple of 4, print `YES` (case-sensitive); otherwise, print `NO`. * * *
s620006580
Accepted
p03693
Input is given from Standard Input in the following format: r g b
# coding: utf-8 print(["NO", "YES"][int(input().replace(" ", "")) % 4 == 0])
Statement AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
[{"input": "4 3 2", "output": "YES\n \n\n432 is a multiple of 4, and thus `YES` should be printed.\n\n* * *"}, {"input": "2 3 4", "output": "NO\n \n\n234 is not a multiple of 4, and thus `NO` should be printed."}]