output_description
stringlengths
15
956
submission_id
stringlengths
10
10
status
stringclasses
3 values
problem_id
stringlengths
6
6
input_description
stringlengths
9
2.55k
attempt
stringlengths
1
13.7k
problem_description
stringlengths
7
5.24k
samples
stringlengths
2
2.72k
Print the minimum total fare. * * *
s372281690
Accepted
p03399
Input is given from Standard Input in the following format: A B C D
x = lambda: min(int(input()), int(input())) print(x() + x())
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s051440374
Accepted
p03399
Input is given from Standard Input in the following format: A B C D
print(min([int(input()), int(input())]) + min([int(input()), int(input())]))
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s422202048
Wrong Answer
p03399
Input is given from Standard Input in the following format: A B C D
a = int(input()) a = int(input())
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s950184446
Wrong Answer
p03399
Input is given from Standard Input in the following format: A B C D
min(input(), input()) + min(input(), input())
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s374387786
Wrong Answer
p03399
Input is given from Standard Input in the following format: A B C D
min(int(input()), int(input())) + min(int(input()), int(input()))
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s465700681
Runtime Error
p03399
Input is given from Standard Input in the following format: A B C D
a,b,c,d=[int(input()) for_ in range(4)] print(min(a,b)+min(c,d))
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s168215598
Wrong Answer
p03399
Input is given from Standard Input in the following format: A B C D
price = [int(input()) for _ in range(4)] price.sort() print(price[0] + price[1])
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s077329945
Accepted
p03399
Input is given from Standard Input in the following format: A B C D
a = min(list(map(int, list(input() for _ in range(2))))) b = min(list(map(int, list(input() for _ in range(2))))) print(a + b)
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s345891294
Accepted
p03399
Input is given from Standard Input in the following format: A B C D
import math import sys def getinputdata(): # 配列初期化 array_result = [] data = input() array_result.append(data.split(" ")) flg = 1 try: while flg: data = input() array_temp = [] if data != "": array_result.append(data.split(" ")) flg = 1 else: flg = 0 finally: return array_result arr_data = getinputdata() a = int(arr_data[0][0]) b = int(arr_data[1][0]) c = int(arr_data[2][0]) d = int(arr_data[3][0]) print((a if a < b else b) + (c if c < d else d))
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s791592603
Accepted
p03399
Input is given from Standard Input in the following format: A B C D
print(eval("+min(s,s)".replace("s", "int(input())") * 2))
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s908205184
Runtime Error
p03399
Input is given from Standard Input in the following format: A B C D
a,b,c,d = map(int, input().split()) if a >= b && c >= d: print(a + c) else: print(b + d)
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s739221206
Accepted
p03399
Input is given from Standard Input in the following format: A B C D
li = list(int(input()) for i in range(4)) print(min(li[0], li[1]) + min(li[2], li[3]))
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s408315956
Accepted
p03399
Input is given from Standard Input in the following format: A B C D
price = [int(input()) for i in range(4)] print(min(price[0], price[1]) + min(price[2], price[3]))
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s114209432
Accepted
p03399
Input is given from Standard Input in the following format: A B C D
x = [int(input()) for _ in range(4)] res = min(x[0], x[1]) + min(x[2], x[3]) print(res)
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s451509626
Runtime Error
p03399
Input is given from Standard Input in the following format: A B C D
a=[] for i in range(4) a.append(int(input()) print(min(a[0],a[1])+min(a[2],a[3]))
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s590628837
Runtime Error
p03399
Input is given from Standard Input in the following format: A B C D
a=[] for i in range(4): a.append(int(input()) print(min(a[0],a[1])+min(a[2],a[3]))
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s630746427
Runtime Error
p03399
Input is given from Standard Input in the following format: A B C D
a = input() b = input() c = input() d = input() print(min(int(a),int(b)) + min(int(c),int(d))
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s486549024
Runtime Error
p03399
Input is given from Standard Input in the following format: A B C D
inputs = list(map(int, input().split())) print(min(inputs[:2]) + min(inputs[2:]))
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s228017527
Runtime Error
p03399
Input is given from Standard Input in the following format: A B C D
A=min([int(input()) for i in range(2)]) print(A+min([int(input()) for i in range(2)])
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s545396699
Runtime Error
p03399
Input is given from Standard Input in the following format: A B C D
n = [int,input() for i in range(1,5)] x = min(n[1], n[2])+ min(n[3], n[4]) print(x)
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s092386402
Runtime Error
p03399
Input is given from Standard Input in the following format: A B C D
a = int(input()) b = int(input()) c = int(input()) d = int(input()) print(min(a, b)=min(c, d))
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s466802171
Accepted
p03399
Input is given from Standard Input in the following format: A B C D
arr = [int(input()) for _ in range(4)] print((arr[0] if arr[0] < arr[1] else arr[1]) + (arr[2] if arr[2] < arr[3] else arr[3]))
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s423416329
Wrong Answer
p03399
Input is given from Standard Input in the following format: A B C D
A = input(int()) B = input(int()) C = input(int()) D = input(int()) train = [A, B] bus = [C, D] ans = min(train) + min(bus) print(ans)
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s034765701
Runtime Error
p03399
Input is given from Standard Input in the following format: A B C D
A = int(input()) B = int(input()) C = int(input()) D = int(input()) sum = 0 if A > B: sum += B elif : sum += A if C > D: sum += D elif : sum += C print(sum)
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s753023051
Runtime Error
p03399
Input is given from Standard Input in the following format: A B C D
a = int(input()) b = int(input()) c = int(input()) d = int(input()) ans = 0 if a > b: ans += a else: ans += b if c > d ans += c else: ans += d print(ans)
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s489809128
Runtime Error
p03399
Input is given from Standard Input in the following format: A B C D
# -*- coding: utf-8 -*- # 整数の入力 a = int(input()) b = int(input()) c = int(input()) d = int(input()) # 出力 if a>b : elif c>d : print("{}".format(a+c)) else : print("{}".format(a+d)) else : elif c>d : print("{}".format(b+c)) else print("{}".format(b+d))
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s401138254
Runtime Error
p03399
Input is given from Standard Input in the following format: A B C D
A = int(input()) B = int(input()) C = int(input()) D = int(input()) if( A < B): if(C < D): print(A + C) else: print(A + D) else: if(C < D) print(B + C) else: print(B + D)
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s534554802
Runtime Error
p03399
Input is given from Standard Input in the following format: A B C D
a,b,c,d = map(int,input().split()) ans = 0 if a > b: ans += a else: ans += b if c > d ans += c else: ans += d print(ans)
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s128539367
Runtime Error
p03399
Input is given from Standard Input in the following format: A B C D
A = int(input()) B = int(input()) C = int(input()) D = int(input()) E = 0 if A > B: E += B elif : E += A if C > D: E += D elif : E += C print(E)
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s242613635
Runtime Error
p03399
Input is given from Standard Input in the following format: A B C D
input_train_price1=input("電車の通常の切符の料金を入力:") input_train_price2=input("電車の乗り放題切符の料金を入力":) input_bus_price1=input("バスの通常の切符の料金を入力:") input_bus_price2=input("バスの乗り放題切符の料金を入力":) train_price1=int(input_train_price1) train_price2=int(input_train_price2) bus_price1=int(input_bus_price1) bus_price2=int(input_bus_price2) train_price=["train_price1,train_price2"] bus_price=["bus_price1,bus_price2"] best_train_price=min(train_price) best_bus_price=min(bus_price) print("運賃の合計の最小値は"+best_train_price+best_bus_price+"円です。")
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s751952738
Runtime Error
p03399
Input is given from Standard Input in the following format: A B C D
a,b,c,d = map(int,input().split()) ans = 0 if a > b: ans += a else: ans += b if c > d ans += c else: ans += d print(ans)
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s528427323
Accepted
p03399
Input is given from Standard Input in the following format: A B C D
n = [int(input()) for i in range(1, 5)] print(min(n[:2]) + min(n[2:]))
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s778883129
Accepted
p03399
Input is given from Standard Input in the following format: A B C D
a, b, c, d = (int(input()) for i in [1] * 4) fare = min(a, b) + min(c, d) print(fare)
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s545311364
Runtime Error
p03399
Input is given from Standard Input in the following format: A B C D
l = [int(input() for i in range(4)] print(min(l[0],l[1])+min(l[2],l[3]))
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s249341288
Runtime Error
p03399
Input is given from Standard Input in the following format: A B C D
l=[int(input())for _ in range(4)] print(min((l[0],l[1]),(l[2],l[3]))
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s239472801
Runtime Error
p03399
Input is given from Standard Input in the following format: A B C D
print(min(int(input(),int(input()))+min(int(input(),int(input()))))
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s121842912
Runtime Error
p03399
Input is given from Standard Input in the following format: A B C D
a,b,c,d=input() for i in range(4) print(max(a,b)+max(c,d))
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s532266109
Runtime Error
p03399
Input is given from Standard Input in the following format: A B C D
a, b, c = map(int, input().split()) print("YNeos"[a + b < c :: 2])
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s593058202
Runtime Error
p03399
Input is given from Standard Input in the following format: A B C D
a,b,c,d = [int(input()) for_ range(4)] print(min(a,b)+min(c,d))
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s260086136
Runtime Error
p03399
Input is given from Standard Input in the following format: A B C D
a, b, c, d = [int(input()), for _ in range(4)] print(min(a,b)+min(c,d))
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s226640220
Runtime Error
p03399
Input is given from Standard Input in the following format: A B C D
*a=list(map(int, input()); print(a)
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s038915629
Runtime Error
p03399
Input is given from Standard Input in the following format: A B C D
a = list(map(int, input().split())) print(min(a[:1]) + min(a[2:]))
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s065631567
Runtime Error
p03399
Input is given from Standard Input in the following format: A B C D
N = list(map(int, input().split())) min_train = min(N[0], N[1]) min_bus = min(N[2], N[3]) print(min_train + min_bus)
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s315818960
Accepted
p03399
Input is given from Standard Input in the following format: A B C D
a = list(int(input()) for _ in range(4)) print(min([a[0] + a[2], a[1] + a[2], a[0] + a[3], a[1] + a[3]]))
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s964210531
Wrong Answer
p03399
Input is given from Standard Input in the following format: A B C D
print(int(min([input() for i in range(2)])) + int(min([input() for i in range(2)])))
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s173337105
Accepted
p03399
Input is given from Standard Input in the following format: A B C D
x = [int(input()) for i in range(4)] print(min(x[0], x[1]) + min(x[2], x[3]))
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s800894729
Accepted
p03399
Input is given from Standard Input in the following format: A B C D
ab = [int(input()) for i in range(2)] cd = [int(input()) for i in range(2)] print(min(ab) + min(cd))
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s475672534
Accepted
p03399
Input is given from Standard Input in the following format: A B C D
V = [int(input()) for i in range(4)] print(min(V[0], V[1]) + min(V[2], V[3]))
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s895791671
Accepted
p03399
Input is given from Standard Input in the following format: A B C D
cost = [int(input()) for _ in range(4)] print(min(cost[0] + cost[2], cost[0] + cost[3], cost[1] + cost[2], cost[1] + cost[3]))
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s435003530
Accepted
p03399
Input is given from Standard Input in the following format: A B C D
##Just for prctice ans1 = 1000 ans2 = 1000 for i in range(2): ans1 = min(ans1, int(input())) for i in range(2): ans2 = min(ans2, int(input())) print(ans1 + ans2) """ 600 300 220 420 520 555 555 400 200 755 549 817 715 603 1152 """
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s560003503
Runtime Error
p03399
Input is given from Standard Input in the following format: A B C D
a,b,c,d = map(int,input().split(" ") count = 0 if a >= b: count += b else: count += a if c >= d: count += d else: count += c print(count)
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s560204425
Accepted
p03399
Input is given from Standard Input in the following format: A B C D
print(min([int(input()) for _ in [0, 1]]) + min([int(input()) for _ in [0, 1]]))
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s087689816
Accepted
p03399
Input is given from Standard Input in the following format: A B C D
A = [int(input()) for _ in range(4)] print(min(A[:2]) + min(A[2:4]))
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s421772199
Runtime Error
p03399
Input is given from Standard Input in the following format: A B C D
a,b,c,d = [int,input() for _ in range(4)] print(min(a+b)+min(c+d))
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s555276996
Runtime Error
p03399
Input is given from Standard Input in the following format: A B C D
A,B,C,D = [int(input) for _ in range(4)] print(min(A,B)+min(C,D)
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s995502219
Runtime Error
p03399
Input is given from Standard Input in the following format: A B C D
A = [int(input()) for i in range(4)] print(min(A[0] + A[1]) + min(A[2] + A[3]))
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s095563892
Wrong Answer
p03399
Input is given from Standard Input in the following format: A B C D
print(max(int(input()), int(input())) + max(int(input()), int(input())))
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s752707075
Runtime Error
p03399
Input is given from Standard Input in the following format: A B C D
print(min(int(input(), int(input()))) + min(int(input(), int(input()))))
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print the minimum total fare. * * *
s651148660
Runtime Error
p03399
Input is given from Standard Input in the following format: A B C D
a, s, d, f = map(int, input().split()) print(min(a, s) + min(d, f))
Statement You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
[{"input": "600\n 300\n 220\n 420", "output": "520\n \n\nThe train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you\nbuy an unlimited ticket. Thus, the optimal choice for trains is to buy an\nunlimited ticket for 300 yen. On the other hand, the optimal choice for buses\nis to buy ordinary tickets for 220 yen.\n\nTherefore, the minimum total fare is 300 + 220 = 520 yen.\n\n* * *"}, {"input": "555\n 555\n 400\n 200", "output": "755\n \n\n* * *"}, {"input": "549\n 817\n 715\n 603", "output": "1152"}]
Print N lines. The i-th line (1 \leq i \leq N) should contain the maximum value among the N-1 elements other than A_i in the sequence. * * *
s099718711
Wrong Answer
p02971
Input is given from Standard Input in the following format: N A_1 : A_N
N = int(input()) A = [input() for i in range(N)] m1, m2 = max(A[0], A[1]), min(A[0], A[1]) for i in range(2, N): if m1 < A[i]: m1, m2 = A[i], m1 elif m2 < A[i]: m2 = A[i] print("\n".join(map(str, [m1 if i != m1 else m2 for i in A])))
Statement You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question: * Find the maximum value among the N-1 elements other than A_i in the sequence.
[{"input": "3\n 1\n 4\n 3", "output": "4\n 3\n 4\n \n\n * The maximum value among the two elements other than A_1, that is, A_2 = 4 and A_3 = 3, is 4.\n * The maximum value among the two elements other than A_2, that is, A_1 = 1 and A_3 = 3, is 3.\n * The maximum value among the two elements other than A_3, that is, A_1 = 1 and A_2 = 4, is 4.\n\n* * *"}, {"input": "2\n 5\n 5", "output": "5\n 5"}]
Print N lines. The i-th line (1 \leq i \leq N) should contain the maximum value among the N-1 elements other than A_i in the sequence. * * *
s055707494
Runtime Error
p02971
Input is given from Standard Input in the following format: N A_1 : A_N
"""長さNの整数A1,A2,...,ANが与えられる。1以上N以下の各整数iに対し、数列中のAiを除くN-1個の要素のうち、最大の値を求める N (int): 数列の個数 Nは整数 2≦N≦200000 Ai...N list(int): 数列中の各整数 整数 1≦Ai≦200000 考え方として、最大の数値のインデックスが指定された場合は2番目に大きな値を、 それ以外は最大の数値を出力するようにすることで、数列全体を調査するコストを最小に減らすことができる。 Raises: ValueError: 数列の個数に制約外の値が指定された場合 """ from typing import List, Any, Iterable SEQUENCE_LEN_MIN = 2 SEQUENCE_LEN_MAX = 200000 NUMERIC_MIN = 1 NUMERIC_MAX = 200000 class NumericInfo: """数列中の値とその値のインデックスを管理する""" def __init__(self): # 初期状態は言語仕様・制約上入力されない値を指定する self.index = -1 self.value = NUMERIC_MIN - 1 def update(self, idx: int, val: int): self.index = idx self.value = val def copy(self, info: Any): self.update(info.index, info.value) class SequenceProcessor: def __init__(self, sequence: List[int]): self.sequence_length = len(sequence) self.first_largest_num_info = NumericInfo() self.second_largest_num_info = NumericInfo() self._process(sequence) def _process(self, sequence: List[int]): """引数で渡される数列をもとに、後の処理で使うインスタンス変数を初期化する sequence_length (int): 配列の個数 first_largest_num_info (NumericInfo): 最大値のインデックスと値 second_largest_num_info (NumericInfo): 2番目に大きな値のインデックスと値 Args: sequence (List[int]): 数列 """ for i, num in enumerate(sequence): if self.first_largest_num_info.value < num: self.second_largest_num_info.copy(self.first_largest_num_info) self.first_largest_num_info.update(i, num) elif self.second_largest_num_info.value < num: self.second_largest_num_info.update(i, num) def _max_value(self, idx: int) -> int: """指定されたインデックスの値を除く、数列中の最大値を求める Args: idx (int): 指定されたインデックス """ if idx == self.first_largest_num_info.index: return self.second_largest_num_info.value else: return self.first_largest_num_info.value def all_max_value(self) -> Iterable[int]: """数列全てのインデックスに対して、インデックスの値を除く、数列中の最大値を求める""" for i in range(self.sequence_length): yield self._max_value(i) def _validate_sequence_length(s: str): """入力値(数列の個数)が制約通りか検証する Args: s (str): 数列の個数が制約通りか検証する文字列 制約1. 整数であること 制約2. 2以上200000以下であること Raises: ValueError: 制約外の値が渡された場合 """ if not s.isdigit(): raise ValueError("数列の個数の入力値が整数ではありません") r = int(s) if not SEQUENCE_LEN_MIN <= r <= SEQUENCE_LEN_MAX: raise ValueError( f"数列の個数は{SEQUENCE_LEN_MIN}から" f"{SEQUENCE_LEN_MAX}の間で指定してください" ) def get_sequence_length_from_stdin() -> int: """数列の個数を標準入力から取得する Returns: int: 数列の個数 """ s = input() s = s.strip() _validate_sequence_length(s) return int(s) def _validate_numeric(s): """入力値(数値)が制約通りか検証する Args: s (str): 数値が制約通りか検証する文字列 制約1. 整数であること 制約2. 1以上200000以下であること Raises: ValueError: 制約外の値が渡された場合 """ if not s.isdigit(): raise ValueError("数値の入力値が整数ではありません") r = int(s) if not NUMERIC_MIN <= r <= NUMERIC_MAX: raise ValueError(f"数値は{NUMERIC_MIN}から{NUMERIC_MAX}の間で指定してください") def get_sequence_from_stdin(length: int) -> List[int]: """標準入力から数列を作成する Args: length (int): 作成する数列の個数 Returns: List[int]: 数列 """ result = [] for i in range(1, length + 1): while True: n = input() try: _validate_numeric(n) result.append(int(n)) break except ValueError: print("入力値に誤りがあります。再入力してください。") continue return result def main(): seq_len = get_sequence_length_from_stdin() sequence = get_sequence_from_stdin(seq_len) seq_processor = SequenceProcessor(sequence) for num in seq_processor.all_max_value(): print(num) if __name__ == "__main__": main()
Statement You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question: * Find the maximum value among the N-1 elements other than A_i in the sequence.
[{"input": "3\n 1\n 4\n 3", "output": "4\n 3\n 4\n \n\n * The maximum value among the two elements other than A_1, that is, A_2 = 4 and A_3 = 3, is 4.\n * The maximum value among the two elements other than A_2, that is, A_1 = 1 and A_3 = 3, is 3.\n * The maximum value among the two elements other than A_3, that is, A_1 = 1 and A_2 = 4, is 4.\n\n* * *"}, {"input": "2\n 5\n 5", "output": "5\n 5"}]
Print N lines. The i-th line (1 \leq i \leq N) should contain the maximum value among the N-1 elements other than A_i in the sequence. * * *
s371682456
Runtime Error
p02971
Input is given from Standard Input in the following format: N A_1 : A_N
import glob import numpy as np import collections # 問題ごとのディレクトリのトップからの相対パス REL_PATH = "ABC\\134\\C" # テスト用ファイル置き場のトップ TOP_PATH = "C:\\AtCoder" class Common: problem = [] index = 0 def __init__(self, rel_path): self.rel_path = rel_path def initialize(self, path): file = open(path) self.problem = file.readlines() self.index = 0 return def input_data(self): try: IS_TEST self.index += 1 return self.problem[self.index - 1] except NameError: return input() def resolve(self): pass def exec_resolve(self): try: IS_TEST for path in glob.glob(TOP_PATH + "\\" + self.rel_path + "/*.txt"): print("Test: " + path) self.initialize(path) self.resolve() print("\n\n") except NameError: self.resolve() class C(Common): def resolve(self): seq_len = int(self.input_data()) seq = np.array([0 for i in range(seq_len)]) for i in range(seq_len): seq[i] = int(self.input_data()) max_num = np.max(seq) times = collections.Counter(seq)[max_num] if times >= 2: for i in range(seq_len): print(str(seq[i])) else: for i in range(seq_len): if seq[i] != max_num: print(str(max_num)) else: print( np.max(seq[0:i]) if np.max(seq[0:i]) > np.max(seq[i + 1 : seq_len]) else np.max(seq[i + 1 : seq_len]) ) solver = C(REL_PATH) solver.exec_resolve()
Statement You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question: * Find the maximum value among the N-1 elements other than A_i in the sequence.
[{"input": "3\n 1\n 4\n 3", "output": "4\n 3\n 4\n \n\n * The maximum value among the two elements other than A_1, that is, A_2 = 4 and A_3 = 3, is 4.\n * The maximum value among the two elements other than A_2, that is, A_1 = 1 and A_3 = 3, is 3.\n * The maximum value among the two elements other than A_3, that is, A_1 = 1 and A_2 = 4, is 4.\n\n* * *"}, {"input": "2\n 5\n 5", "output": "5\n 5"}]
Print N lines. The i-th line (1 \leq i \leq N) should contain the maximum value among the N-1 elements other than A_i in the sequence. * * *
s342403712
Runtime Error
p02971
Input is given from Standard Input in the following format: N A_1 : A_N
loop = int(input()) nums = [int(input()) for i in range(loop)] for i in range(0, loop): subNums = nums del subNums[i] print(max(subNums))
Statement You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question: * Find the maximum value among the N-1 elements other than A_i in the sequence.
[{"input": "3\n 1\n 4\n 3", "output": "4\n 3\n 4\n \n\n * The maximum value among the two elements other than A_1, that is, A_2 = 4 and A_3 = 3, is 4.\n * The maximum value among the two elements other than A_2, that is, A_1 = 1 and A_3 = 3, is 3.\n * The maximum value among the two elements other than A_3, that is, A_1 = 1 and A_2 = 4, is 4.\n\n* * *"}, {"input": "2\n 5\n 5", "output": "5\n 5"}]
Print N lines. The i-th line (1 \leq i \leq N) should contain the maximum value among the N-1 elements other than A_i in the sequence. * * *
s342375445
Runtime Error
p02971
Input is given from Standard Input in the following format: N A_1 : A_N
n = int(input()) t = [int(input()) for i in range(n)] for i in range(len(t)): s = t gomi = s.pop(i) print(max(s))
Statement You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question: * Find the maximum value among the N-1 elements other than A_i in the sequence.
[{"input": "3\n 1\n 4\n 3", "output": "4\n 3\n 4\n \n\n * The maximum value among the two elements other than A_1, that is, A_2 = 4 and A_3 = 3, is 4.\n * The maximum value among the two elements other than A_2, that is, A_1 = 1 and A_3 = 3, is 3.\n * The maximum value among the two elements other than A_3, that is, A_1 = 1 and A_2 = 4, is 4.\n\n* * *"}, {"input": "2\n 5\n 5", "output": "5\n 5"}]
Print N lines. The i-th line (1 \leq i \leq N) should contain the maximum value among the N-1 elements other than A_i in the sequence. * * *
s089676834
Wrong Answer
p02971
Input is given from Standard Input in the following format: N A_1 : A_N
def maximum(n, lista): for i in range(len(lista) - 1, -1, -1): if lista[i] != n: return lista[i] return n casos = int(input()) numeros = [] for i in range(casos): numeros.append(int(input())) ordenados = numeros[:] ordenados.sort() for i in range(casos): print(maximum(numeros[i], ordenados))
Statement You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question: * Find the maximum value among the N-1 elements other than A_i in the sequence.
[{"input": "3\n 1\n 4\n 3", "output": "4\n 3\n 4\n \n\n * The maximum value among the two elements other than A_1, that is, A_2 = 4 and A_3 = 3, is 4.\n * The maximum value among the two elements other than A_2, that is, A_1 = 1 and A_3 = 3, is 3.\n * The maximum value among the two elements other than A_3, that is, A_1 = 1 and A_2 = 4, is 4.\n\n* * *"}, {"input": "2\n 5\n 5", "output": "5\n 5"}]
Print N lines. The i-th line (1 \leq i \leq N) should contain the maximum value among the N-1 elements other than A_i in the sequence. * * *
s268598092
Accepted
p02971
Input is given from Standard Input in the following format: N A_1 : A_N
a = [int(input()) for i in range(int(input()))] a_s = sorted(a)[::-1] mx, submx = a_s[0], a_s[1] cnt = a.count(mx) for n in a: if n != mx: print(mx) elif cnt > 1: print(mx) else: print(submx)
Statement You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question: * Find the maximum value among the N-1 elements other than A_i in the sequence.
[{"input": "3\n 1\n 4\n 3", "output": "4\n 3\n 4\n \n\n * The maximum value among the two elements other than A_1, that is, A_2 = 4 and A_3 = 3, is 4.\n * The maximum value among the two elements other than A_2, that is, A_1 = 1 and A_3 = 3, is 3.\n * The maximum value among the two elements other than A_3, that is, A_1 = 1 and A_2 = 4, is 4.\n\n* * *"}, {"input": "2\n 5\n 5", "output": "5\n 5"}]
Print N lines. The i-th line (1 \leq i \leq N) should contain the maximum value among the N-1 elements other than A_i in the sequence. * * *
s302897770
Accepted
p02971
Input is given from Standard Input in the following format: N A_1 : A_N
n = int(input()) al = [int(input()) for i in range(n)] m1, m2 = 0, 0 for a in al: if m1 < a: m1 = a elif m2 < a: m2 = a for a in al: print(m2) if m1 == a else print(m1)
Statement You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question: * Find the maximum value among the N-1 elements other than A_i in the sequence.
[{"input": "3\n 1\n 4\n 3", "output": "4\n 3\n 4\n \n\n * The maximum value among the two elements other than A_1, that is, A_2 = 4 and A_3 = 3, is 4.\n * The maximum value among the two elements other than A_2, that is, A_1 = 1 and A_3 = 3, is 3.\n * The maximum value among the two elements other than A_3, that is, A_1 = 1 and A_2 = 4, is 4.\n\n* * *"}, {"input": "2\n 5\n 5", "output": "5\n 5"}]
Print the minimum total weight of the edges in such a cycle. * * *
s089868515
Runtime Error
p03233
Input is given from Standard Input in the following format: N A_1 B_1 A_2 B_2 : A_N B_N
4 1 5 2 6 3 7 4 8
Statement We have a directed weighted graph with N vertices. Each vertex has two integers written on it, and the integers written on Vertex i are A_i and B_i. In this graph, there is an edge from Vertex x to Vertex y for all pairs 1 \leq x,y \leq N, and its weight is {\rm min}(A_x,B_y). We will consider a directed cycle in this graph that visits every vertex exactly once. Find the minimum total weight of the edges in such a cycle.
[{"input": "3\n 1 5\n 4 2\n 6 3", "output": "7\n \n\nConsider the cycle 1\u21923\u21922\u21921. The weights of those edges are {\\rm\nmin}(A_1,B_3)=1, {\\rm min}(A_3,B_2)=2 and {\\rm min}(A_2,B_1)=4, for a total of\n7. As there is no cycle with a total weight of less than 7, the answer is 7.\n\n* * *"}, {"input": "4\n 1 5\n 2 6\n 3 7\n 4 8", "output": "10\n \n\n* * *"}, {"input": "6\n 19 92\n 64 64\n 78 48\n 57 33\n 73 6\n 95 73", "output": "227"}]
Print the minimum total weight of the edges in such a cycle. * * *
s496373192
Wrong Answer
p03233
Input is given from Standard Input in the following format: N A_1 B_1 A_2 B_2 : A_N B_N
n = int(input()) m = [] for i in range(n): m += input().split() a = list(map(int, m)) ans = 0 a.sort() print(sum(a[:n]))
Statement We have a directed weighted graph with N vertices. Each vertex has two integers written on it, and the integers written on Vertex i are A_i and B_i. In this graph, there is an edge from Vertex x to Vertex y for all pairs 1 \leq x,y \leq N, and its weight is {\rm min}(A_x,B_y). We will consider a directed cycle in this graph that visits every vertex exactly once. Find the minimum total weight of the edges in such a cycle.
[{"input": "3\n 1 5\n 4 2\n 6 3", "output": "7\n \n\nConsider the cycle 1\u21923\u21922\u21921. The weights of those edges are {\\rm\nmin}(A_1,B_3)=1, {\\rm min}(A_3,B_2)=2 and {\\rm min}(A_2,B_1)=4, for a total of\n7. As there is no cycle with a total weight of less than 7, the answer is 7.\n\n* * *"}, {"input": "4\n 1 5\n 2 6\n 3 7\n 4 8", "output": "10\n \n\n* * *"}, {"input": "6\n 19 92\n 64 64\n 78 48\n 57 33\n 73 6\n 95 73", "output": "227"}]
Print the minimum total weight of the edges in such a cycle. * * *
s015349783
Wrong Answer
p03233
Input is given from Standard Input in the following format: N A_1 B_1 A_2 B_2 : A_N B_N
from sys import exit, setrecursionlimit, stderr from functools import reduce from itertools import * from collections import defaultdict, Counter from bisect import bisect def read(): return int(input()) def reads(): return [int(x) for x in input().split()] N = read() A = [0] * N B = [0] * N for i in range(N): A[i], B[i] = reads() s = sorted(A + B) print(sum(s[:N]))
Statement We have a directed weighted graph with N vertices. Each vertex has two integers written on it, and the integers written on Vertex i are A_i and B_i. In this graph, there is an edge from Vertex x to Vertex y for all pairs 1 \leq x,y \leq N, and its weight is {\rm min}(A_x,B_y). We will consider a directed cycle in this graph that visits every vertex exactly once. Find the minimum total weight of the edges in such a cycle.
[{"input": "3\n 1 5\n 4 2\n 6 3", "output": "7\n \n\nConsider the cycle 1\u21923\u21922\u21921. The weights of those edges are {\\rm\nmin}(A_1,B_3)=1, {\\rm min}(A_3,B_2)=2 and {\\rm min}(A_2,B_1)=4, for a total of\n7. As there is no cycle with a total weight of less than 7, the answer is 7.\n\n* * *"}, {"input": "4\n 1 5\n 2 6\n 3 7\n 4 8", "output": "10\n \n\n* * *"}, {"input": "6\n 19 92\n 64 64\n 78 48\n 57 33\n 73 6\n 95 73", "output": "227"}]
Print the minimum total weight of the edges in such a cycle. * * *
s979027121
Wrong Answer
p03233
Input is given from Standard Input in the following format: N A_1 B_1 A_2 B_2 : A_N B_N
n = int(input()) lisa = [] lisb = [] lia = [] lib = [] for i in range(n): a, b = map(int, input().split()) lisa.append(a) lisb.append(b) lia = sorted(lisa) lib = sorted(lisb, reverse=True) ans = 0 key = [int(i) for i in range(n)] for i in range(n): lib.sort(reverse=True) if key[lisa.index(lia[i])] != lisb.index(lib[0]) and key[ lisa.index(lia[i]) ] != lisa.index(lia[0]): key[lisa.index(lia[i])] = lisb.index(lib[0]) ans += min(lia[i], lib[0]) lib[0] = -1 elif key[lisa.index(lia[i])] != lisb.index(lib[1]) and key[ lisa.index(lia[i]) ] != lisa.index(lia[1]): key[lisa.index(lia[i])] = lisb.index(lib[1]) ans += min(lia[i], lib[1]) lib[1] = -1 else: key[lisa.index(lia[i])] = lisb.index(lib[2]) ans += min(lia[i], lib[2]) lib[1] = -1 print(ans)
Statement We have a directed weighted graph with N vertices. Each vertex has two integers written on it, and the integers written on Vertex i are A_i and B_i. In this graph, there is an edge from Vertex x to Vertex y for all pairs 1 \leq x,y \leq N, and its weight is {\rm min}(A_x,B_y). We will consider a directed cycle in this graph that visits every vertex exactly once. Find the minimum total weight of the edges in such a cycle.
[{"input": "3\n 1 5\n 4 2\n 6 3", "output": "7\n \n\nConsider the cycle 1\u21923\u21922\u21921. The weights of those edges are {\\rm\nmin}(A_1,B_3)=1, {\\rm min}(A_3,B_2)=2 and {\\rm min}(A_2,B_1)=4, for a total of\n7. As there is no cycle with a total weight of less than 7, the answer is 7.\n\n* * *"}, {"input": "4\n 1 5\n 2 6\n 3 7\n 4 8", "output": "10\n \n\n* * *"}, {"input": "6\n 19 92\n 64 64\n 78 48\n 57 33\n 73 6\n 95 73", "output": "227"}]
Print the minimum total weight of the edges in such a cycle. * * *
s426801412
Accepted
p03233
Input is given from Standard Input in the following format: N A_1 B_1 A_2 B_2 : A_N B_N
def mincos(n, ab): aball = [] aball += [(ab[i][0], i + 1, "a") for i in range(n)] aball += [(ab[i][1], i + 1, "b") for i in range(n)] aball.sort() ans1 = sum([i[0] for i in aball[:n]]) hen = aball[n][0] hen2 = aball[n + 1][0] d = set() t = None hantei = True for i, c, mab in aball[:n]: if t != None and t != mab: hantei = False if c in d: print(ans1) exit() d.add(c) t = mab if hantei: print(ans1) exit() ans2 = [] for i, c, aorb in aball[:n]: if aball[n][1] != c: ans2 += [ans1 - i + hen] else: ans2 += [ans1 - i + hen2] print(min(ans2)) exit() n = int(input()) print(mincos(n, [list(map(int, input().split())) for i in range(n)]))
Statement We have a directed weighted graph with N vertices. Each vertex has two integers written on it, and the integers written on Vertex i are A_i and B_i. In this graph, there is an edge from Vertex x to Vertex y for all pairs 1 \leq x,y \leq N, and its weight is {\rm min}(A_x,B_y). We will consider a directed cycle in this graph that visits every vertex exactly once. Find the minimum total weight of the edges in such a cycle.
[{"input": "3\n 1 5\n 4 2\n 6 3", "output": "7\n \n\nConsider the cycle 1\u21923\u21922\u21921. The weights of those edges are {\\rm\nmin}(A_1,B_3)=1, {\\rm min}(A_3,B_2)=2 and {\\rm min}(A_2,B_1)=4, for a total of\n7. As there is no cycle with a total weight of less than 7, the answer is 7.\n\n* * *"}, {"input": "4\n 1 5\n 2 6\n 3 7\n 4 8", "output": "10\n \n\n* * *"}, {"input": "6\n 19 92\n 64 64\n 78 48\n 57 33\n 73 6\n 95 73", "output": "227"}]
Print the minimum total weight of the edges in such a cycle. * * *
s219255093
Wrong Answer
p03233
Input is given from Standard Input in the following format: N A_1 B_1 A_2 B_2 : A_N B_N
mod = 1000000007 eps = 10**-9 def main(): import sys from heapq import heappush, heappop, heapify input = sys.stdin.buffer.readline N = int(input()) L = [] R = [] LR = [] for i in range(N): a, b = map(int, input().split()) L.append((-a, i)) R.append((b, i)) LR.append((a, b)) heapify(L) heapify(R) used = set() ans = 0 for new_id in range(N, N * 2 - 1): while True: l_, id_L = heappop(L) l = -l_ if id_L in used: continue else: break while True: r, id_R = heappop(R) if id_R in used: continue else: break if id_L == id_R: while True: l_2, id_L2 = heappop(L) l2 = -l_2 if id_L2 in used: continue else: heappush(L, (l_, id_L)) l = l2 id_L = id_L2 break used.add(id_L) used.add(id_R) ans += min(LR[id_L][0], LR[id_R][1]) LR.append((LR[id_R][0], LR[id_L][1])) heappush(L, (-LR[id_R][0], new_id)) heappush(R, (LR[id_L][1], new_id)) ans += min(LR[-1][0], LR[-1][1]) print(ans) if __name__ == "__main__": main()
Statement We have a directed weighted graph with N vertices. Each vertex has two integers written on it, and the integers written on Vertex i are A_i and B_i. In this graph, there is an edge from Vertex x to Vertex y for all pairs 1 \leq x,y \leq N, and its weight is {\rm min}(A_x,B_y). We will consider a directed cycle in this graph that visits every vertex exactly once. Find the minimum total weight of the edges in such a cycle.
[{"input": "3\n 1 5\n 4 2\n 6 3", "output": "7\n \n\nConsider the cycle 1\u21923\u21922\u21921. The weights of those edges are {\\rm\nmin}(A_1,B_3)=1, {\\rm min}(A_3,B_2)=2 and {\\rm min}(A_2,B_1)=4, for a total of\n7. As there is no cycle with a total weight of less than 7, the answer is 7.\n\n* * *"}, {"input": "4\n 1 5\n 2 6\n 3 7\n 4 8", "output": "10\n \n\n* * *"}, {"input": "6\n 19 92\n 64 64\n 78 48\n 57 33\n 73 6\n 95 73", "output": "227"}]
Print the minimum total weight of the edges in such a cycle. * * *
s534977290
Wrong Answer
p03233
Input is given from Standard Input in the following format: N A_1 B_1 A_2 B_2 : A_N B_N
# -*- encoding: utf-8 -*- SCORE_NONE = -1 class Life(object): """个体类""" def __init__(self, aGene=None): self.gene = aGene self.score = SCORE_NONE import random class GA(object): """遗传算法类""" def __init__( self, aCrossRate, aMutationRage, aLifeCount, aGeneLenght, aMatchFun=lambda life: 1, ): self.croessRate = aCrossRate self.mutationRate = aMutationRage self.lifeCount = aLifeCount self.geneLenght = aGeneLenght self.matchFun = aMatchFun # 适配函数 self.lives = [] # 种群 self.best = None # 保存这一代中最好的个体 self.generation = 1 self.crossCount = 0 self.mutationCount = 0 self.bounds = 0.0 # 适配值之和,用于选择是计算概率 self.initPopulation() def initPopulation(self): """初始化种群""" self.lives = [] for i in range(self.lifeCount): gene = [x for x in range(self.geneLenght)] random.shuffle(gene) life = Life(gene) self.lives.append(life) def judge(self): """评估,计算每一个个体的适配值""" self.bounds = 0.0 self.best = self.lives[0] for life in self.lives: life.score = self.matchFun(life) self.bounds += life.score if self.best.score < life.score: self.best = life def cross(self, parent1, parent2): """交叉""" index1 = random.randint(0, self.geneLenght - 1) index2 = random.randint(index1, self.geneLenght - 1) tempGene = parent2.gene[index1:index2] # 交叉的基因片段 newGene = [] p1len = 0 for g in parent1.gene: if p1len == index1: newGene.extend(tempGene) # 插入基因片段 p1len += 1 if g not in tempGene: newGene.append(g) p1len += 1 self.crossCount += 1 return newGene def mutation(self, gene): """突变""" index1 = random.randint(0, self.geneLenght - 1) index2 = random.randint(0, self.geneLenght - 1) newGene = gene[:] # 产生一个新的基因序列,以免变异的时候影响父种群 newGene[index1], newGene[index2] = newGene[index2], newGene[index1] self.mutationCount += 1 return newGene def getOne(self): """选择一个个体""" r = random.uniform(0, self.bounds) for life in self.lives: r -= life.score if r <= 0: return life raise Exception("选择错误", self.bounds) def newChild(self): """产生新后的""" parent1 = self.getOne() rate = random.random() # 按概率交叉 if rate < self.croessRate: # 交叉 parent2 = self.getOne() gene = self.cross(parent1, parent2) else: gene = parent1.gene # 按概率突变 rate = random.random() if rate < self.mutationRate: gene = self.mutation(gene) return Life(gene) def next(self): """产生下一代""" self.judge() newLives = [] newLives.append(self.best) # 把最好的个体加入下一代 while len(newLives) < self.lifeCount: newLives.append(self.newChild()) self.lives = newLives self.generation += 1 import math class TSP(object): def __init__( self, aLifeCount=100, ): self.initCitys() self.lifeCount = aLifeCount self.ga = GA( aCrossRate=0.7, aMutationRage=0.02, aLifeCount=self.lifeCount, aGeneLenght=len(self.citys), aMatchFun=self.matchFun(), ) def initCitys(self): self.citys = [] n = int(input()) for i in range(0, n): a, b = map(int, input().split()) self.citys.append((a, b)) def distance(self, order): distance = 0 for i in range(-1, len(self.citys) - 1): index1, index2 = order[i], order[i + 1] city1, city2 = self.citys[index1], self.citys[index2] distance += min(city1[0], city2[1]) """ R = 6371.004 Pi = math.pi LatA = city1[1] LatB = city2[1] MLonA = city1[0] MLonB = city2[0] C = math.sin(LatA*Pi / 180) * math.sin(LatB * Pi / 180) + math.cos(LatA * Pi / 180) * math.cos(LatB * Pi / 180) * math.cos((MLonA - MLonB) * Pi / 180) D = R * math.acos(C) * Pi / 100 distance += D """ return distance def matchFun(self): return lambda life: 1.0 / self.distance(life.gene) def run(self, n=0): while n > 0: self.ga.next() distance = self.distance(self.ga.best.gene) # print (("%d : %f") % (self.ga.generation, distance)) n -= 1 print(distance) def main(): tsp = TSP() tsp.run(10) if __name__ == "__main__": main()
Statement We have a directed weighted graph with N vertices. Each vertex has two integers written on it, and the integers written on Vertex i are A_i and B_i. In this graph, there is an edge from Vertex x to Vertex y for all pairs 1 \leq x,y \leq N, and its weight is {\rm min}(A_x,B_y). We will consider a directed cycle in this graph that visits every vertex exactly once. Find the minimum total weight of the edges in such a cycle.
[{"input": "3\n 1 5\n 4 2\n 6 3", "output": "7\n \n\nConsider the cycle 1\u21923\u21922\u21921. The weights of those edges are {\\rm\nmin}(A_1,B_3)=1, {\\rm min}(A_3,B_2)=2 and {\\rm min}(A_2,B_1)=4, for a total of\n7. As there is no cycle with a total weight of less than 7, the answer is 7.\n\n* * *"}, {"input": "4\n 1 5\n 2 6\n 3 7\n 4 8", "output": "10\n \n\n* * *"}, {"input": "6\n 19 92\n 64 64\n 78 48\n 57 33\n 73 6\n 95 73", "output": "227"}]
Print the minimum total weight of the edges in such a cycle. * * *
s413726774
Wrong Answer
p03233
Input is given from Standard Input in the following format: N A_1 B_1 A_2 B_2 : A_N B_N
n = int(input()) li = [] for i in range(n): li.append(list(map(int, input().split()))) li = sorted(li, key=lambda x: (x[1], -x[0])) li.reverse() li2 = sorted(li, key=lambda x: (x[0], -x[1])) li2.reverse() li3 = sorted(li, key=lambda x: (x[1], x[0])) li3.reverse() li4 = sorted(li, key=lambda x: (x[0], x[1])) li4.reverse() li5 = sorted(li, key=lambda x: (-x[1], -x[0])) li5.reverse() li6 = sorted(li, key=lambda x: (-x[0], -x[1])) li6.reverse() li7 = sorted(li, key=lambda x: (-x[1], x[0])) li7.reverse() li8 = sorted(li, key=lambda x: (-x[0], x[1])) li8.reverse() length = 0 length2 = 0 length3 = 0 length4 = 0 length5 = 0 length6 = 0 length7 = 0 length8 = 0 for i in range(len(li) - 1): length += min(li[i][0], li[i + 1][1]) length += min(li[-1][0], li[0][1]) for i in range(len(li) - 1): length2 += min(li2[i][0], li2[i + 1][1]) length2 += min(li2[-1][0], li2[0][1]) for i in range(len(li) - 1): length3 += min(li3[i][0], li3[i + 1][1]) length3 += min(li3[-1][0], li3[0][1]) for i in range(len(li) - 1): length4 += min(li4[i][0], li4[i + 1][1]) length4 += min(li4[-1][0], li4[0][1]) for i in range(len(li) - 1): length5 += min(li5[i][0], li5[i + 1][1]) length5 += min(li5[-1][0], li5[0][1]) for i in range(len(li) - 1): length6 += min(li6[i][0], li6[i + 1][1]) length6 += min(li6[-1][0], li6[0][1]) for i in range(len(li) - 1): length7 += min(li7[i][0], li7[i + 1][1]) length7 += min(li7[-1][0], li7[0][1]) for i in range(len(li) - 1): length8 += min(li8[i][0], li8[i + 1][1]) length8 += min(li8[-1][0], li8[0][1]) hikaku = [length, length2, length3, length4, length5, length6, length7, length8] print(min(hikaku))
Statement We have a directed weighted graph with N vertices. Each vertex has two integers written on it, and the integers written on Vertex i are A_i and B_i. In this graph, there is an edge from Vertex x to Vertex y for all pairs 1 \leq x,y \leq N, and its weight is {\rm min}(A_x,B_y). We will consider a directed cycle in this graph that visits every vertex exactly once. Find the minimum total weight of the edges in such a cycle.
[{"input": "3\n 1 5\n 4 2\n 6 3", "output": "7\n \n\nConsider the cycle 1\u21923\u21922\u21921. The weights of those edges are {\\rm\nmin}(A_1,B_3)=1, {\\rm min}(A_3,B_2)=2 and {\\rm min}(A_2,B_1)=4, for a total of\n7. As there is no cycle with a total weight of less than 7, the answer is 7.\n\n* * *"}, {"input": "4\n 1 5\n 2 6\n 3 7\n 4 8", "output": "10\n \n\n* * *"}, {"input": "6\n 19 92\n 64 64\n 78 48\n 57 33\n 73 6\n 95 73", "output": "227"}]
Print the number of pairs with integer product A_i \cdot A_j (and i < j). * * *
s138195429
Wrong Answer
p02588
Input is given from Standard Input in the following format. N A_1 A_2 \vdots A_N
n = int(input()) fives, twos, dec = [], [], [] for i in range(n): r = input() if "." in r: dec.append(len(r) - r.index(".") - 1) if r[r.index(".") + 1 :].count("0") == dec[i]: r = r[: r.index(".")] dec[i] = 0 else: r = r.replace(".", "") else: dec.append(0) q = int(r) cf, ct = 0, 0 while q % 5 == 0: q /= 5 cf += 1 while q % 2 == 0: q /= 2 ct += 1 fives.append(cf) twos.append(ct) count = 0 for i in range(n): for j in range(i + 1, n): f, t, d = (fives[i] + fives[j]), (twos[i] + twos[j]), max(dec[i], dec[j]) if min(f, t) >= d: count += 1 print(count)
Statement You are given N real values A_1, A_2, \ldots, A_N. Compute the number of pairs of indices (i, j) such that i < j and the product A_i \cdot A_j is integer.
[{"input": "5\n 7.5\n 2.4\n 17.000000001\n 17\n 16.000000000", "output": "3\n \n\nThere are 3 pairs with integer product:\n\n * 7.5 \\cdot 2.4 = 18\n * 7.5 \\cdot 16 = 120\n * 17 \\cdot 16 = 272\n\n* * *"}, {"input": "11\n 0.9\n 1\n 1\n 1.25\n 2.30000\n 5\n 70\n 0.000000001\n 9999.999999999\n 0.999999999\n 1.000000001", "output": "8"}]
Print the number of pairs with integer product A_i \cdot A_j (and i < j). * * *
s798919690
Runtime Error
p02588
Input is given from Standard Input in the following format. N A_1 A_2 \vdots A_N
def prog(x): n = len(x) y = [int(i * 10**9) for i in x] # y def count25(s): # count25(0) if s.find(".") == -1: s += "." s = s.rstrip("0") decimal_point = s.find(".") int_part = s[:decimal_point] float_part = s[decimal_point + 1 :] float_part += "0" * (9 - len(float_part)) n = int(int_part + float_part) if n == 0: return (0, 0) two = five = 0 while n % 2 == 0: two += 1 n //= 2 while n % 5 == 0: five += 1 n //= 5 return (two, five) two = [0] * n five = [0] * n for i in range(n): two[i], five[i] = count25(y[i]) count = 0 for i in range(n - 1): two_i = 18 - two[i] five_i = 18 - five[i] for j in range(i + 1, n): # if min(two[i] + two[j], five[i] + five[j]) >= 18: if two[j] >= two_i and five[j] >= five_i: # print(min(two1,two2) + min(five1, five2), two1, two2, five1, five2) # print(y[i] * y[j], (y[i] * y[j]) / 10**18) # print(y[i] / 10**9, y[j] / 10**9) # print('=================') count += 1 print(count) n = int(input()) x = [0] * n x = [input() for i in range(n)] prog(x)
Statement You are given N real values A_1, A_2, \ldots, A_N. Compute the number of pairs of indices (i, j) such that i < j and the product A_i \cdot A_j is integer.
[{"input": "5\n 7.5\n 2.4\n 17.000000001\n 17\n 16.000000000", "output": "3\n \n\nThere are 3 pairs with integer product:\n\n * 7.5 \\cdot 2.4 = 18\n * 7.5 \\cdot 16 = 120\n * 17 \\cdot 16 = 272\n\n* * *"}, {"input": "11\n 0.9\n 1\n 1\n 1.25\n 2.30000\n 5\n 70\n 0.000000001\n 9999.999999999\n 0.999999999\n 1.000000001", "output": "8"}]
Print the number of pairs with integer product A_i \cdot A_j (and i < j). * * *
s025905972
Wrong Answer
p02588
Input is given from Standard Input in the following format. N A_1 A_2 \vdots A_N
from bisect import bisect_left from decimal import Decimal N, *A = map(Decimal, open(0).read().split()) N = int(N) A.sort() c = {} intc = 0 ints = [] decs = [] for d in A: if d in c: c[d] += 1 if d == int(d): intc += 1 else: c[d] = 1 if d == int(d): intc += 1 ints.append(d) else: decs.append(d) result = intc * (intc - 1) // 2 for i in range(len(decs)): a = decs[i] t = bisect_left(decs, 1 / a) for j in range(t, len(decs)): b = decs[j] t = a * b if t == int(t): # print(a, b) result += c[a] * c[b] f = a - int(a) t = bisect_left(ints, 1 / f) for j in range(t, len(ints)): b = ints[j] t = a * b if t == int(t): # print(a, b) result += c[a] * c[b] print(result)
Statement You are given N real values A_1, A_2, \ldots, A_N. Compute the number of pairs of indices (i, j) such that i < j and the product A_i \cdot A_j is integer.
[{"input": "5\n 7.5\n 2.4\n 17.000000001\n 17\n 16.000000000", "output": "3\n \n\nThere are 3 pairs with integer product:\n\n * 7.5 \\cdot 2.4 = 18\n * 7.5 \\cdot 16 = 120\n * 17 \\cdot 16 = 272\n\n* * *"}, {"input": "11\n 0.9\n 1\n 1\n 1.25\n 2.30000\n 5\n 70\n 0.000000001\n 9999.999999999\n 0.999999999\n 1.000000001", "output": "8"}]
Print the number of pairs with integer product A_i \cdot A_j (and i < j). * * *
s812529232
Accepted
p02588
Input is given from Standard Input in the following format. N A_1 A_2 \vdots A_N
#!/usr/bin/env python3 # A - Integer Product from math import gcd from collections import Counter def parse(s): """小数点付き数字列をパース""" p = s.find(".") i, f = (s[:p], s[p + 1 :]) if p >= 0 else (s, "") n = int(i + f) # 分子 = 小数点なし数字列 d = 10 ** len(f) # 分母 = 10のべき乗 g = gcd(n, d) return (n // g, d // g) # 約分して返す n = int(input()) a = [parse(input()) for _ in range(n)] MAX_FLEN = 9 # 小数部の長さ def twofive(x): """素因数2と5の個数を返す""" store = {} for d in (2, 5): store[d] = 0 while x % d == 0: store[d] += 1 x //= d return (store[2], store[5]) frac = [twofive(n) + twofive(d) for n, d in a] frac = [(min(MAX_FLEN, n1), min(MAX_FLEN, d1), n2, d2) for n1, d1, n2, d2 in frac] count = Counter(frac) # count[(a, b, c, d)] = a' >= a and b' >= b and c' <= c and d' <= d # である (a', b', c', d') の個数 for a in range(MAX_FLEN, -1, -1): for b in range(MAX_FLEN, -1, -1): for c in range(MAX_FLEN + 1): for d in range(MAX_FLEN + 1): count[(a, b, c, d)] = ( count[(a, b, c, d)] + count[(a + 1, b, c, d)] + count[(a, b + 1, c, d)] + count[(a, b, c - 1, d)] + count[(a, b, c, d - 1)] - count[(a + 1, b + 1, c, d)] - count[(a + 1, b, c - 1, d)] - count[(a + 1, b, c, d - 1)] - count[(a, b + 1, c - 1, d)] - count[(a, b + 1, c, d - 1)] - count[(a, b, c - 1, d - 1)] + count[(a + 1, b + 1, c - 1, d)] + count[(a + 1, b + 1, c, d - 1)] + count[(a + 1, b, c - 1, d - 1)] + count[(a, b + 1, c - 1, d - 1)] - count[(a + 1, b + 1, c - 1, d - 1)] ) # 数(a1, b1, c1, d1)と(a2, b2, c2, d2)の積が整数 # <-> a2 >= c1 and b2 >= d2 and c2 <= a1 and d2 <= b1 s = sum(count[(c, d, a, b)] - (1 if c == d == 0 else 0) for a, b, c, d in frac) print(s // 2)
Statement You are given N real values A_1, A_2, \ldots, A_N. Compute the number of pairs of indices (i, j) such that i < j and the product A_i \cdot A_j is integer.
[{"input": "5\n 7.5\n 2.4\n 17.000000001\n 17\n 16.000000000", "output": "3\n \n\nThere are 3 pairs with integer product:\n\n * 7.5 \\cdot 2.4 = 18\n * 7.5 \\cdot 16 = 120\n * 17 \\cdot 16 = 272\n\n* * *"}, {"input": "11\n 0.9\n 1\n 1\n 1.25\n 2.30000\n 5\n 70\n 0.000000001\n 9999.999999999\n 0.999999999\n 1.000000001", "output": "8"}]
Print the number of pairs with integer product A_i \cdot A_j (and i < j). * * *
s656485614
Accepted
p02588
Input is given from Standard Input in the following format. N A_1 A_2 \vdots A_N
# from collections import deque,defaultdict printn = lambda x: print(x, end="") inn = lambda: int(input()) inl = lambda: list(map(int, input().split())) inm = lambda: map(int, input().split()) ins = lambda: input().strip() DBG = True # and False BIG = 10**18 R = 10**9 + 7 # R = 998244353 def ddprint(x): if DBG: print(x) OFS = 20 KK = 41 n = inn() d = [[0] * KK for i in range(KK)] for i in range(n): a = ins() p = a.find(".") if p < 0: v = int(a) k = 0 else: b = a[:p] + a[p + 1 :] v = int(b) k = len(a) - 1 - p x2 = 0 while v % 2 == 0: x2 += 1 v //= 2 x2 = min(x2, OFS) x5 = 0 while v % 5 == 0: x5 += 1 v //= 5 x5 = min(x5, OFS) d[x2 - k + OFS][x5 - k + OFS] += 1 # if DBG: # for i in range(KK): # for j in range(KK): # if d[i][j]!=0: # ddprint(f"i {i-OFS} j {j-OFS} {d[i][j]}") ans = 0 h = {} for p in range(KK): for q in range(KK): sm = 0 if p < OFS or q < OFS else (d[p][q] * (d[p][q] - 1) // 2) # if sm>0: # ddprint(f"p {p-OFS} q {q-OFS} d {d[p][q]} {sm=}") for r in range(-p + 2 * OFS, KK): # if r==p: # continue for s in range(-q + 2 * OFS, KK): if (r, s) == (p, q) or (r, s, p, q) in h: continue h[(p, q, r, s)] = 1 sm += d[p][q] * d[r][s] # if d[p][q]*d[r][s]>0: # ddprint(f"p {p-OFS} q {q-OFS} r {r-OFS} s {s-OFS} d {d[p][q]} {d[r][s]}") ans += sm print(ans)
Statement You are given N real values A_1, A_2, \ldots, A_N. Compute the number of pairs of indices (i, j) such that i < j and the product A_i \cdot A_j is integer.
[{"input": "5\n 7.5\n 2.4\n 17.000000001\n 17\n 16.000000000", "output": "3\n \n\nThere are 3 pairs with integer product:\n\n * 7.5 \\cdot 2.4 = 18\n * 7.5 \\cdot 16 = 120\n * 17 \\cdot 16 = 272\n\n* * *"}, {"input": "11\n 0.9\n 1\n 1\n 1.25\n 2.30000\n 5\n 70\n 0.000000001\n 9999.999999999\n 0.999999999\n 1.000000001", "output": "8"}]
Print the number of pairs with integer product A_i \cdot A_j (and i < j). * * *
s389413522
Accepted
p02588
Input is given from Standard Input in the following format. N A_1 A_2 \vdots A_N
from fractions import Fraction N = int(input()) A = [Fraction(input()) for i in range(N)] def vp(n, p): res = 0 m = n while m > 0: if m % p == 0: res += 1 m //= p else: return res def div25(f): return ( vp(f.numerator, 2) - vp(f.denominator, 2), vp(f.numerator, 5) - vp(f.denominator, 5), ) B = [div25(f) for f in A] B.sort() MAX_N = 100 C = [[0 for j in range(MAX_N)] for i in range(MAX_N)] for seq in B: x, y = seq C[x + MAX_N // 2][y + MAX_N // 2] += 1 D = [[0 for j in range(MAX_N)] for i in range(MAX_N + 1)] E = [[0 for j in range(MAX_N + 1)] for i in range(MAX_N + 1)] for i in range(MAX_N): for j in range(MAX_N): D[i + 1][j] = D[i][j] + C[i][j] for i in range(MAX_N + 1): for j in range(MAX_N): E[i][j + 1] = E[i][j] + D[i][j] ans = 0 for seq in B: x, y = seq tmp = ( E[MAX_N][MAX_N] + E[-x + MAX_N // 2][-y + MAX_N // 2] - E[MAX_N][-y + MAX_N // 2] - E[-x + MAX_N // 2][MAX_N] ) if x >= 0 and y >= 0: ans += tmp - 1 else: ans += tmp print(ans // 2)
Statement You are given N real values A_1, A_2, \ldots, A_N. Compute the number of pairs of indices (i, j) such that i < j and the product A_i \cdot A_j is integer.
[{"input": "5\n 7.5\n 2.4\n 17.000000001\n 17\n 16.000000000", "output": "3\n \n\nThere are 3 pairs with integer product:\n\n * 7.5 \\cdot 2.4 = 18\n * 7.5 \\cdot 16 = 120\n * 17 \\cdot 16 = 272\n\n* * *"}, {"input": "11\n 0.9\n 1\n 1\n 1.25\n 2.30000\n 5\n 70\n 0.000000001\n 9999.999999999\n 0.999999999\n 1.000000001", "output": "8"}]
Print the number of pairs with integer product A_i \cdot A_j (and i < j). * * *
s608457035
Wrong Answer
p02588
Input is given from Standard Input in the following format. N A_1 A_2 \vdots A_N
cnt = 100 res = [] def one(): global cnt global res res.append(f"< 2 0 {cnt}") cnt += 1 return cnt - 1 def twice(x): global cnt global res res.append(f"+ {x} {x} {cnt}") cnt += 1 return cnt - 1 def plus(x, y): global cnt global res res.append(f"+ {x} {y} {cnt}") cnt += 1 return cnt - 1 def gt(x, y): global cnt global res res.append(f"< {x} {y} {cnt}") cnt += 1 return cnt - 1 def tmp(): global cnt cnt += 1 return cnt - 1 def mult(x, y): global one global cnt global res res.append(f"< {x} {one} {cnt}") res.append(f"< {cnt} {y} {cnt + 1}") cnt += 2 return cnt - 1 A = 0 B = 1 zero = tmp() one = one() two = twice(one) four = twice(two) eight = twice(four) A4 = gt(eight, plus(A, one)) A3 = gt(plus(four, twice(twice(twice(A4)))), plus(A, one)) A2 = gt(plus(two, plus(twice(twice(twice(A4))), twice(twice(A3)))), plus(A, one)) A1 = gt( plus(one, plus(plus(twice(twice(twice(A4))), twice(twice(A3))), twice(A2))), plus(A, one), ) B4 = gt(eight, plus(B, one)) B3 = gt(plus(four, twice(twice(twice(B4)))), plus(B, one)) B2 = gt(plus(two, plus(twice(twice(twice(B4))), twice(twice(B3)))), plus(B, one)) B1 = gt( plus(one, plus(plus(twice(twice(twice(B4))), twice(twice(B3))), twice(B2))), plus(B, one), ) A1B1 = mult(one, mult(A1, B1)) A1B2 = mult(one, mult(A1, B2)) A1B3 = mult(one, mult(A1, B3)) A1B4 = mult(one, mult(A1, B4)) A2B1 = mult(one, mult(A2, B1)) A2B2 = mult(one, mult(A2, B2)) A2B3 = mult(one, mult(A2, B3)) A2B4 = mult(one, mult(A2, B4)) A3B1 = mult(A3, B1) A3B2 = mult(A3, B2) A3B3 = mult(A3, B3) A3B4 = mult(A3, B4) A4B1 = mult(A4, B1) A4B2 = mult(A4, B2) A4B3 = mult(A4, B3) A4B4 = mult(A4, B4) AB1 = A1B1 AB2 = plus(A1B2, A2B1) AB3 = plus(plus(A1B3, A2B2), A3B1) AB4 = plus(plus(A1B4, A2B3), plus(A3B2, A4B1)) AB5 = plus(plus(A2B4, A3B3), A4B2) AB6 = plus(A3B4, A4B3) AB7 = A4B4 t1 = AB1 t2 = twice(AB2) t3 = twice(twice(AB3)) t4 = twice(twice(twice(AB4))) t5 = twice(twice(twice(twice(AB5)))) t6 = twice(twice(twice(twice(twice(AB6))))) t7 = twice(twice(twice(twice(twice(twice(AB7)))))) ans = plus(plus(plus(t1, t2), plus(t3, t4)), plus(plus(t5, t6), t7)) res.append(f"+ 2 {ans} 2") print(len(res)) for i in res: print(i)
Statement You are given N real values A_1, A_2, \ldots, A_N. Compute the number of pairs of indices (i, j) such that i < j and the product A_i \cdot A_j is integer.
[{"input": "5\n 7.5\n 2.4\n 17.000000001\n 17\n 16.000000000", "output": "3\n \n\nThere are 3 pairs with integer product:\n\n * 7.5 \\cdot 2.4 = 18\n * 7.5 \\cdot 16 = 120\n * 17 \\cdot 16 = 272\n\n* * *"}, {"input": "11\n 0.9\n 1\n 1\n 1.25\n 2.30000\n 5\n 70\n 0.000000001\n 9999.999999999\n 0.999999999\n 1.000000001", "output": "8"}]
Print the number of pairs with integer product A_i \cdot A_j (and i < j). * * *
s655712187
Wrong Answer
p02588
Input is given from Standard Input in the following format. N A_1 A_2 \vdots A_N
""" https://atcoder.jp/contests/agc047/tasks/agc047_a """
Statement You are given N real values A_1, A_2, \ldots, A_N. Compute the number of pairs of indices (i, j) such that i < j and the product A_i \cdot A_j is integer.
[{"input": "5\n 7.5\n 2.4\n 17.000000001\n 17\n 16.000000000", "output": "3\n \n\nThere are 3 pairs with integer product:\n\n * 7.5 \\cdot 2.4 = 18\n * 7.5 \\cdot 16 = 120\n * 17 \\cdot 16 = 272\n\n* * *"}, {"input": "11\n 0.9\n 1\n 1\n 1.25\n 2.30000\n 5\n 70\n 0.000000001\n 9999.999999999\n 0.999999999\n 1.000000001", "output": "8"}]
Print the number of pairs with integer product A_i \cdot A_j (and i < j). * * *
s320819523
Wrong Answer
p02588
Input is given from Standard Input in the following format. N A_1 A_2 \vdots A_N
print(246) c = 0 for i in range(1, 10): c += 4 print("<", 10 + i, 0, 20 + i) print("+", 10 + i, 20 + i, 10 + i + 1) print("<", 30 + i, 1, 40 + i) print("+", 30 + i, 40 + i, 30 + i + 1) for i in range(10, 0, -1): print("<", 30 + i, 30 + 1, 30 + i) c += 1 for i in range(10): for j in range(10): c += 2 print("<", 30 + i + 1, 10 + i + 1, 100 + 10 * i + 10 * j) print("+", 2, 100 + 10 * i + 10 * j, 2)
Statement You are given N real values A_1, A_2, \ldots, A_N. Compute the number of pairs of indices (i, j) such that i < j and the product A_i \cdot A_j is integer.
[{"input": "5\n 7.5\n 2.4\n 17.000000001\n 17\n 16.000000000", "output": "3\n \n\nThere are 3 pairs with integer product:\n\n * 7.5 \\cdot 2.4 = 18\n * 7.5 \\cdot 16 = 120\n * 17 \\cdot 16 = 272\n\n* * *"}, {"input": "11\n 0.9\n 1\n 1\n 1.25\n 2.30000\n 5\n 70\n 0.000000001\n 9999.999999999\n 0.999999999\n 1.000000001", "output": "8"}]
Print the number of pairs with integer product A_i \cdot A_j (and i < j). * * *
s226985553
Accepted
p02588
Input is given from Standard Input in the following format. N A_1 A_2 \vdots A_N
import sys # from fractions import Fraction import collections input_methods = ["clipboard", "file", "key"] using_method = 0 input_method = input_methods[using_method] tin = lambda: map(int, input().split()) lin = lambda: list(tin()) mod = 1000000007 # +++++ def a(s): if s.count(".") == 0: n2 = 0 n5 = 0 v = int(s) else: p = s.index(".") n2 = -(len(s) - p - 1) n5 = -(len(s) - p - 1) if p == 1 and s[0] == "0": v = int(s[2:]) else: v = int(s[:p] + s[p + 1 :]) while v % 2 == 0: v = v // 2 n2 += 1 while v % 5 == 0: v = v // 5 n5 += 1 return str(n2) + "_" + str(n5) def main(): n = int(input()) # b , c = tin() al = [a(input()) for _ in range(n)] cal = collections.Counter(al) # pa(cal) ret = 0 pp = set() for k in cal: for k2 in cal: if k + "_" + k2 in pp: continue # pa((vi*vj)/(10**20)) if k == k2: a2, a5 = map(int, k.split("_")) if a2 >= 0 and a5 >= 0: ret += cal[k] * (cal[k] - 1) // 2 else: a2, a5 = map(int, k.split("_")) b2, b5 = map(int, k2.split("_")) if a2 + b2 >= 0 and a5 + b5 >= 0: ret += cal[k] * cal[k2] pp.add(k + "_" + k2) pp.add(k2 + "_" + k) # pa((k,k2,ret)) return ret # +++++ isTest = False def pa(v): if isTest: print(v) def input_clipboard(): import clipboard input_text = clipboard.get() input_l = input_text.splitlines() for l in input_l: yield l if __name__ == "__main__": if sys.platform == "ios": if input_method == input_methods[0]: ic = input_clipboard() input = lambda: ic.__next__() elif input_method == input_methods[1]: sys.stdin = open("inputFile.txt") else: pass isTest = True else: pass # input = sys.stdin.readline ret = main() if ret is not None: print(ret)
Statement You are given N real values A_1, A_2, \ldots, A_N. Compute the number of pairs of indices (i, j) such that i < j and the product A_i \cdot A_j is integer.
[{"input": "5\n 7.5\n 2.4\n 17.000000001\n 17\n 16.000000000", "output": "3\n \n\nThere are 3 pairs with integer product:\n\n * 7.5 \\cdot 2.4 = 18\n * 7.5 \\cdot 16 = 120\n * 17 \\cdot 16 = 272\n\n* * *"}, {"input": "11\n 0.9\n 1\n 1\n 1.25\n 2.30000\n 5\n 70\n 0.000000001\n 9999.999999999\n 0.999999999\n 1.000000001", "output": "8"}]
Print the number of pairs with integer product A_i \cdot A_j (and i < j). * * *
s516810946
Wrong Answer
p02588
Input is given from Standard Input in the following format. N A_1 A_2 \vdots A_N
import sys import math from collections import defaultdict sys.setrecursionlimit(1000000) MOD = 10**9 + 7 input = lambda: sys.stdin.readline().strip() NI = lambda: int(input()) NMI = lambda: map(int, input().split()) NLI = lambda: list(NMI()) SI = lambda: input() def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)] def main(): N = NI() A = [SI() for _ in range(N)] B = defaultdict(list) for a in A: if a.count(".") != 1: B[int(a)].append(1) continue ba, bb = a.split(".") ba = int(ba + bb) bb = 10 ** len(bb) g = math.gcd(ba, bb) ba //= g bb //= g B[ba].append(bb) facts = defaultdict(int) for ba, bbs in B.items(): tmp = ba ba_fac_2 = 0 while True: if tmp % 2: break ba_fac_2 += 1 tmp //= 2 tmp = ba ba_fac_5 = 0 while True: if tmp % 5: break ba_fac_5 += 1 tmp //= 5 for bb in bbs: tmp = bb bb_fac_2 = 0 while True: if tmp % 2: break bb_fac_2 += 1 tmp //= 2 tmp = bb bb_fac_5 = 0 while True: if tmp % 5: break bb_fac_5 += 1 tmp //= 5 facts[(ba_fac_2 - bb_fac_2, ba_fac_5 - bb_fac_5)] += 1 ans = 0 for fact, k in list(facts.items()): fac2, fac5 = fact for i in range(-fac2, 14): for j in range(-fac5, 6): if fac2 == i and fac5 == j: ans += k * (k - 1) else: ans += k * facts[(i, j)] print(ans // 2) if __name__ == "__main__": main()
Statement You are given N real values A_1, A_2, \ldots, A_N. Compute the number of pairs of indices (i, j) such that i < j and the product A_i \cdot A_j is integer.
[{"input": "5\n 7.5\n 2.4\n 17.000000001\n 17\n 16.000000000", "output": "3\n \n\nThere are 3 pairs with integer product:\n\n * 7.5 \\cdot 2.4 = 18\n * 7.5 \\cdot 16 = 120\n * 17 \\cdot 16 = 272\n\n* * *"}, {"input": "11\n 0.9\n 1\n 1\n 1.25\n 2.30000\n 5\n 70\n 0.000000001\n 9999.999999999\n 0.999999999\n 1.000000001", "output": "8"}]
For each print command, print a string in a line.
s543748380
Wrong Answer
p02422
In the first line, a string $str$ is given. $str$ consists of lowercase letters. In the second line, the number of commands q is given. In the next q lines, each command is given in the above mentioned format.
n = input() q = int(input()) def printdef(z, a, b): print(z[a:b]) def replacedef(z, a, b, c): z = z.replace(z[a:b], c) return z def reversedef(z, a, b): ichi = z[a:b] ichi = ichi[::-1] z = z.replace(z[a:b], ichi) return z for _ in range(q): order_str = list(input().split(" ")) order_str[1] = int(order_str[1]) order_str[2] = int(order_str[2]) + 1 if order_str[0] == "print": printdef(n, order_str[1], order_str[2]) elif order_str[0] == "replace": n = replacedef(n, order_str[1], order_str[2], order_str[3]) elif order_str[0] == "reverse": n = reversedef(n, order_str[1], order_str[2])
Transformation Write a program which performs a sequence of commands to a given string $str$. The command is one of: * print a b: print from the a-th character to the b-th character of $str$ * reverse a b: reverse from the a-th character to the b-th character of $str$ * replace a b p: replace from the a-th character to the b-th character of $str$ with p Note that the indices of $str$ start with 0.
[{"input": "abcde\n 3\n replace 1 3 xyz\n reverse 0 2\n print 1 4", "output": "xaze"}, {"input": "xyz\n 3\n print 0 2\n replace 0 2 abc\n print 0 2", "output": "xyz\n abc"}]
For each print command, print a string in a line.
s468929313
Accepted
p02422
In the first line, a string $str$ is given. $str$ consists of lowercase letters. In the second line, the number of commands q is given. In the next q lines, each command is given in the above mentioned format.
char = input() cnt = int(input()) for _ in range(0, cnt): ops = input().split() a, b = map(int, ops[1:3]) if ops[0] == "print": print(char[a : b + 1]) if ops[0] == "reverse": char = char[0:a] + char[a : b + 1][::-1] + char[b + 1 :] if ops[0] == "replace": char = char[0:a] + ops[3] + char[b + 1 :]
Transformation Write a program which performs a sequence of commands to a given string $str$. The command is one of: * print a b: print from the a-th character to the b-th character of $str$ * reverse a b: reverse from the a-th character to the b-th character of $str$ * replace a b p: replace from the a-th character to the b-th character of $str$ with p Note that the indices of $str$ start with 0.
[{"input": "abcde\n 3\n replace 1 3 xyz\n reverse 0 2\n print 1 4", "output": "xaze"}, {"input": "xyz\n 3\n print 0 2\n replace 0 2 abc\n print 0 2", "output": "xyz\n abc"}]
For each print command, print a string in a line.
s750110249
Accepted
p02422
In the first line, a string $str$ is given. $str$ consists of lowercase letters. In the second line, the number of commands q is given. In the next q lines, each command is given in the above mentioned format.
str0 = input() q = int(input()) for i in range(q): ord = input() if "print" in ord: buff = ord.split() a = int(buff[1]) b = int(buff[2]) print(str0[a : b + 1]) if "replace" in ord: buff = ord.split() a = int(buff[1]) b = int(buff[2]) str0 = str0[0:a] + buff[3] + str0[b + 1 :] if "reverse" in ord: buff = ord.split() a = int(buff[1]) b = int(buff[2]) tmp = str0[a : b + 1] str0 = str0[0:a] + "".join(list(reversed(tmp))) + str0[b + 1 :]
Transformation Write a program which performs a sequence of commands to a given string $str$. The command is one of: * print a b: print from the a-th character to the b-th character of $str$ * reverse a b: reverse from the a-th character to the b-th character of $str$ * replace a b p: replace from the a-th character to the b-th character of $str$ with p Note that the indices of $str$ start with 0.
[{"input": "abcde\n 3\n replace 1 3 xyz\n reverse 0 2\n print 1 4", "output": "xaze"}, {"input": "xyz\n 3\n print 0 2\n replace 0 2 abc\n print 0 2", "output": "xyz\n abc"}]
For each print command, print a string in a line.
s700108234
Accepted
p02422
In the first line, a string $str$ is given. $str$ consists of lowercase letters. In the second line, the number of commands q is given. In the next q lines, each command is given in the above mentioned format.
l_str = input() q = int(input()) ord = [] for i in range(q): ord = list(input().split()) if ord[0] == "print": a = int(ord[1]) b = int(ord[2]) print(l_str[a : b + 1]) if ord[0] == "reverse": a = int(ord[1]) b = int(ord[2]) c = l_str[a : b + 1][::-1] l_str = l_str[:a] + c + l_str[b + 1 :] if ord[0] == "replace": a = int(ord[1]) b = int(ord[2]) p = ord[3] l_str = l_str[:a] + p + l_str[b + 1 :]
Transformation Write a program which performs a sequence of commands to a given string $str$. The command is one of: * print a b: print from the a-th character to the b-th character of $str$ * reverse a b: reverse from the a-th character to the b-th character of $str$ * replace a b p: replace from the a-th character to the b-th character of $str$ with p Note that the indices of $str$ start with 0.
[{"input": "abcde\n 3\n replace 1 3 xyz\n reverse 0 2\n print 1 4", "output": "xaze"}, {"input": "xyz\n 3\n print 0 2\n replace 0 2 abc\n print 0 2", "output": "xyz\n abc"}]
For each print command, print a string in a line.
s164570399
Accepted
p02422
In the first line, a string $str$ is given. $str$ consists of lowercase letters. In the second line, the number of commands q is given. In the next q lines, each command is given in the above mentioned format.
str = input() for i in range(int(input())): line = input().split() formula = line[0] left = int(line[1]) right = int(line[2]) + 1 if formula == "print": print(str[left:right]) elif formula == "reverse": str = str[:left] + str[left:right][::-1] + str[right:] elif formula == "replace": str = str[:left] + line[3] + str[right:]
Transformation Write a program which performs a sequence of commands to a given string $str$. The command is one of: * print a b: print from the a-th character to the b-th character of $str$ * reverse a b: reverse from the a-th character to the b-th character of $str$ * replace a b p: replace from the a-th character to the b-th character of $str$ with p Note that the indices of $str$ start with 0.
[{"input": "abcde\n 3\n replace 1 3 xyz\n reverse 0 2\n print 1 4", "output": "xaze"}, {"input": "xyz\n 3\n print 0 2\n replace 0 2 abc\n print 0 2", "output": "xyz\n abc"}]
For each print command, print a string in a line.
s777871969
Accepted
p02422
In the first line, a string $str$ is given. $str$ consists of lowercase letters. In the second line, the number of commands q is given. In the next q lines, each command is given in the above mentioned format.
def print_ab(sent, a, b): res = sent[a : b + 1] return res def reverse_ab(sent, a, b): top = sent[:a] las = sent[b + 1 :] tag = sent[a : b + 1] n = len(tag) rev = "" for i in range(n): rev = rev + tag[n - i - 1] rev = top + rev + las return rev def replace_abp(sent, a, b, p): top = sent[:a] las = sent[b + 1 :] rep = top + p + las return rep # print(print_ab("xyz", 0, 2)) # print(reverse_ab("abcde", 1, 3)) # print(replace_abp("xyz", 0, 2, "abc")) sent = input() op = int(input()) results = [] for i in range(op): oder = list(map(str, input().split())) if oder[0] == "print": res = print_ab(sent, int(oder[1]), int(oder[2])) results.append(res) elif oder[0] == "reverse": sent = reverse_ab(sent, int(oder[1]), int(oder[2])) else: sent = replace_abp(sent, int(oder[1]), int(oder[2]), oder[3]) for s in results: print(s)
Transformation Write a program which performs a sequence of commands to a given string $str$. The command is one of: * print a b: print from the a-th character to the b-th character of $str$ * reverse a b: reverse from the a-th character to the b-th character of $str$ * replace a b p: replace from the a-th character to the b-th character of $str$ with p Note that the indices of $str$ start with 0.
[{"input": "abcde\n 3\n replace 1 3 xyz\n reverse 0 2\n print 1 4", "output": "xaze"}, {"input": "xyz\n 3\n print 0 2\n replace 0 2 abc\n print 0 2", "output": "xyz\n abc"}]
For each print command, print a string in a line.
s245420897
Accepted
p02422
In the first line, a string $str$ is given. $str$ consists of lowercase letters. In the second line, the number of commands q is given. In the next q lines, each command is given in the above mentioned format.
def hyouji(moji, a, b): for j in range(a, b): print(moji[j], end="") print() def gyakujun(moji, a, b): moji1 = [moji[i] for i in range(a, b)] moji1.reverse() for i in range(a, b): moji[i] = moji1[i - a] return moji def replace(moji, a, b, p): for i in range(a, b): moji[i] = p[i - a] return moji nyuryoku = input() moji = [] for i in nyuryoku: moji.append(i) kaisu = int(input()) for j in range(kaisu): command = list(map(str, input().split())) p = [] meirei = command[0] a = int(command[1]) b = int(command[2]) + 1 if len(command) == 4: for i in command[3]: p.append(i) if meirei == "print": hyouji(moji, a, b) elif meirei == "reverse": gyakujun(moji, a, b) elif meirei == "replace": replace(moji, a, b, p)
Transformation Write a program which performs a sequence of commands to a given string $str$. The command is one of: * print a b: print from the a-th character to the b-th character of $str$ * reverse a b: reverse from the a-th character to the b-th character of $str$ * replace a b p: replace from the a-th character to the b-th character of $str$ with p Note that the indices of $str$ start with 0.
[{"input": "abcde\n 3\n replace 1 3 xyz\n reverse 0 2\n print 1 4", "output": "xaze"}, {"input": "xyz\n 3\n print 0 2\n replace 0 2 abc\n print 0 2", "output": "xyz\n abc"}]
For each print command, print a string in a line.
s845328292
Accepted
p02422
In the first line, a string $str$ is given. $str$ consists of lowercase letters. In the second line, the number of commands q is given. In the next q lines, each command is given in the above mentioned format.
str = input() question = int(input()) for q in range(question): line = input() if line.find("print") != -1: order, a, b = (x for x in line.split()) print(str[int(a) : int(b) + 1]) elif line.find("reverse") != -1: order, a, b = (x for x in line.split()) if a == 0: str = str[int(a) : int(b) + 1][::-1] + str[int(b) + 1 : len(str)] else: str = ( str[: int(a)] + str[int(a) : int(b) + 1][::-1] + str[int(b) + 1 : len(str)] ) elif line.find("replace") != -1: order, a, b, word = (x for x in line.split()) str = str[: int(a)] + word + str[int(b) + 1 : len(str)]
Transformation Write a program which performs a sequence of commands to a given string $str$. The command is one of: * print a b: print from the a-th character to the b-th character of $str$ * reverse a b: reverse from the a-th character to the b-th character of $str$ * replace a b p: replace from the a-th character to the b-th character of $str$ with p Note that the indices of $str$ start with 0.
[{"input": "abcde\n 3\n replace 1 3 xyz\n reverse 0 2\n print 1 4", "output": "xaze"}, {"input": "xyz\n 3\n print 0 2\n replace 0 2 abc\n print 0 2", "output": "xyz\n abc"}]
For each print command, print a string in a line.
s153787407
Accepted
p02422
In the first line, a string $str$ is given. $str$ consists of lowercase letters. In the second line, the number of commands q is given. In the next q lines, each command is given in the above mentioned format.
def splitString(target, start, end): first = target[:start] middle = target[start : end + 1] last = target[end + 1 :] return (first, middle, last) def doReplace(target, args): start = int(args[0]) end = int(args[1]) replace_str = args[2] first, _, last = splitString(target, start, end) return first + replace_str + last def doReverse(target, args): start = int(args[0]) end = int(args[1]) first, middle, last = splitString(target, start, end) return first + middle[::-1] + last def makeMessage(target, args): start = int(args[0]) end = int(args[1]) _, middle, _ = splitString(target, start, end) return middle def transform(): messages = [] # プリント用文字を格納するリスト target = input() q = int(input()) for _ in range(q): line = input() cmd = line.split(" ")[0] args = line.split(" ")[1:] # 各命令を実行 if cmd == "print": messages.append(makeMessage(target, args)) elif cmd == "replace": target = doReplace(target, args) elif cmd == "reverse": target = doReverse(target, args) # 各メッセージの表示 [print(message) for message in messages] def kantanna_test(expected, actual): if expected == actual: print("OK") else: print("NG") if __name__ == "__main__": transform()
Transformation Write a program which performs a sequence of commands to a given string $str$. The command is one of: * print a b: print from the a-th character to the b-th character of $str$ * reverse a b: reverse from the a-th character to the b-th character of $str$ * replace a b p: replace from the a-th character to the b-th character of $str$ with p Note that the indices of $str$ start with 0.
[{"input": "abcde\n 3\n replace 1 3 xyz\n reverse 0 2\n print 1 4", "output": "xaze"}, {"input": "xyz\n 3\n print 0 2\n replace 0 2 abc\n print 0 2", "output": "xyz\n abc"}]
For each print command, print a string in a line.
s095029022
Accepted
p02422
In the first line, a string $str$ is given. $str$ consists of lowercase letters. In the second line, the number of commands q is given. In the next q lines, each command is given in the above mentioned format.
str = input() s = list(str) q = int(input()) for i in range(q): Q = input() l = list(Q) if "print" in Q: for p in range(6): l.pop(0) for X in range(len(l)): if l[X] == " ": x = X A = l[0:x] a = "".join(A) a = int(a) B = l[x + 1 : len(l)] b = "".join(B) b = int(b) + 1 t = s[a:b] str = "".join(t) print(str) elif "reverse" in Q: for v in range(8): l.pop(0) for Y in range(len(l)): if l[Y] == " ": y = Y A = l[0:y] a = "".join(A) a = int(a) B = l[y + 1 : len(l)] b = "".join(B) b = int(b) + 1 t = s[a:b] t.reverse() s[a:b] = t elif "replace" in Q: for r in range(8): l.pop(0) for Z in range(len(l)): if l[Z] == " ": z = Z break N = 0 while True: if l[z + N + 1] == " ": n = z + N + 1 break else: N += 1 A = l[0:z] a = "".join(A) a = int(a) B = l[z + 1 : n] b = "".join(B) b = int(b) + 1 t = l[n + 1 : len(l)] s[a:b] = t
Transformation Write a program which performs a sequence of commands to a given string $str$. The command is one of: * print a b: print from the a-th character to the b-th character of $str$ * reverse a b: reverse from the a-th character to the b-th character of $str$ * replace a b p: replace from the a-th character to the b-th character of $str$ with p Note that the indices of $str$ start with 0.
[{"input": "abcde\n 3\n replace 1 3 xyz\n reverse 0 2\n print 1 4", "output": "xaze"}, {"input": "xyz\n 3\n print 0 2\n replace 0 2 abc\n print 0 2", "output": "xyz\n abc"}]
For each print command, print a string in a line.
s156756159
Accepted
p02422
In the first line, a string $str$ is given. $str$ consists of lowercase letters. In the second line, the number of commands q is given. In the next q lines, each command is given in the above mentioned format.
import sys input = sys.stdin.readline def main(): text = input().rstrip() n = int(input().rstrip()) for i in range(n): s = input().split() if s[0] == "print": print(text[int(s[1]) : int(s[2]) + 1]) elif s[0] == "replace": new_text = "" new_text += text[: int(s[1])] new_text += s[3] new_text += text[int(s[2]) + 1 :] text = new_text elif s[0] == "reverse": new_text = "" new_text += text[: int(s[1])] for i in range(int(s[2]) - int(s[1]) + 1): new_text += text[int(s[2]) - i] new_text += text[int(s[2]) + 1 :] text = new_text if __name__ == "__main__": main()
Transformation Write a program which performs a sequence of commands to a given string $str$. The command is one of: * print a b: print from the a-th character to the b-th character of $str$ * reverse a b: reverse from the a-th character to the b-th character of $str$ * replace a b p: replace from the a-th character to the b-th character of $str$ with p Note that the indices of $str$ start with 0.
[{"input": "abcde\n 3\n replace 1 3 xyz\n reverse 0 2\n print 1 4", "output": "xaze"}, {"input": "xyz\n 3\n print 0 2\n replace 0 2 abc\n print 0 2", "output": "xyz\n abc"}]
For each print command, print a string in a line.
s995440532
Accepted
p02422
In the first line, a string $str$ is given. $str$ consists of lowercase letters. In the second line, the number of commands q is given. In the next q lines, each command is given in the above mentioned format.
instr = list(str(input())) num = int(input()) for i in range(num): comm = list(input().split()) if str(comm[0]) == "replace": instr[int(comm[1]) : int(comm[2]) + 1] = str(comm[3]) elif str(comm[0]) == "reverse": instr[int(comm[1]) : int(comm[2]) + 1] = list( reversed(instr[int(comm[1]) : int(comm[2]) + 1]) ) elif str(comm[0]) == "print": print("".join(instr[int(comm[1]) : int(comm[2]) + 1]))
Transformation Write a program which performs a sequence of commands to a given string $str$. The command is one of: * print a b: print from the a-th character to the b-th character of $str$ * reverse a b: reverse from the a-th character to the b-th character of $str$ * replace a b p: replace from the a-th character to the b-th character of $str$ with p Note that the indices of $str$ start with 0.
[{"input": "abcde\n 3\n replace 1 3 xyz\n reverse 0 2\n print 1 4", "output": "xaze"}, {"input": "xyz\n 3\n print 0 2\n replace 0 2 abc\n print 0 2", "output": "xyz\n abc"}]
For each print command, print a string in a line.
s790766207
Accepted
p02422
In the first line, a string $str$ is given. $str$ consists of lowercase letters. In the second line, the number of commands q is given. In the next q lines, each command is given in the above mentioned format.
w = input() N = int(input()) for n in range(N): o = input().split() if o[0] == "print": print(w[int(o[1]) : int(o[2]) + 1]) if o[0] == "reverse": a = w[int(o[1]) : int(o[2]) + 1] w = w[: int(o[1])] + a[::-1] + w[int(o[2]) + 1 :] if o[0] == "replace": b = [x for x in w] i = [y for y in o[3]] for j in range(len(i)): b[int(o[1]) + j] = i[j] w = "".join(map(str, b))
Transformation Write a program which performs a sequence of commands to a given string $str$. The command is one of: * print a b: print from the a-th character to the b-th character of $str$ * reverse a b: reverse from the a-th character to the b-th character of $str$ * replace a b p: replace from the a-th character to the b-th character of $str$ with p Note that the indices of $str$ start with 0.
[{"input": "abcde\n 3\n replace 1 3 xyz\n reverse 0 2\n print 1 4", "output": "xaze"}, {"input": "xyz\n 3\n print 0 2\n replace 0 2 abc\n print 0 2", "output": "xyz\n abc"}]
For each print command, print a string in a line.
s189855439
Accepted
p02422
In the first line, a string $str$ is given. $str$ consists of lowercase letters. In the second line, the number of commands q is given. In the next q lines, each command is given in the above mentioned format.
istr = input() iq = int(input()) arr = [] for i in range(0, iq): arr.append(list(input().split())) # print(arr) for i in arr: cmd = i[0] a, b = int(i[1]), int(i[2]) if cmd == "print": # strのa文字目からb文字目までを出力する。 print(istr[a : b + 1]) elif cmd == "reverse": # strのa文字目からb文字目までを逆順にする。 stemp = "" for i in range(b, a - 1, -1): stemp = stemp + istr[i] istr = istr[:a] + stemp + istr[b + 1 :] elif cmd == "replace": # strのa文字目からb文字目までをpに置き換える。 p = i[3] istr = istr[:a] + p + istr[b + 1 :] # print(istr)
Transformation Write a program which performs a sequence of commands to a given string $str$. The command is one of: * print a b: print from the a-th character to the b-th character of $str$ * reverse a b: reverse from the a-th character to the b-th character of $str$ * replace a b p: replace from the a-th character to the b-th character of $str$ with p Note that the indices of $str$ start with 0.
[{"input": "abcde\n 3\n replace 1 3 xyz\n reverse 0 2\n print 1 4", "output": "xaze"}, {"input": "xyz\n 3\n print 0 2\n replace 0 2 abc\n print 0 2", "output": "xyz\n abc"}]