problem_id
stringlengths 6
6
| user_id
stringlengths 10
10
| time_limit
float64 1k
8k
| memory_limit
float64 262k
1.05M
| problem_description
stringlengths 48
1.55k
| codes
stringlengths 35
98.9k
| status
stringlengths 28
1.7k
| submission_ids
stringlengths 28
1.41k
| memories
stringlengths 13
808
| cpu_times
stringlengths 11
610
| code_sizes
stringlengths 7
505
|
---|---|---|---|---|---|---|---|---|---|---|
p03373 | u517682687 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['A, B, C, X, Y = tuple(map(int, input().split()))\n\n\nTOTAL_MIN = A * X + B * Y + C * (X+Y) * 2\n\nfor a in range(X + 1):\n c = (X - a) * 2\n b = Y - c // 2\n total_tmp = A * a + B * b + C * c\n if total_tmp < TOTAL_MIN:\n TOTAL_MIN = total_tmp\n\nprint(TOTAL_MIN)\n', 'A, B, C, X, Y = tuple(map(int, input().split()))\n\nA + 2 // C > X\nB + 2 // C > Y\n\n\nTOTAL_MIN = A * X + B * Y + C * (X+Y) * 2\nfor i in range(X+1):\n for j in range(Y+1):\n k = max(X - i, Y - j) * 2\n total_tmp = A * i + B * j + C * k\n if X <= i + k and Y <= j + k\\\n and total_tmp < TOTAL_MIN:\n print(i, j, k)\n TOTAL_MIN = total_tmp\n\nprint(TOTAL_MIN)\n', 'A, B, C, X, Y = tuple(map(int, input().split()))\n\n\nTOTAL_MIN = A * X + B * Y + C * (X+Y) * 2\n\nfor a in range(X + 1):\n c = (X - a) * 2\n if c // 2 < Y:\n if B < 2 * C:\n b = Y - c // 2\n else:\n b = 0\n c = max(c, Y * 2) \n else:\n b = 0\n \n total_tmp = A * a + B * b + C * c\n if total_tmp < TOTAL_MIN:\n TOTAL_MIN = total_tmp\n \n\nprint(TOTAL_MIN)\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s499088440', 's592354855', 's357703995'] | [2940.0, 4680.0, 3064.0] | [75.0, 2104.0, 103.0] | [298, 432, 448] |
p03373 | u519939795 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['a,b,c,x,y=map(int,input().split())\nans=10**18\nfor i in range(max(x,y)+1):\n price=a*max(0,x-i)+b*max(0,y-i)+s*c*i\n ans = min(ans,price)\nprint(ans)', 'a,b,c,x,y=map(int,input().split())\nans=10**18\nfor i in range(max(x,y)+1):\n price=a*max(0,x-i)+b*max(0,y-i)+2*c*i\n ans = min(ans,price)\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s252916166', 's755890158'] | [3060.0, 3060.0] | [17.0, 123.0] | [151, 151] |
p03373 | u546440137 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['A,B,C,X,Y = map(int,input().split())\nans=0\n\n\nif A+B > c*2:\n Z = min(X,Y)\n ans += 2*C*Z\n X -= Z\n Y -= Z\na = min(A,2*C)\nb = min(B,2*C)\n\nans += a*X\nans += b*Y\n\nprint(ans)\n', 'A,B,C,X,Y = map(int,input().split())\nans=0\n\n\nif A+B > C*2:\n Z = min(X,Y)\n ans += 2*C*Z\n X -= Z\n Y -= Z\na = min(A,2*C)\nb = min(B,2*C)\n\nans += a*X\nans += b*Y\n\nprint(ans)\n'] | ['Runtime Error', 'Accepted'] | ['s327896475', 's953260126'] | [9076.0, 9172.0] | [23.0, 28.0] | [180, 180] |
p03373 | u548624367 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['a,b,c,x,y=map(int,input().split())\nprint(min(i*c+a*max(x-i,0)+b*max(y-i,0) for i in range(max(x,y)+1)))', 'a,b,c,x,y=map(int,input().split())\nprint(min([i*c+a*max(x-i,0)+b*max(y-i,0) for i in range(max(x,y)+1)]))', 'a,b,c,x,y=map(int,input().split())\nprint(min([i*c*2+a*max(x-i,0)+b*max(y-i,0) for i in range(max(x,y)+1)]))'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s463743271', 's615303341', 's872852715'] | [2940.0, 7048.0, 7096.0] | [85.0, 79.0, 83.0] | [103, 105, 107] |
p03373 | u633914031 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['a,b,c,x,y=map(int, input().split())\ncnta=0\ncntb=0\ncntc=0\nif a+b>2*c:\n cntc=min(x,y) * 2\nelse:\n cnta=min(x,y)\n cntb=min(x,y)\n\nif x>y:\n if a>2*c:\n cntc+=2*(x-y)\n else:\n cnta+=x-y\nelse:\n if b>2*c:\n cntc+=2*(y-x)\n else:\n cntb+=y-x\n\nptint(cnta*a+cntb*b+cntc*c)\n\n', 'A,B,C,X,Y=map(int, input().split())\ncnta=0\ncntb=0\ncntc=0\nif X>Y:\n if A+B>2*C:\n cntc+=2*Y\n else:\n cnta+=Y\n cntb+=Y\n if A>2*C:\n cntc+=2*(X-Y)\n else:\n cnta+=(X-Y)\nelse:\n if A+B>2*C:\n cntc+=2*X\n else:\n cnta+=X\n cntb+=X\n if B>2*C:\n cntc+=2*(Y-X)\n else:\n cntb+=(Y-X)\n\nprint(cnta*A+cntb*B+cntc*C)'] | ['Runtime Error', 'Accepted'] | ['s454725247', 's851405744'] | [3064.0, 3064.0] | [19.0, 17.0] | [276, 327] |
p03373 | u641722141 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['#-*- coding: utf-8 -*-\na, b, c, x, y = map(int, input().split())\nm = min(x, y)\nans = 0\nif (a + b) >= c * 2:\n ans += c * 2 * min(x, y)\n print(ans)\n x -= m\n y -= m\n\nif a >= c * 2:\n ans += c * 2 * x\n x = 0\nif b >= c * 2:\n ans += c * 2 * y\n y = 0\nprint(ans + x*a + y*b)\n', '#-*- coding: utf-8 -*-\na, b, c, x, y = map(int, input().split())\nm = min(x, y)\nans = 0\nif (a + b) >= c * 2:\n ans += c * 2 * min(x, y)\n x -= m\n y -= m\n\nif a >= c * 2:\n ans += c * 2 * x\n x = 0\nif b >= c * 2:\n ans += c * 2 * y\n y = 0\nprint(ans + x*a + y*b)\n'] | ['Wrong Answer', 'Accepted'] | ['s649386026', 's913068162'] | [3064.0, 3060.0] | [17.0, 17.0] | [290, 275] |
p03373 | u727025296 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['# -*- coding: utf-8 -*-\n\nimport sys\n\nargs = sys.argv\n\na_value = int(args[1])\nb_value = int(args[2])\nc_value = int(args[3])\na_number = int(args[4])\nb_number = int(args[5])\n\nvalue = 0\n\nif a_value + b_value <= c_value * 2:\n value = a_value * a_number + b_value * b_number\n print (value)\nelse:\n if a_number >= b_number:\n value += c_value * 2 * b_number\n if (a_number - b_number) * a_value >= (a_number - b_number) * c_value * 2:\n value += (a_number - b_number) * c_value * 2\n else:\n value += (a_number - b_number) * a_value\n\n else:\n value += c_value * 2 * a_number\n if (b_number - a_number) * b_value >= (b_number - a_number) * c_value * 2:\n value += (b_number - a_number) * c_value * 2\n else:\n value += (b_number - a_number) * a_value\n print (value)', '# -*- coding: utf-8 -*-\n\nimport sys\n\nlst = list(map(int, input().split()))\n\na_value = lst[0]\nb_value = lst[1]\nc_value = lst[2]\na_number = lst[3]\nb_number = lst[4]\n\nvalue = 0\n\nif a_value + b_value <= c_value * 2:\n value = a_value * a_number + b_value * b_number\n print (value)\nelse:\n if a_number >= b_number:\n value += c_value * 2 * b_number\n if (a_number - b_number) * a_value >= (a_number - b_number) * c_value * 2:\n value += (a_number - b_number) * c_value * 2\n else:\n value += (a_number - b_number) * a_value\n\n else:\n value += c_value * 2 * a_number\n if (b_number - a_number) * b_value >= (b_number - a_number) * c_value * 2:\n value += (b_number - a_number) * c_value * 2\n else:\n value += (b_number - a_number) * b_value\n print (value)\n'] | ['Runtime Error', 'Accepted'] | ['s782017563', 's005325575'] | [3064.0, 3064.0] | [18.0, 18.0] | [847, 840] |
p03373 | u731436822 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['A,B,C,X,Y = map(int,input().split())\n\ni = 0\nSUM = X*A + Y*B\nif Y >= X:\n while(X-i>=0):\n ans = min(SUM,(X-i)*A + (Y-i)*B + 2*i*C)\n i += 1\n else:\n for j in range(1,Y-X+1):\n ans = min(SUM,(Y-X-j)*B + 2*(X+j)*C)\nelse:\n while(Y-i>=0):\n ans = min(SUM,(X-i)*A + (Y-i)*B + 2*i*C)\n i += 1\n else:\n for j in range(1,X-Y+1):\n ans = min(SUM,(X-Y-j)*B + 2*(Y+j)*C)\nprint(ans)', '# Half and Half\na,b,c,x,y = map(int,input().split())\n\nans = []\nfor i in range(max(x,y)):\n ans.append(2*c*i + a*max(0,x-i) + b*max(0,y-i))\n print(ans)\n\nprint(min(ans))', 'A,B,C,X,Y = map(int,input().split())\n\ni = 0\nSUM = X*A + Y*B\nif Y >= X:\n while(X-i>=0):\n ans = min(SUM,(X-i)*A + (Y-i)*B + 2*i*C)\n i += 1\n else:\n for j in range(1,Y-X+1):\n ans = min(SUM,(Y-X-j)*B + 2*(X+j)*C)\nelse:\n while(Y-i>=0):\n ans = min(SUM,(X-i)*A + (Y-i)*B + 2*i*C)\n i += 1\n else:\n for j in range(X-Y):\n ans = min(SUM,(X-Y-j)*B + 2*(Y+j)*C)\nprint(ans)', '# Half and Half\na,b,c,x,y = map(int,input().split())\n\nans = []\nfor i in range(max(x,y)+1):\n ans.append(2*c*i + a*max(0,x-i) + b*max(0,y-i))\n\nprint(min(ans))'] | ['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s295851721', 's744223672', 's764360111', 's672967805'] | [3064.0, 134472.0, 3064.0, 7096.0] | [86.0, 1284.0, 95.0, 100.0] | [437, 172, 433, 159] |
p03373 | u780354103 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['A,B,C,X,Y = map(int,input().split())\na = 0\n\nif A+B < C*2:\n a += (A+B) * min(X,Y)\nelse\n a += C*2 * min(X,Y)\nif X > Y:\n a += min(A,C*2)*(X-Y)\nelse:\n a += min(B,C*2)*(Y-X)\nprint(a)', 'A,B,C,X,Y = map(int,input().split())\na = 0\n\nif A+B < C*2:\n a += (A+B) * min(X,Y)\nelse:\n a += C*2 * min(X,Y)\nif X > Y:\n a += min(A,C*2) * (X-Y)\nelse:\n a += min(B,C*2) * (Y-X)\nprint(a)'] | ['Runtime Error', 'Accepted'] | ['s480079582', 's778941389'] | [2940.0, 3060.0] | [17.0, 20.0] | [189, 194] |
p03373 | u781262926 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['inputs = open(0).readlines()\na, b, c, x, y = map(int, open(0).read().split())\n\nprices = []\nprices.append(a*x + b*y)\nprices.append(a*abs(x-y) + 2*c*min(x, y))\nprices.append(b*abs(x-y) + 2*c*min(x, y))\nprices.append(2*c*max(x, y))\nprint(min(prices))', 'a, b, c, x, y = map(int, open(0).read().split())\na, b, x, y = (b, a, y, x) if x > y else (a, b, x, y)\n\nprint(min(a*x + b*y, 2*c*x + b*(y-x), 2*c*y))'] | ['Runtime Error', 'Accepted'] | ['s055751741', 's513439532'] | [3064.0, 3060.0] | [18.0, 17.0] | [247, 148] |
p03373 | u796708718 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['A, B, C, X, Y = [int(x) for x in input().split(" ")]\n\nmin = max(A,B,C*2) * 10**5\n\nfor k in range(0,2*max(X,Y)+1,2):\n if A*(X-k/2)+B*(Y-k/2)+C*k < min:\n min = A*max(0,X-k/2)+B*max(0,Y-k/2)+C*k\n \nprint(int(min))', 'A, B, C, X, Y = [int(x) for x in input().split(" ")]\n\nmin = max(A,B,C)*max(X,Y)*2\n\nfor k in range(0,max(X,Y)*2+1,2):\n if A*max(0,X-k/2)+B*max(0,Y-k/2)+C*k < min:\n min = A*max(0,X-k/2)+B*max(0,Y-k/2)+C*k\n \nprint(int(min))'] | ['Wrong Answer', 'Accepted'] | ['s310176916', 's454742835'] | [3064.0, 3064.0] | [193.0, 214.0] | [220, 231] |
p03373 | u799479335 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['A,B,C,X,Y = map(int, input().split())\n\nans = 0\n\nif (A<2*C)&(B<2*C):\n ans += A*X + B*Y\nelse:\n if A>=B:\n ans += 2*C * X\n if (B>2*C)&(Y>X):\n ans += 2*C * (Y - X)\n elif Y>X:\n\t ans += B * (Y - X)\n else:\n ans += 2*C * Y\n if (A>2*C)&(X>Y):\n ans += 2*C * (X - Y)\n elif X>Y:\n\t ans += A * (X - Y)\n \nprint(ans)', 'A,B,C,X,Y = map(int, input().split())\n\nans = 0\n\nif A+B <= 2*C:\n ans += A*X + B*Y\nelse:\n if A*X>B*Y:\n ans += C * 2*X\n if Y>X:\n\t ans += B * (Y - X)\n else:\n ans += C * 2*Y\n if X>Y:\n\t ans += A * (X - Y)\n \nprint(ans)', 'A,B,C,X,Y = map(int, input().split())\n\nans = 0\n\nif A+B<2*C:\n ans += (A+B)*min(X,Y)\nelse:\n ans += 2*C * min(X,Y)\n \nif X>Y:\n ans += min(A,2*C )*(X-Y)\nelse:\n ans += min(B,2*C )*(Y-X)\n \nprint(ans)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s596907838', 's783089758', 's370247731'] | [3064.0, 3064.0, 3064.0] | [17.0, 17.0, 18.0] | [339, 235, 198] |
p03373 | u898967808 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['a,b,c,x,y = map(int,input().split())\nmin_total = a*x + b*y\nfor ci in range(max(x,y)*2+1):\n ai = max(0,x - ci//2)\n bi = max(0,y - ci//2)\n \n total = ai*a + bi*b + ci*c\n if min_total > total:\n min_total = total\n if min_total < 100200000:\n print(ai,bi,ci)\nprint(min_total) ', 'a,b,c,x,y = map(int,input().split())\nmin_total = a*x + b*y\nfor ci in range(max(x,y)*2+1):\n ai = max(0,x - ci//2)\n bi = max(0,y - ci//2)\n \n total = ai*a + bi*b + ci*c\n if min_total > total:# and (ai+ci//2 >= x) and (bi+ci//2 >= y): \n min_total = total \nprint(min_total) '] | ['Wrong Answer', 'Accepted'] | ['s131820087', 's659355465'] | [3712.0, 3060.0] | [218.0, 217.0] | [290, 301] |
p03373 | u923077302 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['# input\nN, C = map(int, input().split(" "))\nx, v = [], []\nfor i in range(1, N+1):\n xv = list(map(int, input().split(" ")))\n x.append(xv[0])\n v.append(xv[1])\n\n\n\nmax_cal = 0\nS = [[i for i in range(N)]] # stack\nplace = 0 \ncal = 0\nS[0].append(cal)\nS[0].append(place)\nwhile len(S) > 0:\n s = S.pop() # n = len\n \n \n print("pop", s, max_cal)\n if len(s) == 3:\n \n idx = s[0] # first\n next_place = x[idx]\n place_step = min(dist, C - dist)\n next_cal = s[-2] - place_step + v[s[0]]\n max_cal = max(max_cal, next_cal)\n else:\n \n \n place = s[-1]\n idx = s[0] # first\n next_place = x[idx]\n dist = abs(next_place - place)\n place_step = min(dist, C - dist)\n next_cal = s[-2] - place_step + v[idx]\n max_cal = max(max_cal, next_cal)\n S.append(s[1:-2] + [next_cal, next_place])\n place = s[-1]\n idx = s[-3] \n next_place = x[idx]\n #place_step = abs(next_place - place) % C\n place_step = min(dist, C - dist)\n next_cal = s[-2] - place_step + v[idx]\n max_cal = max(max_cal, next_cal)\n S.append(s[:-3] + [next_cal, next_place])\nprint(max_cal)', '# input\nN, C = map(int, input().split(" "))\nx, v = [], []\nfor i in range(1, N+1):\n xv = list(map(int, input().split(" ")))\n x.append(xv[0])\n v.append(xv[1])\n\n\n\nmax_cal = 0\nS = [[i for i in range(N)]] # stack\nplace = 0 \ncal = 0\nS[0].append(cal)\nS[0].append(place)\nwhile len(S) > 0:\n s = S.pop() # n = len\n \n \n if len(s) == 3:\n \n idx = s[0] # first\n next_place = x[idx]\n place_step = min(dist, C - dist)\n next_cal = s[-2] - place_step + v[s[0]]\n max_cal = max(max_cal, next_cal)\n else:\n \n \n place = s[-1]\n idx = s[0] # first\n next_place = x[idx]\n dist = abs(next_place - place)\n place_step = min(dist, C - dist)\n next_cal = s[-2] - place_step + v[idx]\n max_cal = max(max_cal, next_cal)\n S.append(s[1:-2] + [next_cal, next_place])\n place = s[-1]\n idx = s[-3] \n next_place = x[idx]\n #place_step = abs(next_place - place) % C\n place_step = min(dist, C - dist)\n next_cal = s[-2] - place_step + v[idx]\n max_cal = max(max_cal, next_cal)\n S.append(s[:-3] + [next_cal, next_place])\nprint(max_cal)', 'input_str = input()\n\nA, B, C, X, Y = input_str.split(" ")\n\nA = int(A)\nB = int(B)\nC = int(C)\nX = int(X)\nY = int(Y)\n\nanswer = 0\nave_AB = (A + B) / 3\nif ave_AB <= C:\n answer = X*A + Y*B\n print(answer)\nelse:\n xy_min = min(X,Y)\n answer = xy_min * C * 2\n tmp = X - Y\n if tmp > 0:\n if A < C*2:\n answer += tmp*A\n else:\n answer += tmp*C*2\n elif tmp < 0:\n if B < C*2:\n answer += -tmp*B\n else:\n answer += -tmp*C*2\nprint(answer)', '# input\nN, C = map(int, input().split(" "))\nx, v = [], []\nfor i in range(1, N+1):\n xv = list(map(int, input().split(" ")))\n x.append(xv[0])\n v.append(xv[1])\n\n\n\nmax_cal = 0\nS = [[i for i in range(N)]] # stack\nplace = 0 \ncal = 0\nS[0].append(cal)\nS[0].append(place)\nwhile len(S) > 0:\n s = S.pop() # n = len\n \n \n if len(s) == 3:\n \n idx = s[0] # first\n next_place = x[idx]\n place_step = min(dist, C - dist)\n next_cal = s[-2] - place_step + v[s[0]]\n max_cal = max(max_cal, next_cal)\n else:\n \n \n place = s[-1]\n idx = s[0] # first\n next_place = x[idx]\n dist = abs(next_place - place)\n place_step = min(dist, C - dist)\n next_cal = s[-2] - place_step + v[idx]\n max_cal = max(max_cal, next_cal)\n S.append(s[1:-2] + [next_cal, next_place])\n place = s[-1]\n idx = s[-3] \n next_place = x[idx]\n #place_step = abs(next_place - place) % C\n place_step = min(dist, C - dist)\n next_cal = s[-2] - place_step + v[idx]\n max_cal = max(max_cal, next_cal)\n S.append(s[:-3] + [next_cal, next_place])\nprint(max_cal)', 'input_str = input()\n\nA, B, C, X, Y = input_str.split(" ")\n\nA = int(A)\nB = int(B)\nC = int(C)\nX = int(X)\nY = int(Y)\n\nanswer = 0\nave_AB = (A + B) / 2\nif ave_AB <= C:\n answer = X*A + Y*B\nelse:\n xy_min = min(X,Y)\n answer = xy_min * C * 2\n tmp = X - Y\n if tmp > 0:\n if A < C*2:\n answer += tmp*A\n else:\n answer += tmp*C*2\n elif tmp < 0:\n if B < C*2:\n answer += -tmp*B\n else:\n answer += -tmp*C*2\nprint(answer)'] | ['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s264087045', 's331239464', 's540557956', 's694857607', 's545794048'] | [3184.0, 3064.0, 3188.0, 3316.0, 3064.0] | [17.0, 18.0, 21.0, 18.0, 17.0] | [1447, 1418, 509, 1418, 491] |
p03373 | u940780117 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['A,B,C,X,Y=map(int,input().split())\nans=0\ntmp=0\nfor i in range(10**5+1):\n tmp = 2*C*i + A*max(0,X-i) + B*max(0,Y-i)\n if i==0:\n ans = tmp\n if tmp < ans:\n ans = tmp\nprint(ans,i)', 'A,B,C,X,Y=map(int,input().split())\nans=0\ntmp=0\nfor i in range(10**5+1):\n tmp = 2*C*i + A*max(0,X-i) + B*max(0,Y-i)\n if i==0:\n ans = tmp\n if tmp < ans:\n ans = tmp\nprint(ans)\n\n'] | ['Wrong Answer', 'Accepted'] | ['s879578688', 's621681504'] | [3060.0, 2940.0] | [102.0, 112.0] | [197, 197] |
p03373 | u970449052 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['a,b,c,x,y=map(int,input().split())\nl=[]\nl.append(x*a+y*b)\nl.append(2*x*c+max(0,y-x)*b)\nl.append(2*b*c+max(0,x-y)*a)\nprint(min(l))', 'a,b,c,x,y=map(int,input().split())\nl=[]\nl.append(x*a+y*b)\nl.append(2*x*c+max(0,y-x)*b)\nl.append(2*y*c+max(0,x-y)*a)\nprint(min(l))'] | ['Wrong Answer', 'Accepted'] | ['s358091440', 's869035767'] | [3060.0, 3060.0] | [17.0, 19.0] | [129, 129] |
p03373 | u993435350 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['A,B,C,X,Y = map(int,input().split())\n\nD = (A + B) // 2\nC2 = C * 2\n\nans = 0\n\nif C2 <= min(A,B):\n ans += C2 * max(X,Y)\n print(ans)\nelif C2 > max(A,B):\n ans += (A * X) + (B * Y)\n print(ans)\nelse:\n if D >= C:\n if X > Y:\n ans += C2 * Y\n ans += A * (X - Y)\n print(ans)\n if Y > X:\n ans += C2 * X\n ans += B * (Y - X)\n print(ans)\n else:\n ans += (A * X) + (B * Y)\n print(ans)', 'A,B,C,X,Y = map(int,input().split())\n\nC2 = C * 2\ndiff = abs(X - Y)\n\nans = 0\n\nif C2 <= min(A,B):\n ans += C2 * max(X,Y)\n\nelif C2 > A + B:\n ans += (A * X) + (B * Y)\n\nelif C2 <= A + B:\n if A > B:\n ans += C2 * Y + A * diff\n\n else:\n ans += C2 * X + B * diff\n \nprint(ans)', 'A,B,C,X,Y = map(int,input().split())\n\nD = (A + B) // 2\nC2 = C * 2\n\nans = 0\n\nif C2 <= min(A,B):\n ans += C2 * max(X,Y)\n print(ans)\nelif C2 > max(A,B):\n ans += (A * X) + (B * Y)\n print(ans)\nelse:\n if D >= C:\n if X > Y:\n ans += C2 * Y\n ans += A * (X - Y)\n print(ans)\n else:\n ans += (A * X) + (B * Y)\n print(ans)', 'A,B,C,X,Y = map(int,input().split())\n\nC2 = C * 2\ndiff = abs(X - Y)\n\nans = 0\n\nif C2 <= min(A,B):\n ans = C2 * max(X,Y)\n\nelif C2 > A + B:\n ans = (A * X) + (B * Y)\n\nelif C2 <= A + B:\n if A > B:\n ans = C2 * Y + A * diff\n\n else:\n ans = C2 * X + B * diff\n \nprint(ans)\n', 'A,B,C,X,Y = map(int,input().split())\n\nD = (A + B) // 2\nC2 = C * 2\n\nans = 0\n\nif C2 <= min(A,B):\n ans += C2 * max(X,Y)\n print(ans)\nelif C2 > max(A,B):\n ans += (A * X) + (B * Y)\n print(ans)\nelse:\n if D >= C:\n if X > Y:\n ans += C2 * Y\n ans += A * (X - Y)\n print(ans)\n else:\n ans += (A * X) + (B * Y)\n print(ans)', 'A,B,C,X,Y = map(int,input().split())\n\nC2 = C * 2\ndiff = abs(X - Y)\n\nans = 0\n\nif C2 <= min(A,B):\n ans += C2 * max(X,Y)\n\nelif C2 > A + B:\n ans += (A * X) + (B * Y)\n\nelif C2 < A + B:\n if A > B:\n ans += C2 * Y + A * diff\n\n else:\n ans += C2 * X + B * diff\n \nprint(ans)', 'A,B,C,X,Y = map(int,input().split())\n\nC2 = C * 2\ndiff = abs(X - Y)\n\nans = 0\n\nif C2 <= min(A,B):\n ans += C2 * max(X,Y)\n print(ans)\nelif C2 > A + B:\n ans += (A * X) + (B * Y)\n print(ans)\nelif C2 < A + B:\n if A > B:\n ans += C2 * Y + A * diff\n else:\n ans += C2 * X + B * diff', 'A,B,C,X,Y = map(int,input().split())\n\nC2 = C * 2\ndiff = abs(X - Y)\n\nans = 0\n\n\nif C2 > A + B:\n ans = (A * X) + (B * Y)\n\nelif C2 <= A + B:\n if X > Y:\n ans = min(C2 * Y + A * diff,C2 * X)\n\n else:\n ans = min(C2 * X + B * diff,C2 * Y)\n \nprint(ans)'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s123857530', 's416839656', 's452164404', 's457626590', 's471464399', 's655772924', 's896708178', 's179324757'] | [3064.0, 3064.0, 3064.0, 3060.0, 2940.0, 3064.0, 3064.0, 3064.0] | [17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0] | [413, 277, 337, 274, 331, 276, 283, 254] |
p03373 | u995861601 | 2,000 | 262,144 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. | ['a, b, ab, x, y = map(int, input().split())\nif a + b > ab*2:\n ab1 = True\nelse:\n ab1 = False\n\nif a > ab*2:\n a1 = True\nelse:\n a1 = False\n\nif b > ab*2:\n b1 = True\nelse:\n b1 = False\n\nprice = 0\nif x > y:\n if ab1 is True:\n price += ab*2*y\n if a1 is True:\n \t price += ab*2*(x-y)\n else:\n price += a*2*(x-y)\n else:\n price += a*x + b*y\nelse:\n if ab1 is True:\n price += ab*2*x\n if b1 is True:\n price += ab*2*(y-x)\n else:\n price += b*2*(y-x)\n else:\n price += a*x + b*y\n \nprint(price)', 'a, b, ab, x, y = map(int, input().split())\nif a + b > ab*2:\n ab1 = True\nelse:\n ab1 = False\n\nif a > ab*2:\n a1 = True\nelse:\n a1 = False\n\nif b > ab*2:\n b1 = True\nelse:\n b1 = False\n\nprice = 0\nif x > y:\n if ab1 is True:\n price += ab*2*y\n if a1 is True:\n \t price += ab*2*(x-y)\n else:\n price += a*(x-y)\n else:\n price += a*x + b*y\nelse:\n if ab1 is True:\n price += ab*2*x\n if b1 is True:\n price += ab*2*(y-x)\n else:\n price += b*(y-x)\n else:\n price += a*x + b*y\n \nprint(price)'] | ['Wrong Answer', 'Accepted'] | ['s963821996', 's523116580'] | [3064.0, 3064.0] | [17.0, 17.0] | [524, 520] |
p03374 | u039623862 | 2,000 | 262,144 | "Teishi-zushi", a Japanese restaurant, is a plain restaurant with only one round counter. The outer circumference of the counter is C meters. Customers cannot go inside the counter. Nakahashi entered Teishi-zushi, and he was guided to the counter. Now, there are N pieces of sushi (vinegared rice with seafood and so on) on the counter. The distance measured clockwise from the point where Nakahashi is standing to the point where the i-th sushi is placed, is x_i meters. Also, the i-th sushi has a nutritive value of v_i kilocalories. Nakahashi can freely walk around the circumference of the counter. When he reach a point where a sushi is placed, he can eat that sushi and take in its nutrition (naturally, the sushi disappears). However, while walking, he consumes 1 kilocalories per meter. Whenever he is satisfied, he can leave the restaurant from any place (he does not have to return to the initial place). On balance, at most how much nutrition can he take in before he leaves? That is, what is the maximum possible value of the total nutrition taken in minus the total energy consumed? Assume that there are no other customers, and no new sushi will be added to the counter. Also, since Nakahashi has plenty of nutrition in his body, assume that no matter how much he walks and consumes energy, he never dies from hunger. | ['n, c = map(int, input().split())\nsushi = []\nfor i in range(n):\n x, v = map(int, input().split())\n sushi.append((x, v))\nsushi.sort()\nsushi_reversed = list(reversed([(c - x, v) for x, v in sushi]))\n\n\ndef accum_max(s):\n v = 0\n res = [(0, 0)]\n for x_i, v_i in s:\n v += v_i\n res.append(max(res[-1], (v-x_i, x_i)))\n return res[1:]\n\n\nmax_sushi = accum_max(sushi)\nmax_sushi_reversed = accum_max(sushi_reversed)\n\n\ndef solve(s, msr):\n v_max = 0\n v_2d_max = 0\n v = 0\n n = len(s)\n for i in range(n-1):\n x_i, v_i = s[i]\n v += v_i\n if v - x_i*2 > v_2d_max:\n v_2d_max = v - x_i*2\n v_sub = msr[n - 2 - i][0]\n v_max = max(v_max, v_2d_max + v_sub)\n print(i,v_max,v_2d_max,v_sub)\n return v_max\n\n\nl = solve(sushi, max_sushi_reversed)\nr = solve(sushi_reversed, max_sushi)\nprint(max(l, r, max_sushi[-1][0], max_sushi_reversed[-1][0]))\n', 'n, c = map(int, input().split())\nsushi = []\nfor i in range(n):\n x, v = map(int, input().split())\n sushi.append((x, v))\nsushi.sort()\nsushi_reversed = list(reversed([(c - x, v) for x, v in sushi]))\n\n\ndef accum_max(s):\n v = 0\n res = [(0, 0)]\n for x_i, v_i in s:\n v += v_i\n res.append(max(res[-1], (v-x_i, x_i)))\n return res[1:]\n\n\nmax_sushi = accum_max(sushi)\nmax_sushi_reversed = accum_max(sushi_reversed)\n\n\ndef solve(s, msr):\n v_max = 0\n v_2d_max = 0\n v = 0\n n = len(s)\n for i in range(n-1):\n x_i, v_i = s[i]\n v += v_i\n if v - x_i*2 > v_2d_max:\n v_2d_max = v - x_i*2\n v_sub = msr[n - 2 - i][0]\n v_max = max(v_max, v_2d_max + v_sub)\n return v_max\n\n\nl = solve(sushi, max_sushi_reversed)\nr = solve(sushi_reversed, max_sushi)\nprint(max(l, r, max_sushi[-1][0], max_sushi_reversed[-1][0]))\n'] | ['Wrong Answer', 'Accepted'] | ['s424508959', 's061985955'] | [52072.0, 48124.0] | [760.0, 999.0] | [928, 886] |
p03374 | u064408584 | 2,000 | 262,144 | "Teishi-zushi", a Japanese restaurant, is a plain restaurant with only one round counter. The outer circumference of the counter is C meters. Customers cannot go inside the counter. Nakahashi entered Teishi-zushi, and he was guided to the counter. Now, there are N pieces of sushi (vinegared rice with seafood and so on) on the counter. The distance measured clockwise from the point where Nakahashi is standing to the point where the i-th sushi is placed, is x_i meters. Also, the i-th sushi has a nutritive value of v_i kilocalories. Nakahashi can freely walk around the circumference of the counter. When he reach a point where a sushi is placed, he can eat that sushi and take in its nutrition (naturally, the sushi disappears). However, while walking, he consumes 1 kilocalories per meter. Whenever he is satisfied, he can leave the restaurant from any place (he does not have to return to the initial place). On balance, at most how much nutrition can he take in before he leaves? That is, what is the maximum possible value of the total nutrition taken in minus the total energy consumed? Assume that there are no other customers, and no new sushi will be added to the counter. Also, since Nakahashi has plenty of nutrition in his body, assume that no matter how much he walks and consumes energy, he never dies from hunger. | ['n,c=map(int,input().split())\nx=[0]\nv=[]\nfor i in range(n):\n a,b=map(int,input().split())\n x.append(a)\n v.append(b)\n\nx1=[x[i+1]-x[i] for i in range(len(x)-1)]\nx2=[c-x[-1]]+x1[:0:-1]\nh=[0]\nfor i,j in zip(x2,reversed(v)):\n h.append(h[-1]+j+-i)\nt=[0]\nfor i,j in zip(x1,v):\n t.append(t[-1]+j-i)\nhi=h.index(max(h[0:-1]))\nti=t.index(max(t[0:-1]))\ntm=max(t[0:-1])\nhm=max(h[0:-ti])\nh2=[h[i]-c+x[-i] for i in range(1,len(h))]\nt2=[t[i]-x[i] for i in range(1,len(h))]\nprint(h,t)\nprint(h2,t2)\n\n#print(ti,hi)\nprint(max(max(t), max(h), hm+max(t2[0:-ti]),tm+max(h2[:-hi])))', 'n,c=map(int,input().split())\nx=[0]\nv=[]\nfor i in range(n):\n a,b=map(int,input().split())\n x.append(a)\n v.append(b)\n\nx1=[x[i+1]-x[i] for i in range(len(x)-1)]\nx2=[c-x[-1]]+x1[:0:-1]\nh=[0]\nfor i,j in zip(x2,reversed(v)):\n h.append(h[-1]+j+-i)\nt=[0]\nfor i,j in zip(x1,v):\n t.append(t[-1]+j-i)\nhi=h.index(max(h[0:-1]))\nti=t.index(max(t[0:-1]))\ntm=max(t[0:-1])\nhm=max(h[0:-ti])\nh2=[h[i]-c+x[-i] for i in range(1,len(h)-1)]\nt2=[t[i]-x[i] for i in range(1,len(t)-1)]\n\n\n#print(ti,hi)\nprint(max(max(t), max(h), hm+max(t2[0:-ti]),tm+max(h2[:-hi])))', 'n,c=map(int,input().split())\nx=[0]\nv=[]\nfor i in range(n):\n a,b=map(int,input().split())\n x.append(a)\n v.append(b)\n\nx1=[x[i+1]-x[i] for i in range(len(x)-1)]\nx2=[c-x[-1]]+x1[:0:-1]\nh=[0]\nfor i,j in zip(x2,reversed(v)):\n h.append(h[-1]+j+-i)\nt=[0]\nfor i,j in zip(x1,v):\n t.append(t[-1]+j-i)\nhi=h.index(max(h[0:-1]))\nti=t.index(max(t[0:-1]))\ntm=max(t[0:-1])\nhm=max(h[0:-ti])\nh2=[h[i]-c+x[-i] for i in range(1,len(h))]\nt2=[t[i]-x[i] for i in range(1,len(t))]\nprint(h,t)\nprint(h2,t2)\n\n#print(ti,hi)\nprint(max(max(t), max(h), hm+max(t2[0:-ti]),tm+max(h2[:-hi])))', 'n,c=map(int,input().split())\nx=[0]\nv=[]\nfor i in range(n):\n a,b=map(int,input().split())\n x.append(a)\n v.append(b)\n \nx1=[x[i+1]-x[i] for i in range(len(x)-1)]\nx2=[c-x[-1]]+x1[:0:-1]\nh=[0]\nfor i,j in zip(x2,reversed(v)):\n h.append(h[-1]+j+-i)\nt=[0]\nfor i,j in zip(x1,v):\n t.append(t[-1]+j-i)\nhi=h.index(max(h[0:-1]))\nti=t.index(max(t[0:-1]))\n\nhm=max(h[0:-1])\ntm=max(t[0:-1])\n\nprint(max( hm, tm, hm+tm-x[-hi],hm+tm-x[ti]))\n#print(h,t)\n#print(x[-hi],x[ti])', 'n,c=map(int, input().split())\na=[[0,0]]+[list(map(int, input().split())) for i in range(n)]+[[c,0]]\nm=[0]\nh=[0]\nmb=[0]\nhb=[0]\nfor i in range(n+1):\n m.append(m[-1]-a[i+1][0]+a[i][0]+a[i+1][1])\n mb.append(m[-2]-a[i+1][0]+a[i][0]+a[i+1][1]-a[i+1][0])\n h.append(h[-1]-a[-i-1][0]+a[-i-2][0]+a[-i-2][1])\n hb.append(h[-2]-a[-i-1][0]+a[-i-2][0]+a[-i-2][1]-c+a[-i-2][0])\n\nmm=[0]\nfor i in range(n):\n mm.append(max(mm[-1],m[i+1]))\nhm=[0]\nfor i in range(n):\n hm.append(max(hm[-1],h[i+1]))\n \nans=max(hm[-1],mm[-1])\nfor i in range(1,n):\n ans=max(hb[i]+mm[-i-1], mb[i]+hm[-i-1],ans)\nprint(ans)'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s125629260', 's228057928', 's424613468', 's545453278', 's143693878'] | [43832.0, 33920.0, 43828.0, 25672.0, 48808.0] | [479.0, 441.0, 486.0, 401.0, 794.0] | [572, 553, 572, 471, 602] |
p03374 | u106778233 | 2,000 | 262,144 | "Teishi-zushi", a Japanese restaurant, is a plain restaurant with only one round counter. The outer circumference of the counter is C meters. Customers cannot go inside the counter. Nakahashi entered Teishi-zushi, and he was guided to the counter. Now, there are N pieces of sushi (vinegared rice with seafood and so on) on the counter. The distance measured clockwise from the point where Nakahashi is standing to the point where the i-th sushi is placed, is x_i meters. Also, the i-th sushi has a nutritive value of v_i kilocalories. Nakahashi can freely walk around the circumference of the counter. When he reach a point where a sushi is placed, he can eat that sushi and take in its nutrition (naturally, the sushi disappears). However, while walking, he consumes 1 kilocalories per meter. Whenever he is satisfied, he can leave the restaurant from any place (he does not have to return to the initial place). On balance, at most how much nutrition can he take in before he leaves? That is, what is the maximum possible value of the total nutrition taken in minus the total energy consumed? Assume that there are no other customers, and no new sushi will be added to the counter. Also, since Nakahashi has plenty of nutrition in his body, assume that no matter how much he walks and consumes energy, he never dies from hunger. | ['import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**15\nmod = 10**9+7\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\n\n\ndef main():\n n,C = LI()\n a = [LI() for _ in range(n)]\n u = [_[0] for _ in a]\n x = [_[1] for _ in a]\n b=c=d=e=[0] * n\n b[0] = x[0]\n c[-1] = x[-1]\n for i in range(1, n):\n b[i] = b[i-1] + x[i]\n for i in range(n-2, -1, -1):\n c[i] = c[i+1] + x[i]\n d[0] = x[0] - u[0]\n e[-1] = x[-1] - (C-u[-1])\n for i in range(1, n):\n d[i] = max(b[i]-u[i], d[i-1])\n for i in range(n-2, -1, -1):\n e[i] = max(c[i]-(C-u[i]), e[i+1])\n r = max(d[-1], e[0], 0)\n for i in range(n):\n try:\n r = max(r,b[i]-u[i]*2+e[i+1])\n try:\n r = max(r,c[i]-(C-u[i])*2+d[i-1])\n \n return r\n\nprint(main())\n', 'import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**15\nmod = 10**9+7\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\n\n\ndef main():\n n,C = LI()\n a = [LI() for _ in range(n)]\n u = [_[0] for _ in a]\n x = [_[1] for _ in a]\n b = [0] * n\n c = [0] * n\n d = [0] * n\n e = [0] * n\n b[0] = x[0]\n c[-1] = x[-1]\n for i in range(1, n):\n b[i] = b[i-1] + x[i]\n for i in range(n-2, -1, -1):\n c[i] = c[i+1] + x[i]\n d[0] = x[0] - u[0]\n e[-1] = x[-1] - (C-u[-1])\n for i in range(1, n):\n d[i] = max(b[i]-u[i], d[i-1])\n for i in range(n-2, -1, -1):\n e[i] = max(c[i]-(C-u[i]), e[i+1])\n\n r = max(d[-1], e[0], 0)\n for i in range(n):\n if i < n-1 and r < b[i] - u[i] * 2 + e[i+1]:\n r = b[i] - u[i] * 2 + e[i+1]\n if i > 0 and r < c[i] - (C-u[i]) * 2 + d[i-1]:\n r = c[i] - (C-u[i]) * 2 + d[i-1]\n\n\n return r\n\n\n\nprint(main())\n\n###'] | ['Runtime Error', 'Accepted'] | ['s897687998', 's850690545'] | [3064.0, 42844.0] | [17.0, 376.0] | [1256, 1376] |
p03374 | u189023301 | 2,000 | 262,144 | "Teishi-zushi", a Japanese restaurant, is a plain restaurant with only one round counter. The outer circumference of the counter is C meters. Customers cannot go inside the counter. Nakahashi entered Teishi-zushi, and he was guided to the counter. Now, there are N pieces of sushi (vinegared rice with seafood and so on) on the counter. The distance measured clockwise from the point where Nakahashi is standing to the point where the i-th sushi is placed, is x_i meters. Also, the i-th sushi has a nutritive value of v_i kilocalories. Nakahashi can freely walk around the circumference of the counter. When he reach a point where a sushi is placed, he can eat that sushi and take in its nutrition (naturally, the sushi disappears). However, while walking, he consumes 1 kilocalories per meter. Whenever he is satisfied, he can leave the restaurant from any place (he does not have to return to the initial place). On balance, at most how much nutrition can he take in before he leaves? That is, what is the maximum possible value of the total nutrition taken in minus the total energy consumed? Assume that there are no other customers, and no new sushi will be added to the counter. Also, since Nakahashi has plenty of nutrition in his body, assume that no matter how much he walks and consumes energy, he never dies from hunger. | ['import numpy as np\nimport sys\ninput2 = sys.stdin.read\n\nn, c = map(int, input().split())\nAV = np.array(list(map(int, input2().rsplit())), dtype=np.int64)\nA, V = AV[::2], AV[1::2]\nB = (c - A)[::-1]\nXA = np.cumsum(V) - A\nXB = np.cumsum(V[::-1]) - B\nRSA, RSB = XA - A, XB - B\n\nXRA, XRB = 0, 0\nfor i in range(n):\n if RSA[i] > 0:\n XRA = max(XRA, RSA[i] + XB[:n - 1 - i].max())\n else:\n break\n\nfor i in range(n):\n if RSB[i] > 0:\n XRB = max(XRB, RSB[i] + XA[:n - 1 - i].max())\n else:\n break\n\nprint(max(0, max(XA), max(XB), XRA, XRB))\n', 'import numpy as np\nimport sys\ninput2 = sys.stdin.read\n\n# A: Anti-clockwise, B: Clockwise, V: Values\nn, c = map(int, input().split())\nAV = np.array(list(map(int, input2().rsplit())), dtype=np.int64)\nA, V = AV[::2], AV[1::2]\nB = (c - A)[::-1]\n\nXA = np.cumsum(V) - A\nXB = np.cumsum(V[::-1]) - B\nRSA, RSB = XA - A, XB - B # Cumulative Values returning to Start\n\nMA, MB = XA.max(), XB.max()\nmai, mbi = 0, 0\n\nfor i, x in enumerate(XA):\n if x == MA:\n mai = i\n\nfor i, x in enumerate(XB):\n if x == MB:\n mbi = i\n\nMRA = max(0, RSA[:n - mbi].max())\nMRB = max(0, RSB[:n - mai].max())\n\nprint(max(MA + MRB, MB + MRA))\n', 'import numpy as np\nimport sys\ninput2 = sys.stdin.read\n\n# A: Anti-clockwise, B: Clockwise, V: Values\nn, c = map(int, input().split())\nAV = np.array(list(map(int, input2().rsplit())), dtype=np.int64)\nA, V = AV[::2], AV[1::2]\nB = (c - A)[::-1]\n\nXA = np.cumsum(V) - A\nXB = np.cumsum(V[::-1]) - B\nRXA, RXB = XA - A, XB - B # Cumulative Values returning to Start\n\nMA = np.zeros(n + 1, dtype=np.int64)\nMB = np.zeros(n + 1, dtype=np.int64)\nMRA = np.zeros(n + 1, dtype=np.int64)\nMRB = np.zeros(n + 1, dtype=np.int64)\n\n\ndef max_mem(lis, mlis):\n for i in range(n):\n mlis[i + 1] = max(mlis[i], lis[i])\n\n\nmax_mem(XA, MA)\nmax_mem(XB, MB)\nmax_mem(RXA, MRA)\nmax_mem(RXB, MRB)\n\nif n == 1:\n print(MA[1])\n exit()\n\n\n\nres1, res2 = 0, 0\nfor i in range(n + 1):\n res1 = max(res1, MA[i] + MRB[n - i])\n res2 = max(res2, MB[i] + MRA[n - i])\n #print(res1, res2)\n\nprint(max(res1, res2))\n'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s301968593', 's538598008', 's913958734'] | [34220.0, 34228.0, 34232.0] | [2109.0, 261.0, 769.0] | [565, 626, 910] |
p03374 | u340781749 | 2,000 | 262,144 | "Teishi-zushi", a Japanese restaurant, is a plain restaurant with only one round counter. The outer circumference of the counter is C meters. Customers cannot go inside the counter. Nakahashi entered Teishi-zushi, and he was guided to the counter. Now, there are N pieces of sushi (vinegared rice with seafood and so on) on the counter. The distance measured clockwise from the point where Nakahashi is standing to the point where the i-th sushi is placed, is x_i meters. Also, the i-th sushi has a nutritive value of v_i kilocalories. Nakahashi can freely walk around the circumference of the counter. When he reach a point where a sushi is placed, he can eat that sushi and take in its nutrition (naturally, the sushi disappears). However, while walking, he consumes 1 kilocalories per meter. Whenever he is satisfied, he can leave the restaurant from any place (he does not have to return to the initial place). On balance, at most how much nutrition can he take in before he leaves? That is, what is the maximum possible value of the total nutrition taken in minus the total energy consumed? Assume that there are no other customers, and no new sushi will be added to the counter. Also, since Nakahashi has plenty of nutrition in his body, assume that no matter how much he walks and consumes energy, he never dies from hunger. | ['from functools import reduce\n\nimport numpy as np\n\n\ndef get_max():\n a = 0\n\n def _max(x):\n nonlocal a\n a = max(a, x)\n return a\n\n return _max\n\n\ndef solve(fwd, bck):\n dp = []\n cur = 0\n for x, v in fwd:\n cur -= x\n cur += v\n dp.append(cur)\n\n dp = list(map(get_max(), dp))\n\n cur = 0\n ans = 0\n for i, (x, v) in enumerate(bck[:-1]):\n cur -= 2 * x\n cur += v\n \n ans = max(ans, dp[n - i - 2] + cur)\n \n\n return ans\n\n\nn, c = map(int, input().split())\nsushi = [list(map(int, input().split())) for _ in range(n)]\n\nfwd = np.array(sushi).T\nfwd[0] = np.diff(np.concatenate(([0], fwd[0])))\nfwd = fwd.T.tolist()\n\nbck = np.array(sushi).T\nbck[0] = np.diff(np.concatenate(([0], (c - bck[0])[::-1])))\nbck[1] = bck[1][::-1]\nbck = bck.T.tolist()\n\nprint(max(solve(fwd, bck), solve(bck, fwd)))\n', 'import numpy as np\n\n\ndef get_max():\n a = 0\n\n def _max(x):\n nonlocal a\n a = max(a, x)\n return a\n\n return _max\n\n\ndef solve(fwd, bck):\n dp = []\n cur = 0\n for x, v in fwd:\n cur -= x\n cur += v\n dp.append(cur)\n\n dp = list(map(get_max(), dp))\n\n cur = 0\n ans = dp[-1]\n for i, (x, v) in enumerate(bck[:-1]):\n cur -= 2 * x\n cur += v\n \n ans = max(ans, dp[n - i - 2] + cur)\n \n\n return ans\n\n\nn, c = map(int, input().split())\nsushi = [list(map(int, input().split())) for _ in range(n)]\n\nfwd = np.array(sushi).T\nfwd[0] = np.diff(np.concatenate(([0], fwd[0])))\nfwd = fwd.T.tolist()\n\nbck = np.array(sushi).T\nbck[0] = np.diff(np.concatenate(([0], (c - bck[0])[::-1])))\nbck[1] = bck[1][::-1]\nbck = bck.T.tolist()\n\n# print(fwd)\n# print(bck)\n\nprint(max(solve(fwd, bck), solve(bck, fwd)))\n'] | ['Wrong Answer', 'Accepted'] | ['s549218860', 's780232701'] | [69668.0, 71708.0] | [1489.0, 854.0] | [957, 959] |
p03374 | u367130284 | 2,000 | 262,144 | "Teishi-zushi", a Japanese restaurant, is a plain restaurant with only one round counter. The outer circumference of the counter is C meters. Customers cannot go inside the counter. Nakahashi entered Teishi-zushi, and he was guided to the counter. Now, there are N pieces of sushi (vinegared rice with seafood and so on) on the counter. The distance measured clockwise from the point where Nakahashi is standing to the point where the i-th sushi is placed, is x_i meters. Also, the i-th sushi has a nutritive value of v_i kilocalories. Nakahashi can freely walk around the circumference of the counter. When he reach a point where a sushi is placed, he can eat that sushi and take in its nutrition (naturally, the sushi disappears). However, while walking, he consumes 1 kilocalories per meter. Whenever he is satisfied, he can leave the restaurant from any place (he does not have to return to the initial place). On balance, at most how much nutrition can he take in before he leaves? That is, what is the maximum possible value of the total nutrition taken in minus the total energy consumed? Assume that there are no other customers, and no new sushi will be added to the counter. Also, since Nakahashi has plenty of nutrition in his body, assume that no matter how much he walks and consumes energy, he never dies from hunger. | ['n,c = map(int,input().split())\nx = [0]\nv = [0]\nrf = [0] * (n+2)\nrg = [0] * (n+2)\nlf = [0] * (n+2)\nlg = [0] * (n+2)\nfor i in range(0,n):\n X,V = map(int,input().split())\n x.append(X)\n v.append(V)\nfor i in range(0,n):\n rf[i+1] = rf[i] + v[i+1]\n rg[i+1] = max(rg[i],rf[i+1] - x[i+1])\nfor i in range(n+1,1,-1):\n lf[i-1] = lf[i] + v[i-1]\n lg[i-1] = max(lg[i],lf[i-1] - (c-x[i-1]))\n\n#print(lg[::-1])\n#print(rg)\n\nfor i in range(1,n):\n ans = max(ans,rg[i]+lg[i+1] - x[i],rg[i]+lg[i+1] - (c - x[i+1]))\nprint(ans)', 'from itertools import*\nfrom numpy import array\nn,c=map(int,input().split())\n\nl1=[]\nl2=[]\nfor i in range(n):\n x,v=map(int,input().split())\n l1.append(x)\n l2.append(v)\n#print(l1,l2)\n\nll=array([0]+l1)\nlll=array([0]+list(accumulate(l2)))\nlr=array([0]+[c-i for i in l1][::-1])\nllr=array([0]+list(accumulate(l2[::-1])))\nx=lll-ll\ny=llr-lr\nfor i in range(1,n+1):\n x[i]=max(x[i-1],x[i])\n y[i]=max(y[i-1],y[i])\nz=array([min(ll[::-1][i],lr[i])for i in range(n+1)])\nprint(max(x[::-1]+y-z))\n'] | ['Runtime Error', 'Accepted'] | ['s976169894', 's195835969'] | [28392.0, 29900.0] | [503.0, 789.0] | [526, 493] |
p03374 | u375616706 | 2,000 | 262,144 | "Teishi-zushi", a Japanese restaurant, is a plain restaurant with only one round counter. The outer circumference of the counter is C meters. Customers cannot go inside the counter. Nakahashi entered Teishi-zushi, and he was guided to the counter. Now, there are N pieces of sushi (vinegared rice with seafood and so on) on the counter. The distance measured clockwise from the point where Nakahashi is standing to the point where the i-th sushi is placed, is x_i meters. Also, the i-th sushi has a nutritive value of v_i kilocalories. Nakahashi can freely walk around the circumference of the counter. When he reach a point where a sushi is placed, he can eat that sushi and take in its nutrition (naturally, the sushi disappears). However, while walking, he consumes 1 kilocalories per meter. Whenever he is satisfied, he can leave the restaurant from any place (he does not have to return to the initial place). On balance, at most how much nutrition can he take in before he leaves? That is, what is the maximum possible value of the total nutrition taken in minus the total energy consumed? Assume that there are no other customers, and no new sushi will be added to the counter. Also, since Nakahashi has plenty of nutrition in his body, assume that no matter how much he walks and consumes energy, he never dies from hunger. | ['from itertools import accumulate\n# python template for atcoder1\nimport sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\nN, C = map(int, input().split())\n\nposDist = [0]*N\nposVal = [0]*N\nfor i in range(N):\n d, v = list(map(int, input().split()))\n posDist[i] = d\n posVal[i] = d\n\nnegDist = [0]*N\nnegVal = [0]*N\nfor i, z in enumerate(zip(posDist, posVal)):\n negDist[N-i-1] = z[0]\n negVal[N-i-1] = z[1]\n\n\nposDist = [0]+posDist\nnegDist = [0]+negDist\n\nposVal = [0]+list(accumulate(posVal))\nnegVal = [0]+list(accumulate(negVal))\n# print(posDist)\n\n# print(posVal)\n\nfor i, d in enumerate(posDist):\n posVal[i] -= d\nfor i, d in enumerate(negDist):\n negVal[i] -= d\nans = 0\n\n# print("after")\n# print(posVal)\n\nfor l in range(N+1):\n if negVal[l] < 0:\n continue\n for r in range(N-l+1):\n tmp = posVal[r]+negVal[l]-min(posDist[r], negDist[l])\n #print("l,r->", l, r, tmp)\n ans = max(tmp, ans)\n# print(ans)\nprint(0)\n', 'from itertools import accumulate\n# python template for atcoder1\nimport sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\nN, C = map(int, input().split())\n\nposDist = []\nposVal = []\nfor _ in range(N):\n d, v = list(map(int, input().split()))\n posDist.append(d)\n posVal.append(v)\n\nnegDist = []\nnegVal = []\nfor d, v in zip(reversed(posDist), reversed(posVal)):\n negDist.append(C-d)\n negVal.append(v)\n\n\nposDist = [0]+posDist\nnegDist = [0]+negDist\n\nposVal = [0]+list(accumulate(posVal))\nnegVal = [0]+list(accumulate(negVal))\n# print(posDist)\n\n# print(posVal)\n\nfor i, d in enumerate(posDist):\n posVal[i] -= d\nfor i, d in enumerate(negDist):\n negVal[i] -= d\nans = 0\n# print("after")\n# print(posVal)\n\nfor l in range(N+1):\n if negVal[l] < 0:\n continue\n for r in range(N-l+1):\n tmp = posVal[r]+negVal[l]-posDist[r] - \\\n negDist[l]-min(posDist[r], negDist[l])\n #print("l,r->", l, r, tmp)\n ans = max(tmp, ans)\nprint(ans)\n', "# python template for atcoder1\nimport sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\nN, C = map(int, input().split())\nsushis = [list(map(int, input().split())) for _ in range(N)]\n\n\n\n\n\nvalA = []\nvalArev = []\nsumV = 0\ntmpMax = -float('inf')\n\nfor d, v in sushis:\n sumV += v\n valArev.append(sumV-2*d)\n tmpMax = max(tmpMax, sumV-d)\n valA.append(tmpMax)\n\nvalB = []\nvalBrev = []\nsumV = 0\ntmpMax = -float('inf')\nfor d, v in reversed(sushis):\n sumV += v\n revD = C-d\n valBrev.append(sumV-2*revD)\n tmpMax = max(tmpMax, sumV-revD)\n valB.append(tmpMax)\n\n\n\nans = max(valA+valB+[0])\n# O->A->O->B\n\nfor i in range(N-1):\n ans = max(ans, valArev[i]+valB[N-i-2]) \n\n# O->B->O->A\nfor i in range(N-1):\n ans = max(ans, valBrev[i]+valA[N-i-2])\nprint(ans)\n"] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s212879900', 's632411156', 's966966654'] | [20204.0, 25976.0, 46752.0] | [2105.0, 2105.0, 435.0] | [1006, 1029, 1163] |
p03374 | u608088992 | 2,000 | 262,144 | "Teishi-zushi", a Japanese restaurant, is a plain restaurant with only one round counter. The outer circumference of the counter is C meters. Customers cannot go inside the counter. Nakahashi entered Teishi-zushi, and he was guided to the counter. Now, there are N pieces of sushi (vinegared rice with seafood and so on) on the counter. The distance measured clockwise from the point where Nakahashi is standing to the point where the i-th sushi is placed, is x_i meters. Also, the i-th sushi has a nutritive value of v_i kilocalories. Nakahashi can freely walk around the circumference of the counter. When he reach a point where a sushi is placed, he can eat that sushi and take in its nutrition (naturally, the sushi disappears). However, while walking, he consumes 1 kilocalories per meter. Whenever he is satisfied, he can leave the restaurant from any place (he does not have to return to the initial place). On balance, at most how much nutrition can he take in before he leaves? That is, what is the maximum possible value of the total nutrition taken in minus the total energy consumed? Assume that there are no other customers, and no new sushi will be added to the counter. Also, since Nakahashi has plenty of nutrition in his body, assume that no matter how much he walks and consumes energy, he never dies from hunger. | ['N, C = map(int, input().split())\nSushi = [[int(info) for info in input().split()] for n in range(N)]\nClocksum = [0 for i in range(N+1)]\nAntiClocksum = [0 for i in range(N+1)]\nmaxClocksum, maxAntisum = [0 for i in range(N+1)], [0 for i in range(N+1)]\nfor i in range(N): \n Clocksum[i+1] = Clocksum[i] + Sushi[i][1] - Sushi[i][0] \n AntiClocksum[i+1] = AntiClocksum[i] + Sushi[N-i-1][1] - (C - Sushi[N-i-1][0])\n if i > 0:\n Clocksum[i+1] += Sushi[i-1][0]\n AntiClocksum[i+1] += C - Sushi[N-i][0]\n maxClocksum[i+1] = max(maxClocksum[i], Clocksum[i+1])\n maxAntisum[i+1] = max(maxAntisum[i], AntiClocksum[i+1])\nmaxCalorie = max(max(Clocksum), max(AntiClocksum))\n\n\nClockToAnticlock = 0\nAntiClockToClock = 0\nfor i in range(N-1):\n print(i, N-1-i)\n ClockToAnticlock = max(Clocksum[i+1] + maxAntisum[N-1-i] - Sushi[i][0], ClockToAnticlock)\n AntiClockToClock = max(AntiClocksum[i+1] + maxClocksum[N-1-i] - (C - Sushi[N-i-1][0]), AntiClockToClock)\n\nprint(max(maxCalorie, max(ClockToAnticlock, AntiClockToClock)))', 'N, C = map(int, input().split())\nSushi = [[int(info) for info in input().split()] for n in range(N)]\nClocksum = [0 for i in range(N+1)]\nAntiClocksum = [0 for i in range(N+1)]\nmaxClocksum, maxAntisum = [0 for i in range(N+1)], [0 for i in range(N+1)]\nfor i in range(N): \n Clocksum[i+1] = Clocksum[i] + Sushi[i][1] - Sushi[i][0] \n AntiClocksum[i+1] = AntiClocksum[i] + Sushi[N-i-1][1] - (C - Sushi[N-i-1][0])\n if i > 0:\n Clocksum[i+1] += Sushi[i-1][0]\n AntiClocksum[i+1] += C - Sushi[N-i][0]\n maxClocksum[i+1] = max(maxClocksum[i], Clocksum[i+1])\n maxAntisum[i+1] = max(maxAntisum[i], AntiClocksum[i+1])\nmaxCalorie = max(max(Clocksum), max(AntiClocksum))\n\n\nClockToAnticlock = 0\nAntiClockToClock = 0\nfor i in range(N-1):\n ClockToAnticlock = max(Clocksum[i+1] + maxAntisum[N-1-i] - Sushi[i][0], ClockToAnticlock)\n AntiClockToClock = max(AntiClocksum[i+1] + maxClocksum[N-1-i] - (C - Sushi[N-i-1][0]), AntiClockToClock)\n\nprint(max(maxCalorie, max(ClockToAnticlock, AntiClockToClock)))'] | ['Wrong Answer', 'Accepted'] | ['s268767012', 's052107592'] | [33732.0, 32308.0] | [864.0, 739.0] | [1081, 1061] |
p03374 | u792078574 | 2,000 | 262,144 | "Teishi-zushi", a Japanese restaurant, is a plain restaurant with only one round counter. The outer circumference of the counter is C meters. Customers cannot go inside the counter. Nakahashi entered Teishi-zushi, and he was guided to the counter. Now, there are N pieces of sushi (vinegared rice with seafood and so on) on the counter. The distance measured clockwise from the point where Nakahashi is standing to the point where the i-th sushi is placed, is x_i meters. Also, the i-th sushi has a nutritive value of v_i kilocalories. Nakahashi can freely walk around the circumference of the counter. When he reach a point where a sushi is placed, he can eat that sushi and take in its nutrition (naturally, the sushi disappears). However, while walking, he consumes 1 kilocalories per meter. Whenever he is satisfied, he can leave the restaurant from any place (he does not have to return to the initial place). On balance, at most how much nutrition can he take in before he leaves? That is, what is the maximum possible value of the total nutrition taken in minus the total energy consumed? Assume that there are no other customers, and no new sushi will be added to the counter. Also, since Nakahashi has plenty of nutrition in his body, assume that no matter how much he walks and consumes energy, he never dies from hunger. | ["N, C = map(int, input().split())\nX = []\nV = []\nfor i in range(N):\n x, v = map(int, input().split())\n X.append(x)\n V.append(v)\n\nfrontS = []\nprevX = 0\nv = 0\nfor i in range(N):\n v = v + V[i] - (X[i] - prevX)\n frontS.append(v)\n prevX= X[i]\n\n\nbackMaxS = []\nprevX = C\nv = 0\ntmpMax = float('-inf')\nfor i in range(N-1, -1, -1):\n v = v + V[i] - (prevX - X[i])\n tmpMax = max(tmpMax, v)\n backMaxS.append(tmpMax)\n prevX = X[i]\nbackMaxS.reverse()\nbackMaxS.append(0)\n\nprint([0]+X)\nprint([0]+frontS)\nprint(backMaxS)\n\nans = backMaxS[0]\nfor i in range(N):\n \n ans = max(\n ans,\n frontS[i],\n frontS[i] - X[i] + backMaxS[i+1]\n )\n\nprint(ans)", "N, C = map(int, input().split())\nX = []\nV = []\nfor i in range(N):\n x, v = map(int, input().split())\n X.append(x)\n V.append(v)\n\nfrontS = []\n\nfrontMaxS = []\nprevX = 0\nv = 0\ntmpMax = float('-inf')\nfor i in range(N):\n v = v + V[i] - (X[i] - prevX)\n frontS.append(v)\n tmpMax = max(tmpMax, v)\n frontMaxS.append(tmpMax)\n prevX= X[i]\nfrontMaxS.reverse()\nfrontMaxS.append(0)\n\nbackS = []\n\nbackMaxS = []\nprevX = C\nv = 0\ntmpMax = float('-inf')\nfor i in range(N-1, -1, -1):\n v = v + V[i] - (prevX - X[i])\n backS.append(v)\n tmpMax = max(tmpMax, v)\n backMaxS.append(tmpMax)\n prevX = X[i]\nbackMaxS.reverse()\nbackMaxS.append(0)\n\nans = max(0, backMaxS[0], frontMaxS[0])\nfor i in range(N):\n \n ans = max(\n ans,\n frontS[i],\n frontS[i] - X[i] + backMaxS[i+1],\n backS[i],\n backS[i] - (C-X[-i-1]) + frontMaxS[i+1]\n )\n\nprint(ans)"] | ['Wrong Answer', 'Accepted'] | ['s176243180', 's246603564'] | [29032.0, 21676.0] | [529.0, 613.0] | [717, 944] |
p03374 | u846150137 | 2,000 | 262,144 | "Teishi-zushi", a Japanese restaurant, is a plain restaurant with only one round counter. The outer circumference of the counter is C meters. Customers cannot go inside the counter. Nakahashi entered Teishi-zushi, and he was guided to the counter. Now, there are N pieces of sushi (vinegared rice with seafood and so on) on the counter. The distance measured clockwise from the point where Nakahashi is standing to the point where the i-th sushi is placed, is x_i meters. Also, the i-th sushi has a nutritive value of v_i kilocalories. Nakahashi can freely walk around the circumference of the counter. When he reach a point where a sushi is placed, he can eat that sushi and take in its nutrition (naturally, the sushi disappears). However, while walking, he consumes 1 kilocalories per meter. Whenever he is satisfied, he can leave the restaurant from any place (he does not have to return to the initial place). On balance, at most how much nutrition can he take in before he leaves? That is, what is the maximum possible value of the total nutrition taken in minus the total energy consumed? Assume that there are no other customers, and no new sushi will be added to the counter. Also, since Nakahashi has plenty of nutrition in his body, assume that no matter how much he walks and consumes energy, he never dies from hunger. | ['n,c= [int(i) for i in input().split()]\nt_tk_r=0\nt_md_r=0\ng_tk_r=0\ng_md_r=0\nt_tk_m=0\nt_md_m=0\ng_tk_m=0\ng_md_m=0\nt_tk=[]\nt_md=[]\ng_tk=[]\ng_md=[]\na=[]\nd1=0\nfor i in range(n):\n a.append([int(i) for i in input().split()])\nfor d0,v0 in a:\n t_tk_r+=v0-(d0-d1)\n t_md_r+=v0-(d0-d1)*2\n t_tk_m=max(t_tk_m,t_tk_r)\n t_md_m=max(t_md_m,t_md_r)\n t_tk.append(t_tk_m)\n t_md.append(t_md_m)\n d1=d0\nd1=0 \nfor d0,v0 in a[::-1]:\n g_tk_r+=v0-(c-d0)-d1\n g_md_r+=v0-((c-d0)-d1)*2\n g_tk_m=max(g_tk_m,g_tk_r)\n g_md_m=max(g_md_m,g_md_r)\n g_tk.append(g_tk_m)\n g_md.append(g_md_m)\n d1=(c-d0) \nmx=max(max(t_tk),max(g_tk),0)\nfor i in range(1,n):\n mx=max(mx,t_tk[i]+g_md[n-i],t_md[i]+g_tk[n-i])\nprint(mx)\n', 'n,c= [int(i) for i in input().split()]\nt_tk_r=0\nt_md_r=0\ng_tk_r=0\ng_md_r=0\nt_tk_m=0\nt_md_m=0\ng_tk_m=0\ng_md_m=0\nt_tk=[]\nt_md=[]\ng_tk=[]\ng_md=[]\na=[]\nd1=0\nfor i in range(n):\n a.append([int(i) for i in input().split()])\nfor d0,v0 in a:\n t_tk_r+=v0-(d0-d1)\n t_md_r+=v0-(d0-d1)*2\n t_tk_m=max(t_tk_m,t_tk_r)\n t_md_m=max(t_md_m,t_md_r)\n t_tk.append(t_tk_m)\n t_md.append(t_md_m)\n d1=d0\nd1=0 \nfor d0,v0 in a[::-1]:\n g_tk_r+=v0-(c-d0)-d1\n g_md_r+=v0-((c-d0)-d1)*2\n g_tk_m=max(g_tk_m,g_tk_r)\n g_md_m=max(g_md_m,g_md_r)\n g_tk.append(g_tk_m)\n g_md.append(g_md_m)\n d1=(c-d0) \nmx=max(max(t_tk),max(g_tk),0)\nfor i in range(1,n):\n mx=max(mx,t_tk[i]+g_md[n-i-1],t_md[i]+g_tk[n-i-1])\nprint(mx)\n', 'n,c= [int(i) for i in input().split()]\nt_tk_r=0\nt_md_r=0\ng_tk_r=0\ng_md_r=0\nt_tk_m=0\nt_md_m=0\ng_tk_m=0\ng_md_m=0\nt_tk=[]\nt_md=[]\ng_tk=[]\ng_md=[]\na=[]\nd1=0\n\nfor i in range(n):\n a.append([int(i) for i in input().split()])\n\nfor d0,v0 in a:\n t_tk_r += v0-(d0-d1)\n t_md_r += v0-(d0-d1)*2\n t_tk_m = max(t_tk_m,t_tk_r)\n t_md_m = max(t_md_m,t_md_r)\n t_tk.append(t_tk_m)\n t_md.append(t_md_m)\n d1=d0\n \nd1=0 \nfor d0,v0 in a[::-1]:\n g_tk_r += v0-((c-d0)-d1)\n g_md_r += v0-((c-d0)-d1)*2\n g_tk_m = max(g_tk_m,g_tk_r)\n g_md_m = max(g_md_m,g_md_r)\n g_tk.append(g_tk_m)\n g_md.append(g_md_m)\n d1=(c-d0) \nmx=max(max(t_tk),max(g_tk),0)\n\nfor i in range(n-1):\n mx=max(mx,t_tk[i]+g_md[n-2-i],t_md[i]+g_tk[n-i-2])\nprint(mx)\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s137625025', 's506848145', 's086403295'] | [33540.0, 33540.0, 37124.0] | [661.0, 642.0, 649.0] | [688, 692, 716] |
p03375 | u476199965 | 4,000 | 524,288 | In "Takahashi-ya", a ramen restaurant, basically they have one menu: "ramen", but N kinds of toppings are also offered. When a customer orders a bowl of ramen, for each kind of topping, he/she can choose whether to put it on top of his/her ramen or not. There is no limit on the number of toppings, and it is allowed to have all kinds of toppings or no topping at all. That is, considering the combination of the toppings, 2^N types of ramen can be ordered. Akaki entered Takahashi-ya. She is thinking of ordering some bowls of ramen that satisfy both of the following two conditions: * Do not order multiple bowls of ramen with the exactly same set of toppings. * Each of the N kinds of toppings is on two or more bowls of ramen ordered. You are given N and a prime number M. Find the number of the sets of bowls of ramen that satisfy these conditions, disregarding order, modulo M. Since she is in extreme hunger, ordering any number of bowls of ramen is fine. | ['N,M = list(map(int,input().split()))\n\ntable = [1,1]\nwhile len(table) <= N:\n temp = 1\n for i in range(len(table)-1):\n table[i+1] += temp\n temp = table[i+1]- temp\n table[i+1] = M\n table.append(1)\n\nS = [1]\n\nrev2 = pow(2, M-2, M)\nbase = pow(2, N, M)\nans = 0\nS = [1]\nfor K in range(N+1):\n res = table[K] % M\n res = (res * pow(2, pow(2, N - K, M-1), M)) % M\n b = 1\n v = 0\n T = [0]*(K+2)\n for L in range(K):\n T[L+1] = s = (S[L] + (L+1)*S[L+1]) % M\n v += s * b\n b = (b * base) % M\n v += b\n T[K+1] = 1\n S = T\n res = (res * v) % M\n if K % 2:\n ans -= res\n else:\n ans += res\n ans %= M\n\n base = (base * rev2) % M\nprint(ans)\n', 'N, M = map(int, input().split())\nfact = [1]*(N+1)\nrfact = [1]*(N+1)\nfor i in range(1, N+1):\n fact[i] = r = (i * fact[i-1]) % M\n rfact[i] = pow(r, M-2, M)\n\nS = [1]\n\nrev2 = pow(2, M-2, M)\nbase = pow(2, N, M)\nans = 0\nS = [1]\nfor K in range(N+1):\n res = (fact[N] * rfact[K] * rfact[N-K]) % M\n res = (res * pow(2, pow(2, N - K, M-1), M)) % M\n b = 1\n v = 0\n T = [0]*(K+2)\n for L in range(K):\n T[L+1] = s = (S[L] + (L+1)*S[L+1]) % M\n v += s * b\n b = (b * base) % M\n v += b\n T[K+1] = 1\n S = T\n res = (res * v) % M\n if K % 2:\n ans -= res\n else:\n ans += res\n ans %= M\n\n base = (base * rev2) % M\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s843352618', 's029877459'] | [3316.0, 3436.0] | [4204.0, 3424.0] | [718, 679] |
p03381 | u026155812 | 2,000 | 262,144 | When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N. | ['N = int(input())\nX = [int(i) for i in input().split()]\nX.sort()\nif N%2 == 0:\n for i in range(N):\n if i <= N//2 - 1:\n print(X[N//2])\n else:\n print(X[N//2 - 1])\nelse:\n for i in range(N):\n if i < N//2:\n print((X[N//2] + X[N//2 + 1])/2)\n elif i == N//2 -1:\n print((X[N//2 - 1] + X[N//2 + 1])/2)\n else:\n print((X[N//2 - 1] + X[N//2])/2)', 'from copy import deepcopy\nN = int(input())\nX = [int(i) for i in input().split()]\nx = deepcopy(X)\nX.sort()\nif N%2 == 0:\n for i in x:\n if i <= X[N//2 - 1]:\n print(X[N//2])\n else:\n print(X[N//2 - 1])\nelse:\n for i in x:\n if i < X[N//2]:\n print((X[N//2] + X[N//2 + 1])/2)\n elif i == X[N//2 -1]:\n print((X[N//2 - 1] + X[N//2 + 1])/2)\n else:\n print((X[N//2 - 1] + X[N//2])/2)'] | ['Wrong Answer', 'Accepted'] | ['s310163924', 's242201735'] | [30736.0, 32628.0] | [199.0, 275.0] | [427, 464] |
p03381 | u054957956 | 2,000 | 262,144 | When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N. | ["from sys import exit\nr, s = map(int, input().split())\na = [input() for i in range(r)]\n\ndef check(x):\n cnt = [0 for i in range(300)]\n for i in x:\n cnt[ord(i)] += 1\n odd = sum(i % 2 for i in cnt)\n if odd != len(x) % 2:\n print('NO')\n exit(0)\n\nmidr, mids = None, None\n\ndr = dict()\nfor i in range(r):\n b = tuple(sorted(a[i]))\n if b not in dr:\n dr[b] = 1\n else:\n dr[b] += 1\nodd = 0\nfor k in dr:\n if dr[k] % 2 == 1:\n odd += 1\n midr = k\nif odd != r % 2:\n print('NO')\n exit(0)\nif odd == 1:\n check(midr)\n\nds = dict()\nfor j in range(s):\n b = tuple(sorted([a[i][j] for i in range(r)]))\n if b not in ds:\n ds[b] = 1\n else:\n ds[b] += 1\nodd = 0\nfor k in ds:\n if ds[k] % 2 == 1:\n odd += 1\n mids = k\nif odd != s % 2:\n print('NO')\n exit(0)\nif odd == 1:\n check(mids)\n\nif mids:\n for k in dr:\n indeksi = [i for i in range(r) if tuple(sorted(a[i])) == k]\n check([mids[i] for i in indeksi])\nif midr:\n for k in ds:\n indeksi = [j for j in range(s) if tuple(\n sorted([a[i][j] for i in range(r)])) == k]\n check([midr[j] for j in indeksi])\n\nprint('YES')\n", 'A', 'CODE', "print(r.text[:300] + '...')", 'n = int(input())\na = list(map(int, input().split()))\nb = sorted(a)\ni, j = b[n // 2 - 1], b[n // 2]\nfor x in a:\n if x <= i:\n print(j)\n else:\n print(i)\n'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s167263573', 's287790341', 's543314880', 's995554058', 's442300962'] | [3188.0, 2940.0, 3068.0, 2940.0, 25620.0] | [20.0, 17.0, 17.0, 17.0, 296.0] | [1201, 1, 4, 27, 170] |
p03381 | u066337396 | 2,000 | 262,144 | When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N. | ["from collections import defaultdict\n\n\ndef main():\n h, w = map(int, input().split())\n s = []\n for _ in range(h):\n col = []\n s.append(col)\n for c in input().strip():\n col.append(ord(c))\n c_row = defaultdict(int)\n for col in s:\n c_row[tuple(sorted(col))] += 1\n if sum(c % 2 for c in c_row.values()) > h % 2:\n print('NO')\n return\n for row, c in c_row.items():\n if c % 2:\n count = defaultdict(int)\n for ch in row:\n count[ch] += 1\n if sum(cc % 2 for cc in count.values()) > w % 2:\n print('NO')\n return\n\n c_col = defaultdict(int)\n for col in zip(*s):\n c_col[tuple(sorted(col))] += 1\n if sum(c % 2 for c in c_col.values()) > w % 2:\n print('NO')\n return\n\n for col, c in c_col.items():\n if c % 2:\n count = defaultdict(int)\n for ch in col:\n count[ch] += 1\n if sum(cc % 2 for cc in count.values()) > h % 2:\n print('NO')\n return\n\n if s[0][0] == ord('b'):\n print('NO')\n else:\n print('YES')\n\n\nmain()\n", "# -*- coding: utf-8 -*-\n\nn = int(input())\nxx = list([i, x] for i, x in enumerate(map(int, input().split())))\nxx.sort(key=lambda x: x[1])\n\nmid1 = xx[n // 2][1]\nmid2 = xx[n // 2 - 1][1]\nfor i in range(n // 2):\n xx[i][1] = mid1\nfor i in range(n // 2, n):\n xx[i][1] = mid2\n\nxx.sort()\nprint('\\n'.join(str(x[1]) for x in xx))\n"] | ['Runtime Error', 'Accepted'] | ['s768603434', 's740755731'] | [3316.0, 55492.0] | [21.0, 653.0] | [1182, 326] |
p03381 | u092650292 | 2,000 | 262,144 | When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N. | ['from numpy import median\nfrom copy import deepcopy\n\nn = int(input())\nx = list(map(int,input().split()))\n\nsx = x.sorted()\nnewl = deepcopy(sx)\ndel newl[0]\nbigm = median(newl)\nnewl = deepcopy(sx)\ndel newl[-1]\nminm = median(newl)\n\nmed = median(x)\n\nfor i in x:\n if i > med:\n print(minm)\n else:\n print(maxm)\n', 'n = int(input())\nx = list(map(int,input().split())\n\nfor i in range(n/2):\n print(x[n/2])\n\nfor i in range(n/2):\n print(x[(n-1)//2])\n', 'from numpy import median\nfrom copy import deepcopy\n\nn = int(input())\nx = list(map(int,input().split()))\n\nsx = sorted(x)\nnewl = deepcopy(sx)\ndel newl[0]\nmaxm = median(newl)\nnewl = deepcopy(sx)\ndel newl[-1]\nminm = median(newl)\n\nmed = median(x)\n\nfor i in x:\n if i > med:\n print(int(minm))\n else:\n print(int(maxm))\n'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s535087612', 's859923372', 's169012623'] | [34128.0, 2940.0, 34176.0] | [304.0, 17.0, 1050.0] | [322, 136, 331] |
p03381 | u132434645 | 2,000 | 262,144 | When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N. | ["import sys\nsys.setrecursionlimit(10000)\n\nh, w = map(int, input().split())\ns = [None] * h\nss = [None] * h\nfor i in range(h):\n s[i] = input()\n ss[i] = sorted(s[i])\n\ndef c(x, y):\n l = len(y)\n if l == w: return True\n if l % 2 == 0:\n for i in range(w):\n if i not in y:\n y.append(i)\n if c(x, y): return True\n y.pop()\n else:\n for i in range(w):\n if i not in y:\n ok = True\n for j in range(0, h, 2):\n if j + 1 == h: k = j\n else: k = j + 1\n a, b = x[j], x[k]\n d, e = y[-1], i\n if s[a][d] == s[b][e] and s[a][e] == s[b][d]:\n continue\n ok = False\n if ok:\n y.append(i)\n if c(x, y): return True\n y.pop()\n return False\n \ndef r(x):\n l = len(x)\n if l == h:\n for i in range(w):\n if c(x, [i]): return True\n if l % 2 == 0:\n for i in range(h):\n if i not in x:\n x.append(i)\n if r(x): return True\n x.pop()\n else:\n for i in range(h):\n if i not in x and ss[x[-1]] == ss[i]:\n x.append(i)\n if r(x): return True\n x.pop()\n return False\n \n\nok = True\nfor i in range(h):\n ok = r([i])\n if ok: break\nif ok: print('YES')\nelse: print('NO')\n", 'n = int(input())\na = [int(x) for x in input().split()]\nx = sorted(a)\nm1 = x[n // 2]\nm2 = x[n // 2 - 1]\nfor i in range(n):\n if a[i] < m1: print(m1)\n else: print(m2)\n'] | ['Runtime Error', 'Accepted'] | ['s571057467', 's580496255'] | [3188.0, 25556.0] | [18.0, 332.0] | [1524, 170] |
p03381 | u226155577 | 2,000 | 262,144 | When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N. | ["N = int(input())\n*X, = map(int, input().split())\nY = sorted(X)\np, q = Y[N//2-1:N//2+1]\nans = []\nprint(p, q)\nfor i in range(N):\n if X[i] < q:\n ans.append(q)\n else:\n ans.append(p)\nprint(*ans, sep='\\n')", "n = int(input())\n*x, = map(int, input().split())\ny = sorted(x)\np, q = y[n//2-1:n//2+1]\nans = []\nfor i in range(n):\n if x[i] < q:\n ans.append(q)\n else:\n ans.append(p)\nprint(*ans, sep='\\n')\n\n"] | ['Wrong Answer', 'Accepted'] | ['s194498057', 's079029384'] | [26772.0, 26772.0] | [261.0, 267.0] | [219, 209] |
p03381 | u228759454 | 2,000 | 262,144 | When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N. | ['import numpy as np\n\nN = int(input())\nn_list = list(map(int, input().split()))\n\nM = np.max(n_list)\n\nbest_k_bar = (M - 1) / 2\nbest_k_cand = [x for x in n_list if x >= best_k_bar]\nbest_k = np.min(best_k_cand)\n\nprint(M, best_k)', 'import numpy as np\n\nN = int(input())\nn_list1 = list(map(int, input().split()))\n\nn_list2 = list(n_list1)\nn_list_test = list(n_list1)\n\nprint(n_list_test)\n\nn_list_max = np.max(n_list1)\nn_list_min = np.min(n_list2)\n\nn_list1.remove(n_list_max)\nn_list2.remove(n_list_min)\n\n# print(np.max(n_list))\n# np.median(n_list - )\nn_list1_median = int(np.median(n_list1))\nn_list2_median = int(np.median(n_list2))\n\nprint(n_list1_median)\nprint(n_list2_median)\n\nfor x in n_list_test:\n if n_list1_median >= x:\n print(n_list2_median)\n else:\n print(n_list1_median)\n \n \n\n', 'import numpy as np\n\nN = int(input())\nn_list1 = list(map(int, input().split()))\n\nn_list2 = list(n_list1)\nn_list_test = list(n_list1)\n\n\nn_list_max = np.max(n_list1)\nn_list_min = np.min(n_list2)\n\nn_list1.remove(n_list_max)\nn_list2.remove(n_list_min)\n\n# print(np.max(n_list))\n# np.median(n_list - )\nn_list1_median = int(np.median(n_list1))\nn_list2_median = int(np.median(n_list2))\n\nfor x in n_list_test:\n if n_list1_median >= x:\n print(n_list2_median)\n else:\n print(n_list1_median)\n \n \n\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s276280631', 's635324732', 's783163432'] | [34188.0, 34184.0, 34180.0] | [355.0, 1533.0, 582.0] | [223, 558, 494] |
p03381 | u237362582 | 2,000 | 262,144 | When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N. | ["N = int(input())\n\na = list(map(int,input().split(' ')))\n\nsorted_a = sorted(a)\n\nif N > 2:\n for i in range(int(N/2)):\n print(sorted_a[int(N/2)])\n for i in range(int(N/2)):\n print(sorted_a[int(N/2)-1])\nelse:\n print(a[0])\n", "N = int(input())\n\na = list(map(int,input().split(' ')))\n\nsorted_a = sorted(a)\n\nfor i in range(int(N/2)):\n print(sorted_a[int(N/2)-1])\n\nfor i in range(int(N/2)):\n print(sorted_a[int(N/2)])", "N = int(input())\n\na = list(map(int,input().split(' ')))\n\nsorted_a = sorted(a)\n\n\nfor i in range(int(N/2)):\n print(sorted_a[int(N/2)])\nfor i in range(int(N/2)):\n print(sorted_a[int(N/2)-1])", "N = int(input())\n\na = list(map(int,input().split(' ')))\n\nsorted_a = sorted(a)\n\nfor i in range(N):\n if a[i] < sorted_a[int(N/2)]:\n print(sorted_a[int(N/2)])\n else:\n print(sorted_a[int(N/2)-1])\n\n"] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s178663378', 's659495813', 's925891105', 's993681182'] | [25620.0, 26016.0, 25620.0, 25220.0] | [337.0, 340.0, 338.0, 388.0] | [241, 193, 193, 213] |
p03381 | u268210555 | 2,000 | 262,144 | When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N. | ['n = int(input())\na = list(map(int, input().split()))\ni = max(a)\na.remove(i)\nj = min(a, key=lambda x: abs(i-x*2))\nprint(i, j)', 'n = int(input())\nx = list(map(int, input().split()))\na = sorted(range(n), key=lambda i: x[i])\nl = x[a[n//2-1]]\nr = x[a[n//2]]\nb = [0]*n\nfor i, j in enumerate(a):\n if i < n//2:\n b[j] = r\n else:\n b[j] = l\nfor e in b:\n print(e)'] | ['Wrong Answer', 'Accepted'] | ['s446397360', 's556730910'] | [26016.0, 26772.0] | [114.0, 384.0] | [124, 247] |
p03381 | u289381123 | 2,000 | 262,144 | When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N. | ["n=int(input())\nx=list(map(int,input().split(' ')))\nx1=x[:]\nx1.sort()\nx2=x1[:]\nfor i in range(n):\n l=x[i]\n print(x1)\n x1.remove(l)\n print (x1[int(n/2)-1])\n print(x1)\n x1=x2[:]\n", "n=int(input())\nx=list(map(int,input().split(' ')))\nx1=x[:]\nx1.sort()\nfor i in range(n):\n l=x[i]\n x1.remove(l)\n print (x1[int(n/2)-1])\n x1=x[:]\n", "import numpy as np\nn=int(input())\nx=list(map(int,input().split(' ')))\nx1=x[:]\nx.sort()\nm1=x[int(n/2)-1]\nm2=x[int(n/2)]\nfor i in range(n):\n now=x1[i]\n if x1[i]<=m1:\n print(m2)\n else:\n print(m1)\n"] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s909777002', 's971050512', 's948784633'] | [153600.0, 25620.0, 34188.0] | [1927.0, 2104.0, 447.0] | [193, 155, 216] |
p03381 | u397531548 | 2,000 | 262,144 | When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N. | ['from collections import Counter\nN=int(input())\nX=list(map(int,input().split()))\nY=sorted(X)\na=Y[N//2]\nb=Y[N//2-1]\nfor i in range(N):\n if X[i]<=b:\n print(a)\n break\n else:\n print(b)\n break', 'from collections import Counter\nN=int(input())\nX=list(map(int,input().split()))\nY=sorted(X)\na=Y[N//2]\nb=Y[N//2-1]\nfor i in X:\n if i<=b:\n print(a)\n else:\n print(b)'] | ['Wrong Answer', 'Accepted'] | ['s403092555', 's077620189'] | [26540.0, 25948.0] | [156.0, 300.0] | [220, 182] |
p03381 | u399810298 | 2,000 | 262,144 | When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N. | ["N=int(input())\ninp=list(map(int, input().strip().split(' ')))\nXsort=sorted(inp)\nmed = int(N/2)\nfor i in range(N):\n if Xsort[med-1] > inp[i]:\n print(Xsort[med])\n else:\n print(Xsort[med-1])", "N=int(input())\ninp=list(map(int, input().strip().split(' ')))\nXsort=sorted(inp)\nmed = int(N/2)\nfor i in range(N):\n if Xsort[med-1] >= inp[i] :\n print(Xsort[med])\n else:\n print(Xsort[med-1])"] | ['Wrong Answer', 'Accepted'] | ['s622591608', 's415584357'] | [26772.0, 25620.0] | [326.0, 318.0] | [195, 197] |
p03381 | u411158173 | 2,000 | 262,144 | When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N. | ['import copy\n\nN = int(input())\nX = []\nX = [int(i) for i in input().split()]\n\nY = copy.deepcopy(X)\nY.sort()\n\nlargeMedian = Y[int(N / 2)]\nsmallMedian = Y[int(N / 2)-1]\n\n\nprint(X)\nprint(Y)\nprint(smallMedian)\nprint(largeMedian)\n\nfor i in range(N):\n if X[i] <= smallMedian:\n X[i] = largeMedian\n else:\n X[i] = smallMedian\n\nfor i in range(N):\n print(X[i])\n', "import copy\n\nN = int(input())\nX = []\nX = [int(i) for i in input().split()]\n\nY = copy.deepcopy(X)\nY.sort()\n\nlargeMedian = Y[int(N / 2)]\nsmallMedian = Y[int(N / 2)-1]\n\n\nprint(X)\nprint(Y)\nprint(smallMedian)\nprint(largeMedian)\n\nfor i in range(N):\n if X[i] <= smallMedian:\n X[i] = largeMedian\n else:\n X[i] = smallMedian\n\nfor i in range(N):\n print(X[i], end=' ')\n", 'import copy\n\nN = int(input())\nX = []\nX = [int(i) for i in input().split()]\n\nY = copy.deepcopy(X)\nY.sort()\n\nlargeMedian = Y[int(N / 2)]\nsmallMedian = Y[int(N / 2)-1]\n\nfor i in range(N):\n if X[i] <= smallMedian:\n X[i] = largeMedian\n else:\n X[i] = smallMedian\n\nfor i in range(N):\n print(X[i])\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s342331041', 's379970516', 's602653107'] | [26528.0, 26068.0, 27156.0] | [540.0, 623.0, 484.0] | [371, 380, 313] |
p03381 | u452786862 | 2,000 | 262,144 | When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N. | ['from collections import defaultdict\nH, W = map(int, input().split())\ns = [input() for _ in range(H)]\nif H == 1 and W == 1:\n print(\'YES\')\nelif W==1:\n print(\'NO\')\nelse:\n\n d_h = [[0 for i in range(28)] for _ in range(H)]\n d_w = [[0 for i in range(28)] for _ in range(W)]\n\n for i in range(H):\n for c in s[i]:\n d_h[i][ord(c) - ord("a")] += 1\n\n for i in range(H):\n for j in range(W):\n d_w[j][ord(s[i][j]) - ord("a")] += 1\n #\n \n # d_h[i].sort()\n # d_w[i].sort()\n\n check_h = []\n check_w = []\n\n for i in range(H):\n if i in check_h:\n continue\n for j in range(i + 1, H):\n if j in check_h:\n continue\n else:\n if d_h[i] == d_h[j]:\n check_h.append(i)\n check_h.append(j)\n break\n\n for i in range(W):\n if i in check_w:\n continue\n for j in range(i + 1, W):\n if j in check_w:\n continue\n else:\n if d_w[i] == d_w[j]:\n check_w.append(i)\n check_w.append(j)\n break\n\n c_w = 0\n c_h = 0\n\n for i in range(H):\n if i in check_h:\n c_h += 1\n for i in range(W):\n if i in check_w:\n c_w += 1\n\n if c_h >= H - 1 and c_w >= W - 1:\n\n print(\'YES\')\n else:\n print(\'NO\')\n', 'from collections import defaultdict\nH, W = map(int, input().split())\ns = [input() for _ in range(H)]\nif H == 1 and W == 1:\n print(\'YES\')\nelif H==1:\n print(\'NO\')\nelse:\n\n d_h = [[0 for i in range(28)] for _ in range(H)]\n d_w = [[0 for i in range(28)] for _ in range(W)]\n\n for i in range(H):\n for c in s[i]:\n d_h[i][ord(c) - ord("a")] += 1\n\n for i in range(H):\n for j in range(W):\n d_w[j][ord(s[i][j]) - ord("a")] += 1\n #\n \n # d_h[i].sort()\n # d_w[i].sort()\n\n check_h = []\n check_w = []\n\n for i in range(H):\n if i in check_h:\n continue\n for j in range(i + 1, H):\n if j in check_h:\n continue\n else:\n if d_h[i] == d_h[j]:\n check_h.append(i)\n check_h.append(j)\n break\n\n for i in range(W):\n if i in check_w:\n continue\n for j in range(i + 1, W):\n if j in check_w:\n continue\n else:\n if d_w[i] == d_w[j]:\n check_w.append(i)\n check_w.append(j)\n break\n\n c_w = 0\n c_h = 0\n\n for i in range(H):\n if i in check_h:\n c_h += 1\n for i in range(W):\n if i in check_w:\n c_w += 1\n\n if c_h >= H - 1 and c_w >= W - 1:\n\n print(\'YES\')\n else:\n print(\'NO\')\n', '\nn = int(input())\nx = list(map(int, input().split()))\nx_sort = x.copy()\nx_sort.sort()\nrow = x_sort[n//2 - 1]\nhigh = x_sort[n//2]\n\nfor i in range(n):\n if x[i] <= row:\n print(high)\n else:\n print(row)\n'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s073913582', 's827970685', 's809226103'] | [3440.0, 3316.0, 26180.0] | [25.0, 22.0, 303.0] | [1469, 1469, 218] |
p03381 | u459737327 | 2,000 | 262,144 | When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N. | ["n = int(input())\na = sorted(zip(map(int, input().split()), range(n)))\nfor i in range(n//2):\n a[i] = a[n//2 - 1]\n a[i + n//2] = a[n//2]\nprint('\\n'.join(map(lambda x: str(x[0]), sorted(a, key = lambda x: x[1]))))\n", "n = int(input())\na = sorted(zip(map(int, input().split()), range(n)))\nb = [0] * n\nfor i in range(n//2):\n b[i], b[n - i - 1] = (a[n//2][0], a[i][1]), (a[n//2 - 1][0], a[n - i - 1][1])\nprint('\\n'.join(map(lambda x: str(x[0]), sorted(b, key = lambda x: x[1]))))\n"] | ['Wrong Answer', 'Accepted'] | ['s396126723', 's520767892'] | [45460.0, 64832.0] | [576.0, 667.0] | [213, 260] |
p03381 | u476199965 | 2,000 | 262,144 | When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N. | ['n = int(input())\nx = list(map(int,input().split()))\ny = sorted(x)\nl = y[n/2-2]\nr = y[n/2-1]\nfor i in range(n):\n if x[I] <= l:print(r)\n else:print(l)\n', 'n = int(input())\nx = list(map(int,input().split()))\ny = sorted(x)\nl = y[n/2-2]\nr = y[n/2-1]\nfor i in range(n):\n if x[i] <= l:print(r)\n else:print(l)\n', 'n = list(map(int,input().split()))\nx = list(map(int,input().split()))\ny = sorted(x)\nl = y[n/2-2]\nr = y[n/2-1]\nfor i in range(n):\n if x[I] <= l:print(r)\n else:print(l)', 'n = list(map(int,input().split()))\nx = list(map(int,input().split()))\ny = sorted(x)\nl = y[n/2-2]\nr = y[n/2-1]\nfor i in range(n):\n if x[i] <= l:print(r)\n else:print(l)\n', 'n = int(input())\nx = list(map(int,input().split()))\ny = sorted(x)\nl = y[n//2-2]\nr = y[n//2-1]\nfor i in range(n):\n if x[i] <= l:print(r)\n else:print(l)\n', 'n = int(input())\nx = list(map(int,input().split()))\ny = sorted(x)\nl = y[n//2-1]\nr = y[n//2]\nfor i in range(n):\n if x[i] <= l:print(r)\n else:print(l)\n'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s481226340', 's566281365', 's603303086', 's677470937', 's807271866', 's293421704'] | [25624.0, 25620.0, 25220.0, 25472.0, 26772.0, 25220.0] | [151.0, 149.0, 151.0, 148.0, 310.0, 322.0] | [155, 155, 172, 173, 157, 155] |
p03381 | u495415554 | 2,000 | 262,144 | When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N. | ['N = int(input())\nX = list(map(int, input().split()))\n\nX.sort()\n\nfor i in range(N):\n tmp = X.pop(i)\n print(X[(N // 2) - 1])\n X.insert(i, tmp)', 'N = int(input())\nX = list(map(int, input().split()))\nX_sorted = sorted(X)\n\nfor i in range(N):\n if X[i] < X_sorted[N // 2]:\n print(X_sorted[N // 2])\n else:\n print(X_sorted[(N // 2) - 1])'] | ['Wrong Answer', 'Accepted'] | ['s412799091', 's058874234'] | [26016.0, 25620.0] | [2104.0, 336.0] | [149, 205] |
p03381 | u547085427 | 2,000 | 262,144 | When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N. | ['N = int(input())\nN_d = int(N/2)\nX1 = list(map(int,input().split()))\nX = X1[:]\nX1.sort()\n\ndef getMed(i):\n if i < X[N_d]:\n print(X[N_d])\n else:\n print( X[N_d -1])\n\nfor i in X:\n getMed(i)\n ', 'N = int(input())\nN_d = int(N/2)\nX1 = list(map(int,input().split()))\nX = X1[:]\nX1.sort()\n\ndef getMed(i):\n if i < X1[N_d]:\n print(X1[N_d])\n else:\n print( X1[N_d -1])\n\nfor i in X:\n getMed(i)'] | ['Wrong Answer', 'Accepted'] | ['s217080575', 's054366599'] | [25228.0, 26016.0] | [310.0, 327.0] | [196, 197] |
p03381 | u584749014 | 2,000 | 262,144 | When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N. | ['n = int(input())\nl0 = list(map(int, input().split()))\nl = sorted(l0)\n\nm1 = l[n//2 - 1]\nm2 = l[n//2]\nfor i in range(len(l0)):\n if l0[i] <= m2:\n print(m2)\n if l0[i] > m1:\n print(m1)\n', "n, m = map(int,input().split())\nd = {i: {chr(i): 0 for i in range(ord('a'), ord('z')+1)} for i in range(n)}\nd2 = {i: {chr(i): 0 for i in range(ord('a'), ord('z')+1)} for i in range(m)}\nfor i in range(n):\n s = input()\n for j in s:\n d[i][j] += 1\n for j in range(len(s)):\n d2[j][s[j]] += 1\n\nk = [0 for i in range(n)]\nk2 = [0 for i in range(m)]\n\nf = True\nfor i in range(n):\n for j in range(n):\n if d[i] == d[j]:\n k[i] += 1\n\n\nfor i in range(m):\n for j in range(m):\n if d2[i] == d2[j]:\n k2[i] += 1\n\nk2 = sorted(k2)\nk = sorted(k)\nif n % 2:\n if len(k) > 1:\n if k[1] < 2:\n f = False\nelse:\n if k[0] < 2:\n f = False\n\nif m % 2:\n if len(k) > 1:\n if k2[1] < 2:\n f = False\nelse:\n if k2[0] < 2:\n f = False\n\nif f:\n print('YES')\nelse:\n print('NO')", 'n = int(input())\nl0 = list(map(int, input().split()))\nl = sorted(l0)\n\nm1 = l[n//2 - 1]\nm2 = l[n//2]\nfor i in range(len(l0)):\n if l0[i] < m2:\n print(m2)\n elif l0[i] > m1:\n print(m1)\n elif l0[i] == m1:\n print(m2)\n elif l0[i] == m2:\n print(m1)'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s431990044', 's951718364', 's711247316'] | [26772.0, 3064.0, 25224.0] | [322.0, 17.0, 320.0] | [200, 862, 280] |
p03381 | u657541767 | 2,000 | 262,144 | When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N. | ['n = int(input())\nx = [int(a) for a in input().split()]\nsorted_x = sorted(x)\nprint(x)\nprint(sorted_x)\nfor elem in x:\n if elem >= sorted_x[(len(x) + 1) // 2]:\n print(sorted_x[(len(x) + 1) // 2 - 1])\n else:\n print(sorted_x[(len(x) + 1) // 2])\n ', 'n = int(input())\nx = [int(a) for a in input().split()]\nsorted_x = sorted(x)\nfor elem in x:\n if elem >= sorted_x[(len(x) + 1) // 2]:\n print(sorted_x[(len(x) + 1) // 2 - 1])\n else:\n print(sorted_x[(len(x) + 1) // 2])\n '] | ['Wrong Answer', 'Accepted'] | ['s146267300', 's541097740'] | [25620.0, 25224.0] | [419.0, 402.0] | [264, 239] |
p03381 | u730769327 | 2,000 | 262,144 | When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N. | ['from heapq import heappush\nn=int(input())\nx=list(map(int,input().split()))\na=[]\nfor i in range(n):\n a+=[(x[i],i)]\na=sorted(a)\nans=[]\nfor i,j in a:\n if i<=a[n//2][0]:heappush(ans,(j,a[n//2][0]))\n else:heappush(ans,(j,a[n//2-1][0]))\nfor i,j in ans:\n print(j)', 'n=int(input())\nx=list(map(int,input().split()))\na=[]\nfor i in range(n):\n a+=[(x[i],i)]\na=sorted(a)\nans=[]\nfor i in range(n):\n if i<n//2:ans+=[(a[i][1],a[n//2][0])]\n else:ans+=[(a[i][1],a[n//2-1][0])]\nfor i,j in sorted(ans):\n print(j)'] | ['Wrong Answer', 'Accepted'] | ['s762645689', 's117993835'] | [53164.0, 55000.0] | [545.0, 616.0] | [260, 237] |
p03381 | u812137330 | 2,000 | 262,144 | When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N. | ['n = int(input())\n\na = input().split()\n\na = [int(x) for x in a]\n\nam = max(a)\nai = 0\nr = abs(a[0] - (am/2)) \n\nfor i in range(n):\n if r >= abs(a[i]-(am/2)):\n r = abs(a[i]-(am/2))\n ai = a[i]\n \nprint("{0} {1}".format(am,ai))', 'N = int(input())\n\nX = input().split()\nx1 = [int(x) for x in X]\nx2 = [int(x) for x in X]\n\nx2.sort()\nml = x2[int((N/2)-1)]\nmr = x2[int(N/2)]\n\nfor i in range(N):\n if x1[i] <= ml:\n print("%d"%mr)\n else:\n print("%d"%ml)\n \n '] | ['Wrong Answer', 'Accepted'] | ['s880144541', 's859256759'] | [25228.0, 36220.0] | [156.0, 378.0] | [243, 249] |
p03381 | u835482198 | 2,000 | 262,144 | When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N. | ["n = int(input())\nx = list(map(int, input().split()))\nsorted_x = sorted(x)\n\nif sorted_x[n // 2] == sorted_x[n // 2 - 1]:\n print(' '.join([sorted_x[n // 2] * n]))\nelse:\n ret = []\n for i in range(n):\n if x[i] >= sorted_x[n // 2]:\n ret.append(sorted_x[n // 2])\n else:\n ret.append(sorted_x[n // 2 - 1])\n print(' '.join(ret))\n", 'n = int(input())\nx = list(map(int, input().split()))\nsorted_x = sorted(x)\n\nif sorted_x[n // 2] == sorted_x[n // 2 - 1]:\n ret = [sorted_x[n // 2]] * n\nelse:\n ret = []\n for i in range(n):\n if x[i] >= sorted_x[n // 2]:\n ret.append(sorted_x[n // 2])\n else:\n ret.append(sorted_x[n // 2 - 1])\nfor i in ret:\n print(i)\n', 'n = int(input())\nx = list(map(int, input().split()))\nsorted_x = sorted(x)\n\nif sorted_x[n // 2] == sorted_x[n // 2 - 1]:\n ret = [sorted_x[n // 2]] * n\nelse:\n ret = []\n for i in range(n):\n if x[i] >= sorted_x[n // 2]:\n ret.append(sorted_x[n // 2 - 1])\n else:\n ret.append(sorted_x[n // 2])\nfor i in ret:\n print(i)\n'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s247133162', 's423079251', 's274249606'] | [26772.0, 25224.0, 25620.0] | [225.0, 348.0, 353.0] | [368, 359, 359] |
p03381 | u876442898 | 2,000 | 262,144 | When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N. | ['# -*- coding: utf-8 -*-\n\n\nimport numpy as np\n\nN = int(input())\nX = np.array(map(int, input().split(" ")))\n\nfor i in range(N):\n print(np.append(X[:i], X[i+1:]).median)', '# -*- coding: utf-8 -*-\n\nimport random\nimport copy\n\nN = int(input())\nX = list(map(int, input().split(" ")))\nsorted_X = sorted(X)\nmed1 = sorted_X[N//2-1]\nmed2 = sorted_X[N//2]\nfor i in range(N):\n if X[i] <= med1:\n print(med2)\n else:\n print(med1)'] | ['Runtime Error', 'Accepted'] | ['s963071484', 's299629935'] | [28252.0, 27108.0] | [167.0, 305.0] | [297, 392] |
p03381 | u980652670 | 2,000 | 262,144 | When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N. | ['N = int(input())\nb = [int(i) for i in input().split()]\nb.sort()\ns = b[len(b)//2 - 1]\nl = b[len(b)//2]\n\nfor i in range(N):\n if i > len(b)//2:\n print(s)\n else:\n print(l)', 'N = int(input())\nb = input().split(" ")\n\nfor i in range(N):\n X = b\n X.pop(i)\n X.sort()\n print(X[len(X)//2])', 'N = int(input())\nb = [int(i) for i in input().split()]\nb.sort()\ns = b[len(b)//2 - 1]\nl = b[len(b)//2]\n\nfor i in range(N):\n if s > i:\n print(s)\n else:\n print(l)\n', 'N = int(input())\nb = [int(i) for i in input().split()]\nb.sort()\ns = b[(N-1)//2]\nl = b[N//2]\n\nfor i in range(N):\n if i > s:\n print(s)\n else:\n print(l)', 'N = int(input())\nb = [int(i) for i in input().split()]\nb.sort()\ns = b[len(b)//2 - 1]\nl = b[len(b)//2]\n\nfor i in range(N):\n if i > len(b)//2-1:\n print(s)\n else:\n print(l)', 'N = int(input())\nb = [int(i) for i in input().split()]\nc = sorted(b[:])\ns = c[(N-1)//2]\nl = c[N//2]\n\nfor i in b:\n if i > s:\n print(s)\n else:\n print(l)'] | ['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s146202982', 's393882280', 's472604249', 's859010730', 's874245733', 's258479591'] | [25220.0, 20292.0, 25220.0, 26016.0, 25224.0, 25228.0] | [340.0, 2105.0, 323.0, 313.0, 331.0, 319.0] | [187, 119, 180, 167, 189, 168] |
p03381 | u984276646 | 2,000 | 262,144 | When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N. | ['N = int(input())\nX = list(map(int, input().split()))\nfor i in range(N):\n Y = X[:]\n Y.remove(X[i])\n Y.sort()\n print(Y[N // 2])', 'N = int(input())\nX = list(map(int, input().split()))\nL = [0 for _ in range(N)]\nfor i in range(N):\n X[i] = X[i] * N + i\nX.sort()\nd = N // 2\nfor i in range(N):\n if i < d:\n L[X[i]%N] = X[d] // N\n else:\n L[X[i]%N] = X[d-1] // N\nfor i in range(N):\n print(L[i])'] | ['Runtime Error', 'Accepted'] | ['s056994555', 's672857732'] | [25556.0, 25228.0] | [2104.0, 447.0] | [129, 265] |
p03382 | u228759454 | 2,000 | 262,144 | Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted. | ['import numpy as np\n\nN = int(input())\nn_list = list(map(int, input().split()))\n\nM = np.max(n_list)\n\nbest_k_bar = (M - 1) / 2\nbest_k_cand = [x for x in n_list if x >= best_k_bar]\nbest_k = np.min(best_k_cand)\n\nprint(best_k_bar)\nprint(M, best_k)', 'import numpy as np\n\nN = int(input())\nn_list = list(map(int, input().split()))\n\nM = np.max(n_list)\nmid_M = M / 2\nex_M_list = list(n_list)\nex_M_list.remove(M)\n\nbest_k_cand = list(abs(ex_M_list - mid_M))\nbest_k = min(best_k_cand)\na = best_k_cand.index(best_k)\n\nprint(M, ex_M_list[a])\n'] | ['Wrong Answer', 'Accepted'] | ['s379794335', 's596507809'] | [23100.0, 23132.0] | [263.0, 253.0] | [241, 281] |
p03382 | u257974487 | 2,000 | 262,144 | Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted. | ['n = int(input())\np = list(map(int,input().split()))\np.sort()\na1 = max(p)\na2 = min(p)\nhalf = (a1+1) // 2\ns = n // 2\ngraph = [0] * n\n\nwhile True:\n if graph[s] != 0:\n break\n else:\n graph[s] += 1\n if p[s] < half:\n if abs(p[s] - half) < abs(a2 - half):\n a2 = p[s]\n s += 1\n elif p[s] > half:\n if abs(p[s] - half) < abs(a2 - half):\n a2 = p[s]\n s -= 1\n if s == 0 or s == n:\n break\nprint(a1, a2)', 'n = int(input())\np = list(map(int,input().split()))\np.sort()\na1 = max(p)\na2 = min(p)\nhalf = (a1+1) // 2\ns = n // 2\ngraph = [0] * n\n\nwhile True:\n if graph[s] != 0:\n break\n else:\n graph[s] += 1\n if p[s] <= half:\n if abs(p[s] - half) < abs(a2 - half):\n a2 = p[s]\n s += 1\n elif p[s] > half:\n if abs(p[s] - half) < abs(a2 - half):\n a2 = p[s]\n s -= 1\n if s == 0 or s == n:\n break\nprint(a1, a2)'] | ['Wrong Answer', 'Accepted'] | ['s350804195', 's330986550'] | [14428.0, 14440.0] | [84.0, 88.0] | [472, 473] |
p03382 | u268210555 | 2,000 | 262,144 | Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted. | ['n = int(input())\na = list(map(int, input().split()))\ni = max(a)\na.remove(i)\nk = min(a, key=lambda x: abs(i-x*2))\nprint(i, j)', 'n = int(input())\na = list(map(int, input().split()))\ni = max(a)\na.remove(i)\nj = min(a, key=lambda x: abs(i-x*2))\nprint(i, j)'] | ['Runtime Error', 'Accepted'] | ['s048084493', 's917080157'] | [14428.0, 14428.0] | [66.0, 66.0] | [124, 124] |
p03382 | u374103100 | 2,000 | 262,144 | Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted. | ['cache = {0: 1, 1: 1, 2: 2}\ncombo_cache = {}\n\n\ndef prepare_cache():\n val = 1\n for i in range(1, 10000):\n cache[i] = val * i\n\ndef permutation(n):\n if n in cache:\n return cache[n]\n\n ret = n\n for i in range(n-1, 0, -1):\n if i in cache:\n ret *= cache[i]\n cache[n] = ret\n return ret\n\n ret *= i\n return ret\n\n\ndef combo(n, r):\n key = str(n) + "-" + str(r)\n if key in combo_cache:\n return combo_cache[key]\n\n x = permutation(n)\n y = permutation(n-r)\n z = permutation(r)\n combo_cache[key] = int(x // (y * z))\n return combo_cache[key]\n\n\ncount = int(input())\nli = list(map(int, input().split()))\n#\n# data = open("input.txt", "r")\n# l = data.read()\n\n\nprepare_cache()\n\nsli = sorted(li)\n\npair_a = 0\npair_b = 0\ncurrent_max = 0\n\ni = sli[len(sli) - 1]\n\nfor j in range(0, len(sli) - 1):\n val = combo(i, sli[j])\n # print(str(sli[i]) + ", " + str(sli[j]) + ", " + str(val))\n if val > current_max:\n current_max = val\n pair_a = i\n pair_b = sli[j]\n\nprint(str(pair_a) + " " + str(pair_b))\n', '\ncache = {0: 1, 1: 1, 2: 2}\ncombo_cache = {}\n\n\ndef permutuation(n):\n if n in cache:\n return cache[n]\n\n ret = n\n for i in range(n, 0, -1):\n if i in cache:\n ret *= cache[i]\n cache[n] = ret\n return ret\n\n ret *= i\n return ret\n\n\ndef combo(n, r):\n key = str(n) + "-" + str(r)\n if key in combo_cache:\n return combo_cache[key]\n\n x = permutuation(n)\n y = permutuation(n-r)\n z = permutuation(r)\n combo_cache[key] = int(x // (y * z))\n return combo_cache[key]\n\n\ncount = int(input())\nli = list(map(int, input().split()))\n#\n# data = open("input.txt", "r")\n# l = data.read()\n\n\n\nsli = sorted(li)\n\npair_a = 0\npair_b = 0\ncurrent_max = 0\n\nfor i in range(len(sli) - 2,len(sli)):\n for j in range(0, i):\n val = combo(sli[i], sli[j])\n # print(str(sli[i]) + ", " + str(sli[j]) + ", " + str(val))\n if val > current_max:\n current_max = val\n pair_a = sli[i]\n pair_b = sli[j]\n\nprint(str(pair_a) + " " + str(pair_b))\n', 'count = int(input())\nli = list(map(int, input().split()))\n\nsli = sorted(li)\n\npair_a = sli[len(sli) - 1]\npair_b = 0\ncurrent_max = 0\n\ni = sli[len(sli) - 1]\n\ndiff = 10**9\nfor j in range(0, len(sli) - 1):\n h = pair_a / 2\n if abs(h - sli[j]) < diff:\n diff = abs(h - sli[j])\n pair_b = sli[j]\n\nprint(str(pair_a) + " " + str(pair_b))\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s003824343', 's710042703', 's667669039'] | [14348.0, 14348.0, 14428.0] | [2104.0, 2104.0, 124.0] | [1135, 1074, 346] |
p03382 | u442877951 | 2,000 | 262,144 | Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted. | ['from bisect import *\nn = int(input())\na = list(map(int,input().split()))\na = sorted(a)\nans = a[-1]//2\nb = bisect_left(a,ans)\nif abs(ans-a[b]) < abs(ans-a[b-1]):\n print(a[-1],a[b])\nelse:\n print(a[-1],a[b-1])', 'from bisect import *\nn = int(input())\na = list(map(int,input().split()))\na = sorted(a)\nans = a[-1]/2\nb = bisect_left(a,ans)\nif abs(ans-a[b]) < abs(ans-a[b-1]):\n print(a[-1],a[b])\nelse:\n print(a[-1],a[b-1])'] | ['Wrong Answer', 'Accepted'] | ['s359126576', 's835174130'] | [14052.0, 14052.0] | [80.0, 78.0] | [208, 207] |
p03382 | u476199965 | 2,000 | 262,144 | Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted. | ['import bisect\nn = int(input())\nx = list(map(int,input().split()))\ny = sorted(x)\nmid = bisect.bisect_left(y,y[-1]/2)\nif y[-1]/2-x[mid]>=x[mid+1]-y[-1]/2:print(y[-1],x[mid+1])\nelse:print(y[-1],x[mid])', 'n = int(input())\nx = list(map(int,input().split()))\n\ny = max(x)\nsub = y\nres = 0\nfor i in range(n):\n if abs(float(y/2-x[i])) < sub and x[i] != y:\n sub = abs(float(y/2-x[i]))\n res = x[i]\n\nprint(y,res)\n'] | ['Runtime Error', 'Accepted'] | ['s702979413', 's738204824'] | [14428.0, 14432.0] | [80.0, 81.0] | [198, 216] |
p03382 | u535171899 | 2,000 | 262,144 | Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted. | ["def main():\n import sys\n input = sys.stdin.readline\n \n N = int(input())\n A = set(map(int,input().split()))\n A = sorted(list(A))\n\n import bisect\n\n ans = A[-1]//2\n b = bisect.bisect_left(A,ans)\n\n if abs(ans-A[b])<abs(ans-A[max(0,b-1)]):\n print(A[-1],A[b])\n else:\n print(A[-1],A[b-1])\n\nif __name__=='__main__':\n main()", "def main():\n import sys\n input = sys.stdin.readline\n \n N = int(input())\n A = set(map(int,input().split()))\n A = sorted(list(A))\n\n import bisect\n\n ans = A[-1]/2\n b = bisect.bisect_left(A,ans)\n\n if abs(ans-A[b])<abs(ans-A[max(0,b-1)]):\n print(A[-1],A[b])\n else:\n print(A[-1],A[b-1])\n\nif __name__=='__main__':\n main()"] | ['Wrong Answer', 'Accepted'] | ['s913989512', 's493717254'] | [25008.0, 25116.0] | [73.0, 80.0] | [365, 364] |
p03382 | u657913472 | 2,000 | 262,144 | Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted. | ['input()\na=list(map(int,input().split()))\nm=max(a)\nd=max(a,key=lambda d:abs(m-2*d)if m!=d else-1)\nprint(m,d)', 'input()\na=list(map(int,input().split()))\nm=max(a)\nd=min(a,key=lambda d:abs(m-2*d)if m!=d else 1e18)\nprint(m,d)'] | ['Wrong Answer', 'Accepted'] | ['s733503075', 's997363156'] | [14060.0, 14428.0] | [70.0, 69.0] | [107, 110] |
p03382 | u721316601 | 2,000 | 262,144 | Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted. | ["import numpy as np\n\nN = int(input())\n\na = list(map(int, input().split()))\n \na_i = max(a)\n\ndel a[np.argmax(a)]\n\na = np.array(a)\n\ncenter = a_i // 2\n\nif a_i % 2 == 1:\n center += 1\n \ntmp = center // a\n\na_j = a[np.argmin(tmp)]\n \nprint(str(a_i) + ' ' + str(a_j))", "import numpy as np\n\nn = int(input())\na = list(map(int, input().split()))\n\na_max = max(a)\na_max_index = np.argmax(a)\n\ndel a[a_max_index]\n\ncenter = a_max / 2\n\na_x_index = np.argmin(np.absolute(np.array(a) - center))\na_x = a[a_x_index]\n\nprint(str(a_max) + ' ' + str(a_x))\n"] | ['Wrong Answer', 'Accepted'] | ['s050992060', 's908886432'] | [29212.0, 23664.0] | [341.0, 212.0] | [266, 269] |
p03382 | u807772568 | 2,000 | 262,144 | Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted. | ['input()\nda = list(map(int,input().split()))\n\nx = max(da)\ny = x + 1\nfor i in x\n\tif i == x:\n \t\tcontinue\n if abs(x/2 - i ) <= (x/2 - y):\n\t\ty = i\nprint(x,y)', 'input()\nda = list(map(int,input().split()))\n \nx = max(da)\ny = x + 1\nfor i in da:\n\tif i == x:\n \t\tcontinue\n if abs(x/2 - i ) <= abs(x/2 - y):\n\t\ty = i\nprint(x,y)', 'input()\nda = list(map(int,input().split()))\n \nx = max(da)\ny = x + 1\nfor i in x:\n\tif i == x:\n \t\tcontinue\n if abs(x/2 - i ) <= abs(x/2 - y):\n\t\ty = i\nprint(x,y)', 'input()\nda = list(map(int,input().split()))\n \nx = max(da)\ny = x + 1\nfor i in da:\n if i == x:\n continue\n if abs(x/2 - i ) <= abs(x/2 - y):\n y = i\nprint(x,y)'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s668469974', 's677934241', 's894894297', 's131131494'] | [2940.0, 2940.0, 2940.0, 14060.0] | [17.0, 17.0, 17.0, 88.0] | [156, 162, 161, 163] |
p03382 | u867069435 | 2,000 | 262,144 | Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted. | ['import bisect\nn = int(input())\na = sorted(list(map(int, input().split())))\nl, r = 0, 0\nl = max(a)\na.remove(l)\nj = bisect.bisect_left(a, l/2)\nprint(a[min(j, len(a)-1)])', 'import bisect\nn = int(input())\na = sorted(list(map(int, input().split())))\nl, r = 0, 0\nl = max(a)\na.remove(l)\nj = bisect.bisect_left(a, l/2)\ntry:\n if abs((l/2) - a[j-1]) < abs((l/2) - a[j]):\n j -= 1\nexcept:\n pass\nprint(l, a[min(j, len(a)-1)])'] | ['Wrong Answer', 'Accepted'] | ['s763914932', 's519209769'] | [14428.0, 14052.0] | [85.0, 86.0] | [167, 255] |
p03382 | u875291233 | 2,000 | 262,144 | Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted. | ['# coding: utf-8\n# Your code here!\n\nN=int(input())\nC = list(map(int,input().split()))\n\na=sorted(C)\n\nM=a[-1]\n\n\nA=sorted([abs(2*i - M) for i in a])\nprint(C)\nprint(a)\nprint(A)\nN1= (-A[0]+M)//2\nN2= (A[0]+M)//2\nprint(N1,N2)\nj = C.index(M)\nif N1 in a:\n print(M,N1)\nelse:\n print(M,N2)\n\n\n\n', '# coding: utf-8\n# Your code here!\n\nN=int(input())\nC = list(map(int,input().split()))\n\na=sorted(C)\n\nM=a[-1]\n\n\nA=sorted([abs(2*i - M) for i in a])\n#print(C)\n#print(a)\n#print(A)\nN1= (-A[0]+M)//2\nN2= (A[0]+M)//2\n#print(N1,N2)\nj = C.index(M)\nif N1 in a:\n print(M,N1)\nelse:\n print(M,N2)\n\n\n\n'] | ['Wrong Answer', 'Accepted'] | ['s415486244', 's799860991'] | [18768.0, 14052.0] | [129.0, 98.0] | [286, 290] |
p03382 | u957084285 | 2,000 | 262,144 | Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted. | ['N = int(input())\na = sorted(list(map(int, input().split())))\n\nimport numpy as np\nfrom scipy.misc import comb\n\ni = 0\nj = 1\n\nans = (0, 0)\nx = 0\nfor j in range(1, N):\n n = a[j]\n while j - i > 1:\n if abs(n/2 - a[i]) < abs(n/2 - a[i+1]):\n break\n i+=1\n p = a[i]\n y = comb(n, p)\n if y > x:\n x = y\n ans = (n, p)\n\nprint(str(ans[0]), str(ans[1]))', "N = int(input())\na = sorted(list(map(int, input().split())))\nimport numpy as np\nfrom scipy.misc import comb\n\ndef find_p(n, i):\n lo = 0\n hi = i\n mid = (hi-lo)//2\n xl = a[0]\n xh = a[i]\n while hi - lo > 1:\n mid = (hi+lo)//2\n if a[mid] > n//2:\n hi = mid\n else:\n lo = mid\n if abs(a[lo] - n/2) > abs(a[hi] - n/2):\n return a[hi]\n else:\n return a[lo]\n\nans = (0, 0)\nx = 0\nfor j in range(N):\n i = N-j-1\n n = a[i]\n p = find_p(n, i)\n y = comb(n, p)\n if y > x:\n ans = (n, p)\n x = y\n\nprint(str(ans[0]) + ' ' + str(ans[1]))", 'N = int(input())\na = sorted(list(map(int, input().split())))\n\nimport numpy as np\nfrom scipy.misc import comb\n\ni = 0\nj = N//2\n\nans = (0, 0)\nx = 0\nfor j in range(1, N):\n n = a[j]\n while j - i > 1:\n if abs(n/2 - a[i]) < abs(n/2 - a[i+1]):\n break\n i+=1\n p = a[i]\n y = comb(n, p)\n if y > x:\n x = y\n ans = (n, p)\n\nprint(str(ans[0]), str(ans[1]))\n', "N = int(input())\na = sorted(list(map(int, input().split())))\nimport numpy as np\nfrom scipy.misc import comb\n\ndef find_p(n, i):\n lo = 0\n hi = i\n mid = (hi-lo)//2\n xl = a[0]\n xh = a[i]\n while hi - lo > 1:\n mid = (hi+lo)//2\n if a[mid] > n//2:\n hi = mid\n else:\n lo = mid\n if abs(a[lo] - n/2) > abs(a[hi] - n/2):\n return a[hi]\n else:\n return a[lo]\n\nans = (0, 0)\nx = 0\nfor j in range(N):\n i = N-j-1\n if a[i] < ans[1]:\n break\n n = a[i]\n p = find_p(n, i)\n y = comb(n, p)\n if y > x:\n ans = (n, p)\n x = y\n\nprint(str(ans[0]) + ' ' + str(ans[1]))\n", "N = int(input())\na = sorted(list(map(int, input().split())))\n\ndef find_p(n, i):\n lo = 0\n hi = i\n mid = (hi-lo)//2\n xl = a[0]\n xh = a[i]\n while hi - lo > 1:\n mid = (hi+lo)//2\n if a[mid] > n//2:\n hi = mid\n else:\n lo = mid\n if abs(a[lo] - n/2) > abs(a[hi] - n/2):\n return a[hi]\n else:\n return a[lo]\n\n\n\nprint(str(a[-1]) + ' ' + str(find_p(a[-1], N-1)))"] | ['Time Limit Exceeded', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted'] | ['s475526432', 's589492529', 's745562765', 's899247345', 's101545718'] | [19560.0, 19568.0, 19556.0, 19564.0, 14428.0] | [2109.0, 2109.0, 2109.0, 2112.0, 79.0] | [390, 618, 394, 655, 429] |
p03383 | u104282757 | 2,000 | 262,144 | There is an H \times W grid (H vertical, W horizontal), where each square contains a lowercase English letter. Specifically, the letter in the square at the i-th row and j-th column is equal to the j-th character in the string S_i. Snuke can apply the following operation to this grid any number of times: * Choose two different rows and swap them. Or, choose two different columns and swap them. Snuke wants this grid to be _symmetric_. That is, for any 1 \leq i \leq H and 1 \leq j \leq W, the letter in the square at the i-th row and j-th column and the letter in the square at the (H + 1 - i)-th row and (W + 1 - j)-th column should be equal. Determine if Snuke can achieve this objective. | ['# E\nimport numpy as np\n\nH, W = map(int, input().split())\nS = list()\nfor _ in range(H):\n S.append(list(input()))\nS_arr = np.array(S)\n\nres = "YES"\n\ndef check_ok(S_arr, H, W):\n res = True\n for i in range(H):\n for j in range(W):\n if S_arr[i, j] != S_arr[H-1-i, W-1-j]:\n res = False\n return res\n\n\ndef apply_switch(S_arr, row_matching, col_matching):\n S_arr_row = S_arr.copy()\n i = 0\n for mat in row_matching:\n if len(mat) == 2:\n S_arr_row[i, :] = S_arr[mat[0], :]\n S_arr_row[H-1-i, :] = S_arr[mat[1], :]\n i += 1\n else:\n S_arr_row[(H-1)//2, :] = S_arr[mat[0], :]\n S_arr_rowcol = S_arr_row.copy()\n j = 0\n for mat in row_matching:\n if len(mat) == 2:\n S_arr_rowcol[:, j] = S_arr_row[:, mat[0]]\n S_arr_rowcol[:, W-1-j] = S_arr_row[:, mat[1]]\n j += 1\n else:\n S_arr_rowcol[:, (W-1)//2] = S_arr_row[:, mat[0]]\n \n# row_matching\nsame_row_list = []\ndone_row_list = np.zeros(H)\nfor i in range(H):\n if done_row_list[i] == 1:\n continue\n done_row_list[i] = 1\n j_list = [i]\n for j in range(H):\n if i != j and np.prod(np.sort(S_arr[i, :]) == np.sort(S_arr[j, :])) == 1:\n j_list.append(j)\n done_row_list[j] = 1\n same_row_list.append(j_list)\n\n# col_matching\nsame_col_list = []\ndone_col_list = np.zeros(W)\nfor i in range(W):\n if done_col_list[i] == 1:\n continue\n done_col_list[i] = 1\n j_list = [i]\n for j in range(W):\n if i != j and np.prod(np.sort(S_arr[:, i]) == np.sort(S_arr[:, j])) == 1:\n j_list.append(j)\n done_col_list[j] = 1\n same_col_list.append(j_list)\n \nif len(same_row_list) == H // 2 and len(same_col_list) == W // 2:\n if check_ok(apply_switch(S_arr, same_row_list, same_col_list), H, W) == False:\n res = "NO"\nelif len(same_row_list) > H // 2:\n res = "NO"\nelif len(same_col_list) > W // 2:\n res = "NO"\nprint(res)', '# E\nimport numpy as np\n\nH, W = map(int, input().split())\nS = list()\nfor _ in range(H):\n S.append(list(input()))\nS_arr = np.array(S)\n\nres = "NO"\n\ndef check_col_switch(S_arr, H, W):\n if W % 2 == 1:\n res_bar = -1\n else:\n res_bar = 0\n done_col = np.zeros(W)\n for j in range(W):\n if done_col[j] == 1:\n continue\n rev_j = S_arr[::(-1), j]\n for k in range(W):\n if np.prod(S_arr[:, k] == rev_j) == 1 and j != k and done_col[k] == 0:\n done_col[j] = 1\n done_col[k] = 1\n break\n if done_col[j] == 0:\n if np.prod(S_arr[:, j] == rev_j) == 1:\n done_col[j] = 1\n res_bar += 1\n else:\n res_bar += 10\n if res_bar <= 0:\n return "YES"\n else:\n return "NO"\n \ndef check_col_switch_fast(S_arr, H, W):\n \n col_raw = np.array(["".join(list(S_arr[:, j])) for j in range(W)])\n col_reverse = np.array(["".join(list(S_arr[::(-1), j])) for j in range(W)])\n \n argsa = np.argsort(col_raw)\n argsb = np.argsort(col_reverse)\n \n res = "YES"\n for j in range(W):\n if col_raw[argsa[j]] != col_reverse[argsb[j]]:\n res = "NO"\n break\n cnt_single = 0\n for j in range(W):\n if argsa[j] == argsb[j]:\n cnt_single += 1\n j = 0\n while j < W-1:\n if col_raw[argsa[j]] != col_raw[argsa[j+1]]:\n cnt_single -= 2\n j += 2\n else:\n j += 1\n if cnt_single >= 2:\n res = "NO"\n \n return res\n \ndef make_pairs(x_list):\n if len(x_list) <= 2:\n return [[x_list]]\n else:\n res = []\n for j in range(1, len(x_list)):\n x_list_s = [x_list[k] for k in range(1, len(x_list)) if k != j]\n res = res + [[[x_list[0], x_list[j]]] + xl for xl in make_pairs(x_list_s)]\n if len(x_list) % 2 == 1:\n x_list_l = [x_list[k] for k in range(1, len(x_list))]\n res = res + [xl + [[x_list[0]]] for xl in make_pairs(x_list_l)]\n return res\n \ndef run_row_switch(S_arr, row_matching, H, W):\n S_arr_row = S_arr.copy()\n i = 0\n for mat in row_matching:\n if len(mat) == 2:\n S_arr_row[i, :] = S_arr[mat[0], :]\n S_arr_row[H-1-i, :] = S_arr[mat[1], :]\n i += 1\n else:\n S_arr_row[(H-1)//2, :] = S_arr[mat[0], :]\n return S_arr_row\n \nrow_match_list = make_pairs([i for i in range(H)])\n\n\n \n\n# row_matching\nsame_row_list = []\nfor i in range(H):\n j_list = [i]\n for j in range(H):\n if i != j and np.prod(np.sort(S_arr[i, :]) == np.sort(S_arr[j, :])) == 1:\n j_list.append(j)\n same_row_list.append(j_list)\n \ndef pass_condition(rs):\n res = True\n for pair in rs:\n if len(pair) == 1:\n continue\n if pair[1] not in same_row_list[pair[0]]:\n res = False\n break\n return res\n\nrow_match_list_s = [rs for rs in row_match_list if pass_condition(rs)]\n\n\nfor rs in row_match_list_s:\n res = check_col_switch(run_row_switch(S_arr, rs, H, W), H, W)\n if res == "YES":\n break\nprint(res)'] | ['Runtime Error', 'Accepted'] | ['s743719914', 's884729981'] | [12272.0, 19740.0] | [157.0, 249.0] | [2003, 3182] |
p03383 | u226155577 | 2,000 | 262,144 | There is an H \times W grid (H vertical, W horizontal), where each square contains a lowercase English letter. Specifically, the letter in the square at the i-th row and j-th column is equal to the j-th character in the string S_i. Snuke can apply the following operation to this grid any number of times: * Choose two different rows and swap them. Or, choose two different columns and swap them. Snuke wants this grid to be _symmetric_. That is, for any 1 \leq i \leq H and 1 \leq j \leq W, the letter in the square at the i-th row and j-th column and the letter in the square at the (H + 1 - i)-th row and (W + 1 - j)-th column should be equal. Determine if Snuke can achieve this objective. | ['H, W = map(int, input().split())\nS = [list(input()) for i in range(H)]\nT = [[None]*H for i in range(W)]\nD = {}\nfor i in range(H):\n for j in range(W):\n c = S[i][j]\n D[c] = D.get(c, 0) ^ 1\nif sum(D.values()) != (1 if (H%2==1)and(W%2==1) else 0):\n print("NO")\n exit(0)\nfor i in range(H):\n s = S[i]\n for j in range(W):\n T[j][i] = s[j]\ndef check(S, H, W):\n res = []\n ok1 = 1\n for p in range(H):\n sp = S[p]\n for q in range(p+1, H):\n sq = S[q]\n d = {}\n for k in range(W):\n if sp[k] < sq[k]:\n k = sp[k], sq[k]\n d[k] = d.get(k, 0) + 1\n elif sp[k] == sq[k]:\n k = sp[k], sp[k]\n d[k] = d.get(k, 0) ^ 1\n else:\n k = sq[k], sp[k]\n d[k] = d.get(k, 0) - 1\n cap = (W % 2)\n ok = 1\n for a, b in d:\n if a == b:\n if d[a, b]:\n if cap == 0:\n ok = ok1 = 0\n cap -= 1\n else:\n if d[a, b] != 0:\n ok = ok1 = 0\n if ok: res.append((p, q))\n if H % 2 == 1:\n for p in range(H):\n d = {}\n for s in S[p]:\n d[s] = d.get(s, 0) ^ 1\n if sum(d.values()) == W % 2:\n res.append((p, p))\n return [] if ok1 else res\nsc = check(S, H, W)\ntc = check(T, W, H)\ndef solve(N, P):\n def dfs(state, c):\n if N == c:\n return 1\n for p, q in P:\n v = (1 << p) | (1 << q)\n if state & v:\n continue\n if dfs(state | v, (c+2 if p != q else c+1)):\n return 1\n return 0\n return dfs(0, 0)\nif solve(H, sc) and solve(W, tc):\n print("YES")\nelse:\n print("NO")\n\n', 'H, W = map(int, input().split())\nS = [input() for i in range(H)]\n\ndef check(l):\n u = [0]*W\n mid = W % 2\n for i in range(W):\n if u[i]:\n continue\n for j in range(i+1, W):\n for p, q in l:\n sp = S[p]; sq = S[q]\n if sp[i] != sq[j] or sp[j] != sq[i]:\n break\n else:\n u[j] = 1\n break\n else:\n if mid:\n for p, q in l:\n sp = S[p]; sq = S[q]\n if sp[i] != sq[i]:\n break\n else:\n mid = 0\n continue\n break\n else:\n return 1\n return 0\n\ndef make(c, l, u, p):\n while c in u:\n c += 1\n if c == H:\n if check(l):\n print("YES")\n exit(0)\n return\n if p:\n l.append((c, c))\n make(c+1, l, u, 0)\n l.pop()\n for i in range(c+1, H):\n if i in u:\n continue\n u.add(i)\n l.append((c, i))\n make(c+1, l, u, p)\n l.pop()\n u.remove(i)\n\nmake(0, [], set(), H%2)\nprint("NO")'] | ['Wrong Answer', 'Accepted'] | ['s829489612', 's516190086'] | [3192.0, 3192.0] | [20.0, 85.0] | [1927, 1162] |
p03383 | u252883287 | 2,000 | 262,144 | There is an H \times W grid (H vertical, W horizontal), where each square contains a lowercase English letter. Specifically, the letter in the square at the i-th row and j-th column is equal to the j-th character in the string S_i. Snuke can apply the following operation to this grid any number of times: * Choose two different rows and swap them. Or, choose two different columns and swap them. Snuke wants this grid to be _symmetric_. That is, for any 1 \leq i \leq H and 1 \leq j \leq W, the letter in the square at the i-th row and j-th column and the letter in the square at the (H + 1 - i)-th row and (W + 1 - j)-th column should be equal. Determine if Snuke can achieve this objective. | ["H, W = list(map(int, input().split(' ')))\nS = []\nd = defaultdict(list)\n\nfor h in range(H):\n s = input()\n S.append(s)\n d[''.join(sorted(S))].append(h)\n\nalready_paired = np.zeros(H)\n\nGs = []\n\nfor i in range(H):\n if already_paired[i]:\n continue\n\n for j in range(i+1, H):\n if already_paired[j]:\n continue\n\n if can_pair(S[i], S[j]):\n already_paired[i] = 1\n already_paired[j] = 1\n G = pair_graph(S[i], S[j])\n Gs.append(G)\n\nif already_paired.sum() < H - 1:\n print('NO')\n\nelif already_paired.sum() == H - 1:\n for i in range(H):\n if already_paired[i] == 0:\n Gs.append(pair_graph(S[i], S[i]))\n break\n\nG = np.array(Gs).sum(axis=0) // len(Gs)\n\ndef is_perfect_matching(G):\n N = len(G)\n for i in range(N):\n for j in range(i+1, N):\n if G[i, j] == 1:\n l = list(range(N))\n l.remove(i)\n l.remove(j)\n if len(l) == 0:\n return True\n if is_perfect_matching(G[l][:, l]):\n return True\n return False\n\nprint(is_perfect_matching(G))", "import numpy as np\nH, W = list(map(int, input().split(' ')))\nS = []\nd = defaultdict(list)\n\nfor h in range(H):\n s = input()\n S.append(s)\n d[''.join(sorted(S))].append(h)\n\nalready_paired = np.zeros(H)\n\nGs = []\n\nfor i in range(H):\n if already_paired[i]:\n continue\n\n for j in range(i+1, H):\n if already_paired[j]:\n continue\n\n if can_pair(S[i], S[j]):\n already_paired[i] = 1\n already_paired[j] = 1\n G = pair_graph(S[i], S[j])\n Gs.append(G)\n\nif already_paired.sum() < H - 1:\n print('NO')\n exit()\n\nelif already_paired.sum() == H - 1:\n for i in range(H):\n if already_paired[i] == 0:\n Gs.append(pair_graph(S[i], S[i]))\n break\n\nG = np.array(Gs).sum(axis=0) // len(Gs)\n\ndef is_perfect_matching(G):\n N = len(G)\n for i in range(N):\n for j in range(i+1, N):\n if G[i, j] == 1:\n l = list(range(N))\n l.remove(i)\n l.remove(j)\n if len(l) == 0:\n return True\n if is_perfect_matching(G[l][:, l]):\n return True\n return False\n\nif is_perfect_matching(G):\n print('YES')\nelse:\n print('NO')", "from collections import defaultdict\n\n\ndef can_palindrome(s):\n l = []\n for c in s:\n if c in l:\n l.remove(c)\n else:\n l.append(c)\n\n if len(s) % 2 == 0:\n return len(l) == 0\n else:\n return len(l) == 1\n\n\ndef can_pair(s1, s2):\n l = []\n for c1, c2 in zip(s1, s2):\n c = sorted([c1, c2])\n if c in l:\n l.remove(c)\n else:\n l.append(c)\n\n if len(s1) % 2 == 0:\n return len(l) == 0\n else:\n return len(l) == 1\n\n\ndef pair_graph(s1, s2):\n N = len(s1)\n G = np.zeros([N, N])\n for i in range(N):\n for j in range(i+1, N):\n if s1[i] == s2[j] and s1[j] == s2[i]:\n G[i, j] = 1\n G[j, i] = 1\n return G\n\nimport numpy as np\nH, W = list(map(int, input().split(' ')))\nS = []\nd = defaultdict(list)\n\nfor h in range(H):\n s = input()\n S.append(s)\n d[''.join(sorted(S))].append(h)\n\nalready_paired = np.zeros(H)\n\nGs = []\n\nfor i in range(H):\n if already_paired[i]:\n continue\n\n for j in range(i+1, H):\n if already_paired[j]:\n continue\n\n if can_pair(S[i], S[j]):\n already_paired[i] = 1\n already_paired[j] = 1\n G = pair_graph(S[i], S[j])\n Gs.append(G)\n\nif already_paired.sum() < H - 1:\n print('NO')\n exit()\n\nelif already_paired.sum() == H - 1:\n for i in range(H):\n if already_paired[i] == 0:\n Gs.append(pair_graph(S[i], S[i]))\n break\n\nG = np.array(Gs).sum(axis=0) // len(Gs)\n\ndef is_perfect_matching(G):\n N = len(G)\n for i in range(N):\n for j in range(i+1, N):\n if G[i, j] == 1:\n l = list(range(N))\n l.remove(i)\n l.remove(j)\n if len(l) == 0:\n return True\n if is_perfect_matching(G[l][:, l]):\n return True\n return False\n\nif is_perfect_matching(G):\n print('YES')\nelse:\n print('NO')", "def _3():\n from collections import defaultdict\n\n def can_pair(s1, s2):\n l = []\n for c1, c2 in zip(s1, s2):\n c = sorted([c1, c2])\n if c in l:\n l.remove(c)\n else:\n l.append(c)\n\n if len(s1) % 2 == 0:\n return len(l) == 0\n else:\n return len(l) == 1 and l[0][0] == l[0][1]\n\n def pair_graph(s1, s2):\n N = len(s1)\n G = np.zeros([N, N])\n for i in range(N):\n for j in range(i+1, N):\n if s1[i] == s2[j] and s1[j] == s2[i]:\n G[i, j] = 1\n G[j, i] = 1\n return G\n\n import numpy as np\n H, W = list(map(int, input().split(' ')))\n S = []\n d = defaultdict(list)\n\n for h in range(H):\n s = input()\n S.append(s)\n d[''.join(sorted(S))].append(h)\n\n already_paired = np.zeros(H)\n\n Gs = []\n\n for i in range(H):\n if already_paired[i]:\n continue\n\n for j in range(i+1, H):\n if already_paired[j]:\n continue\n\n if can_pair(S[i], S[j]):\n already_paired[i] = 1\n already_paired[j] = 1\n G = pair_graph(S[i], S[j])\n Gs.append(G)\n break\n\n if already_paired.sum() < H - 1:\n print('NO')\n exit()\n\n elif already_paired.sum() == H - 1:\n for i in range(H):\n if already_paired[i] == 0:\n G = pair_graph(S[i], S[i])\n Gs.append(G)\n break\n\n G = np.array(Gs).sum(axis=0) // len(Gs)\n\n def is_perfect_matching(G):\n N = len(G)\n if N == 1:\n return True\n\n for i in range(N):\n for j in range(i+1, N):\n if G[i, j] == 1:\n l = list(range(N))\n l.remove(i)\n l.remove(j)\n if len(l) == 0:\n return True\n if is_perfect_matching(G[l][:, l]):\n return True\n return False\n\n if is_perfect_matching(G):\n print('YES')\n else:\n print('NO')\n\nif __name__ == '__main__':\n _3()"] | ['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s280820589', 's476328671', 's740942960', 's079842461'] | [3188.0, 14548.0, 21768.0, 21564.0] | [19.0, 158.0, 2109.0, 374.0] | [1171, 1237, 2003, 2213] |
p03383 | u467736898 | 2,000 | 262,144 | There is an H \times W grid (H vertical, W horizontal), where each square contains a lowercase English letter. Specifically, the letter in the square at the i-th row and j-th column is equal to the j-th character in the string S_i. Snuke can apply the following operation to this grid any number of times: * Choose two different rows and swap them. Or, choose two different columns and swap them. Snuke wants this grid to be _symmetric_. That is, for any 1 \leq i \leq H and 1 \leq j \leq W, the letter in the square at the i-th row and j-th column and the letter in the square at the (H + 1 - i)-th row and (W + 1 - j)-th column should be equal. Determine if Snuke can achieve this objective. | ['from itertools import groupby\nH, W = map(int, input().split())\nif H<=6:\n assert False\nS = ["" for _ in range(W)]\nT = []\nfor _ in range(H):\n s = input()\n T.append(s)\n for i, c in enumerate(s):\n S[i] += c\nT = [sorted(t) for t in T]\nS = [sorted(s) for s in S]\nT.sort()\nS.sort()\ncnt = 0\nfor _, g in groupby(T):\n if len(list(g))%2:\n cnt += 1\nif H%2 < cnt:\n print("NO")\n exit()\ncnt = 0\nfor _, g in groupby(S):\n if len(list(g))%2:\n cnt += 1\nif W%2 < cnt:\n print("NO")\n exit()\nprint("YES")\n', 'from itertools import groupby\nH, W = map(int, input().split())\nif W%2==1:\n assert False\nS = ["" for _ in range(W)]\nT = []\nfor _ in range(H):\n s = input()\n T.append(s)\n for i, c in enumerate(s):\n S[i] += c\nT = [sorted(t) for t in T]\nS = [sorted(s) for s in S]\nT.sort()\nS.sort()\ncnt = 0\nfor _, g in groupby(T):\n if len(list(g))%2:\n cnt += 1\nif H%2 < cnt:\n print("NO")\n exit()\ncnt = 0\nfor _, g in groupby(S):\n if len(list(g))%2:\n cnt += 1\nif W%2 < cnt:\n print("NO")\n exit()\nprint("YES")\n', '\n\nfrom itertools import groupby\nH, W = map(int, input().split())\nS_ = ["" for _ in range(W)]\nT_ = []\nfor _ in range(H):\n s = input()\n T_.append(s)\n for i, c in enumerate(s):\n S_[i] += c\nT = [sorted(t) for t in T_]\nS = [sorted(s) for s in S_]\ncnt = 0\nfor _, g in groupby(sorted(T)):\n if len(list(g))%2:\n cnt += 1\nif H%2 < cnt:\n print("NO")\n exit()\ncnt = 0\nfor _, g in groupby(sorted(S)):\n if len(list(g))%2:\n cnt += 1\nif W%2 < cnt:\n print("NO")\n exit()\nif W%2 or H%2:\n print("YES")\n exit()\nT1 = []\nT2 = []\nfor i, (_, t) in enumerate(sorted(zip(T, T_))):\n if i%2:\n T1.append(t)\n else:\n T2.append(t)\nT_p = T1 + T2[::-1]\nS_pp = ["" for _ in range(W)]\nfor t in T_p:\n for i, c in enumerate(t):\n S_pp[i] += c\nS1 = []\nS2 = []\nfor i, (_, s) in enumerate(sorted(zip(S, S_pp))):\n if i%2:\n S1.append(s)\n else:\n S2.append(s)\nS_p = S1 + S2[::-1]\nfor s1, s2 in zip(S_p, S_p[::-1]):\n for c1, c2 in zip(s1, s2[::-1]):\n if c1!=c2:\n print("NO")\n exit()\nprint("YES")\n'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s395699482', 's883984776', 's423715195'] | [3064.0, 3064.0, 3188.0] | [18.0, 18.0, 18.0] | [533, 535, 1112] |
p03383 | u476199965 | 2,000 | 262,144 | There is an H \times W grid (H vertical, W horizontal), where each square contains a lowercase English letter. Specifically, the letter in the square at the i-th row and j-th column is equal to the j-th character in the string S_i. Snuke can apply the following operation to this grid any number of times: * Choose two different rows and swap them. Or, choose two different columns and swap them. Snuke wants this grid to be _symmetric_. That is, for any 1 \leq i \leq H and 1 \leq j \leq W, the letter in the square at the i-th row and j-th column and the letter in the square at the (H + 1 - i)-th row and (W + 1 - j)-th column should be equal. Determine if Snuke can achieve this objective. | ["h,w = list(map(int,input().split()))\ns = []\nfor i in range(h):\n s.append(input())\n\ncon = []\n\nfor i in range(h):\n for j in range(i+1,h):\n ij = []\n ji = []\n for k in range(w):\n ij.append(s[i][k]+s[j][k])\n ji.append(s[j][k]+s[i][k])\n if sorted(ij) == sorted(ji):\n con.append([i,j])\n\nrest = set()\nfor i in range(h):\n rest.add(i)\nfor x in con:\n if x[0] in rest and x[1] in rest:\n rest -= {x[0],x[1]}\n\nif len(rest) <= 1:print('Yes')\nelse:print('No')\n", 'H, W = map(int, input().split())\nS = [input() for i in range(H)]\n \ndef check(l):\n u = [0]*W\n mid = W % 2\n for i in range(W):\n if u[i]:\n continue\n for j in range(i+1, W):\n for p, q in l:\n sp = S[p]; sq = S[q]\n if sp[i] != sq[j] or sp[j] != sq[i]:\n break\n else:\n u[j] = 1\n break\n else:\n if mid:\n for p, q in l:\n sp = S[p]; sq = S[q]\n if sp[i] != sq[i]:\n break\n else:\n mid = 0\n continue\n break\n else:\n return 1\n return 0\n \ndef make(c, l, u, p):\n while c in u:\n c += 1\n if c == H:\n if check(l):\n print("YES")\n exit(0)\n return\n if p:\n l.append((c, c))\n make(c+1, l, u, 0)\n l.pop()\n for i in range(c+1, H):\n if i in u:\n continue\n u.add(i)\n l.append((c, i))\n make(c+1, l, u, p)\n l.pop()\n u.remove(i)\n \nmake(0, [], set(), H%2)\nprint("NO")'] | ['Wrong Answer', 'Accepted'] | ['s441294319', 's347516823'] | [3064.0, 3064.0] | [18.0, 92.0] | [524, 1165] |
p03384 | u102461423 | 2,000 | 262,144 | Takahashi has an ability to generate a tree using a permutation (p_1,p_2,...,p_n) of (1,2,...,n), in the following process: First, prepare Vertex 1, Vertex 2, ..., Vertex N. For each i=1,2,...,n, perform the following operation: * If p_i = 1, do nothing. * If p_i \neq 1, let j' be the largest j such that p_j < p_i. Span an edge between Vertex i and Vertex j'. Takahashi is trying to make his favorite tree with this ability. His favorite tree has n vertices from Vertex 1 through Vertex n, and its i-th edge connects Vertex v_i and w_i. Determine if he can make a tree isomorphic to his favorite tree by using a proper permutation. If he can do so, find the lexicographically smallest such permutation. | ['import sys\ninput = sys.stdin.readline\n\nN = int(input())\nVW = [[int(x)-1 for x in input().split()] for _ in range(N-1)]\n\n\n\ngraph = [[] for _ in range(N)]\ndeg = [0] * (N)\nfor v,w in VW:\n graph[v].append(w)\n graph[w].append(v)\n deg[v] += 1\n deg[w] += 1\n\ndef dijkstra(start):\n INF = 10**10\n dist = [INF] * N\n q = [(start,0)]\n while q:\n qq = []\n for v,d in q:\n dist[v] = d\n for w in graph[v]:\n if dist[w] == INF:\n qq.append((w,d+1))\n q = qq\n return dist\n\ndist = dijkstra(0)\nv = dist.index(max(dist))\ndist = dijkstra(v)\nw = dist.index(max(dist))\ndiag = v,w\n', "import sys\ninput = sys.stdin.readline\n\nN = int(input())\nVW = [[int(x)-1 for x in input().split()] for _ in range(N-1)]\n\n\n\ngraph = [[] for _ in range(N)]\ndeg = [0] * N\nfor v,w in VW:\n graph[v].append(w)\n graph[w].append(v)\n deg[v] += 1\n deg[w] += 1\n\ndef dijkstra(start):\n INF = 10**10\n dist = [INF] * N\n q = [(start,0)]\n while q:\n qq = []\n for v,d in q:\n dist[v] = d\n for w in graph[v]:\n if dist[w] == INF:\n qq.append((w,d+1))\n q = qq\n return dist\n\ndist = dijkstra(0)\nv = dist.index(max(dist))\ndist = dijkstra(v)\nw = dist.index(max(dist))\ndiag = v,w\n\ndef create_perm(v,parent,next_p,arr):\n next_v = None\n V1 = []\n V2 = []\n for w in graph[v]:\n if w == parent:\n continue\n if deg[w] == 1:\n V1.append(w)\n else:\n V2.append(w)\n if len(V1) == 0 and len(V2) == 0:\n arr.append(next_p)\n return\n if len(V2) > 0:\n next_v = V2[0]\n else:\n next_v = V1[-1]\n V1 = V1[:-1]\n arr += list(range(next_p+1,next_p+len(V1)+1))\n arr.append(next_p)\n next_p += len(V1)+1\n #create_perm(next_v,v,next_p,arr)\n\nP = []\ncreate_perm(diag[1],None,1,P)\n\nQ = []\ncreate_perm(diag[0],None,1,Q)\n\nif len(P) != N:\n answer = -1\nelse:\n if P > Q:\n P = Q\n answer = ' '.join(map(str,P))\nprint(answer)\n\n", "import sys\ninput = sys.stdin.readline\n\nN = int(input())\nVW = [[int(x)-1 for x in input().split()] for _ in range(N-1)]\n\n\n\ngraph = [[] for _ in range(N)]\ndeg = [0] * (N)\nfor v,w in VW:\n graph[v].append(w)\n graph[w].append(v)\n deg[v] += 1\n deg[w] += 1\n\ndef dijkstra(start):\n INF = 10**10\n dist = [INF] * N\n q = [(start,0)]\n while q:\n qq = []\n for v,d in q:\n dist[v] = d\n for w in graph[v]:\n if dist[w] == INF:\n qq.append((w,d+1))\n q = qq\n return dist\n\ndist = dijkstra(0)\nv = dist.index(max(dist))\ndist = dijkstra(v)\nw = dist.index(max(dist))\ndiag = v,w\n\ndef create_perm(v,parent,next_p,arr):\n next_v = None\n V1 = []\n V2 = []\n for w in graph[v]:\n if w == parent:\n continue\n if deg[w] == 1:\n V1.append(w)\n else:\n V2.append(w)\n if len(V1) == len(V2) == 0:\n arr.append(next_p)\n return\n# next_v = V2[0] if V2 else V1.pop()\n# arr += list(range(next_p+1,next_p+len(V1)+1))\n# arr.append(next_p)\n# next_p += len(V1)+1\n create_perm(next_v,v,next_p,arr)\n\nP = [] * N\ncreate_perm(diag[1],None,1,P)\n\nQ = [] * N\ncreate_perm(diag[0],None,1,Q)\n\nif len(P) != N:\n answer = -1\nelse:\n if P > Q:\n P = Q\n answer = ' '.join(map(str,P))\nprint(answer)\n", "import sys\ninput = sys.stdin.readline\n\nN = int(input())\nVW = [[int(x)-1 for x in input().split()] for _ in range(N-1)]\n\n\n\ngraph = [[] for _ in range(N)]\ndeg = [0] * N\nfor v,w in VW:\n graph[v].append(w)\n graph[w].append(v)\n deg[v] += 1\n deg[w] += 1\n\ndef dijkstra(start):\n INF = 10**10\n dist = [INF] * N\n q = [(start,0)]\n while q:\n qq = []\n for v,d in q:\n dist[v] = d\n for w in graph[v]:\n if dist[w] == INF:\n qq.append((w,d+1))\n q = qq\n return dist\n\ndist = dijkstra(0)\nv = dist.index(max(dist))\ndist = dijkstra(v)\nw = dist.index(max(dist))\ndiag = v,w\n\ndef create_perm(v,parent,next_p,arr):\n next_v = None\n V1 = []\n V2 = []\n for w in graph[v]:\n if w == parent:\n continue\n if deg[w] == 1:\n V1.append(w)\n else:\n V2.append(w)\n if len(V1) == len(V2) == 0:\n arr.append(next_p)\n return\n next_v = V2[0] if V2 else V1.pop()\n# arr += list(range(next_p+1,next_p+len(V1)+1))\n# arr.append(next_p)\n# next_p += len(V1)+1\n create_perm(next_v,v,next_p,arr)\n\nP = []\ncreate_perm(diag[1],None,1,P)\n\nQ = []\ncreate_perm(diag[0],None,1,Q)\n\nif len(P) != N:\n answer = -1\nelse:\n if P > Q:\n P = Q\n answer = ' '.join(map(str,P))\nprint(answer)\n\n", "import sys\nsys.setrecursionlimit(10**7)\ninput = sys.stdin.readline\n\nN = int(input())\nVW = [[int(x)-1 for x in input().split()] for _ in range(N-1)]\n\n\n\ngraph = [[] for _ in range(N)]\ndeg = [0] * N\nfor v,w in VW:\n graph[v].append(w)\n graph[w].append(v)\n deg[v] += 1\n deg[w] += 1\n\ndef dijkstra(start):\n INF = 10**10\n dist = [INF] * N\n q = [(start,0)]\n while q:\n qq = []\n for v,d in q:\n dist[v] = d\n for w in graph[v]:\n if dist[w] == INF:\n qq.append((w,d+1))\n q = qq\n return dist\n\ndist = dijkstra(0)\nv = dist.index(max(dist))\ndist = dijkstra(v)\nw = dist.index(max(dist))\ndiag = v,w\n\ndef create_perm(start):\n arr = []\n v = start\n parent = None\n next_p = 1\n while True:\n n = 0\n next_v = None\n for w in graph[v]:\n if w == parent:\n continue\n if next_v is None or deg[next_v] < deg[w]:\n next_v = w\n if deg[w] == 1:\n n += 1\n if next_v is None:\n return arr + [next_p]\n if deg[next_v] == 1:\n n -= 1\n arr += list(range(next_p+1,next_p+n+1))\n arr.append(next_p)\n next_p += n+1\n parent = v\n v = next_v\n\nP = create_perm(diag[1])\n\nQ = create_perm(diag[0])\n\nif len(P) != N:\n answer = -1\nelse:\n if P > Q:\n P = Q\n answer = ' '.join(map(str,P))\nprint(answer)\n\n"] | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s153860597', 's274067232', 's690837832', 's831088342', 's926437552'] | [43220.0, 43160.0, 43188.0, 43160.0, 53640.0] | [472.0, 452.0, 440.0, 537.0, 722.0] | [706, 1446, 1393, 1383, 1495] |
p03389 | u056977516 | 2,000 | 262,144 | You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations. | ['# ANSHUL GAUTAM\n# IIIT-D\n\nA,B,C = map(int, input().split())\nm = max(A,B,C)\ns = sum(m-A,m-B,m-C)\nif(s%2 == 0):\n\tprint(s//2)\nelse:\n\tprint(s//2 + 2)\n\n\n\n\n', '# ANSHUL GAUTAM\n# IIIT-D\n\nA,B,C = map(int, input().split())\nm = max(A,B,C)\ns = sum((m-A,m-B,m-C))\nif(s%2 == 0):\n\tprint(s//2)\nelse:\n\tprint(s//2 + 2)\n\n\n\n\n'] | ['Runtime Error', 'Accepted'] | ['s314910328', 's255453794'] | [2940.0, 2940.0] | [17.0, 17.0] | [150, 152] |
p03389 | u062147869 | 2,000 | 262,144 | You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations. | ["from math import sqrt \nQ = int(input())\ntable=[]\nfor i in range(Q):\n A,B=map(int,input().split())\n if A>B:\n table.append([B,A])\n else:\n table.append([A,B])\ndef f(a,b):\n if a==b:\n return 2*a-2\n if a+1==b:\n return 2*a-2\n m = int(sqrt(a*b))\n if m**2 ==a*b:\n return 2*m-3\n if m*(m+1) >= a*b:\n return 2*m -2\n return 2*m-1\n\nans = []\nfor a,b in table:\n ans.append(f(a,b))\nprint('\\n'.join(map(str,ans)))", 'A,B,C=map(int,input().split())\nL=[A,B,C]\nL.sort()\nans=0\ns=(L[-1]-L[0])//2\nL[0]=L[0]+2*s\nt=(L[-1]-L[1])//2\nL[1]=L[1]+2*t\nL.sort()\na=0\nif L[0]!=L[1]:\n a=2\nelif L[1]!=L[2]:\n a=1\nprint(s+t+a)'] | ['Runtime Error', 'Accepted'] | ['s746698434', 's416997450'] | [3064.0, 3064.0] | [18.0, 17.0] | [467, 193] |
p03389 | u104282757 | 2,000 | 262,144 | You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations. | ['# D\nimport math\nQ = int(input())\nA_list = []\nB_list = []\nfor _ in range(Q):\n A, B = map(int, input().split())\n A_list.append(min(A, B))\n B_list.append(max(A, B))\n \nfor i in range(Q):\n A = A_list[i]\n B = B_list[i]\n \n if A == B:\n print(A+B-2)\n continue\n \n R = int(math.sqrt(A*B-1))\n Q = (A*B-1) // R\n \n if Q <= R+1:\n add = min(Q - A - 1, B - R - 1) \n elif (Q - R)**2 - 4*(A*B-Q*R) > 0:\n add = int(((Q - R) - math.sqrt((Q - R)**2 - 4*(A*B-Q*R))) / 2)\n if (R + add)*(Q-add) == A*B:\n add -= 1\n else:\n add = 0\n print((A-1) + R + add)\n ', '# C\nABC = sorted(list(map(int, input().split())))\n\nres = 0\n\nres += ABC[2] - ABC[1]\nABC[0] += ABC[2] - ABC[1]\nABC[1] = ABC[2]\n\nif (ABC[2] - ABC[0]) % 2 == 0:\n res += (ABC[2] - ABC[0]) // 2\nelse:\n res += (ABC[2] - ABC[0]) // 2 + 2\n \nprint(res)'] | ['Runtime Error', 'Accepted'] | ['s924159291', 's686589554'] | [3064.0, 3316.0] | [18.0, 20.0] | [644, 250] |
p03389 | u108784591 | 2,000 | 262,144 | You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations. | ['a=int(input())\nb=int(input())\nc=int(input())\nnum=[a,b,c]\nnum.sort()\nans=((num[2]*3)-(num[0]+num[1]+num[2]))/2\nprint(ans)\n', 'a,b,c=map(int,input().split())\nnum=[a,b,c]\nnum.sort()\nans=((num[2]*3)-(num[0]+num[1]+num[2]))/2\nprint(ans)\n', 'import math\n\na,b,c=map(int,input().split())\nnum=[a,b,c]\nnum.sort()\nif (num[1]+num[0])%2==0:\n\tans=((num[2]*3)-(num[0]+num[1]+num[2]))/2\nelse :\n\tans=(((num[2]+1)*3)-(num[0]+num[1]+num[2]))/2\nans=math.floor(ans)\nprint(ans)'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s009830973', 's130787918', 's612349849'] | [2940.0, 2940.0, 3064.0] | [17.0, 17.0, 17.0] | [121, 107, 219] |
p03389 | u137228327 | 2,000 | 262,144 | You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations. | ['lst = list(map(int,input().split()))\nprint(lst)\nlst.sort()\ncount = 0\nwhile len(set(lst)) != 1:\n for i in range(len(lst)-2):\n if lst[i] <= lst[i+1]-2:\n lst[i] += 2\n elif lst[i] <= lst[i+2] and lst[i+1] <= lst[i-1]:\n lst[i] += 1\n lst[i+1] += 1\n count += 1\n lst.sort()\n #print(lst)\nprint(count)\n', '\nlst = list(map(int,input().split()))\n#print(lst)\nlst.sort()\ncount = 0\nwhile len(set(lst)) != 1:\n for i in range(len(lst)-2):\n if lst[i] <= lst[i+1]-2:\n lst[i] += 2\n elif lst[i] <= lst[i+2] and lst[i+1] <= lst[i-1]:\n lst[i] += 1\n lst[i+1] += 1\n count += 1\n lst.sort()\n #print(lst)\nprint(count)\n'] | ['Wrong Answer', 'Accepted'] | ['s974179623', 's582131114'] | [9104.0, 9132.0] | [30.0, 28.0] | [351, 353] |
p03389 | u169138653 | 2,000 | 262,144 | You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations. | ['a=list(map(int,input().split()))\ncnt=0\nfor i in range(3):\n if a[i]%2==1:\n cnt+=1\nif cnt==0 or cnt==3:\n print((3*max(a)-sum(a))//2)\nelse:\n print((max(a)+1-a[0])//2+(max(a)+1-a[1])//2+(max(a)+1-a[2])//2+1)\n', 'a=list(map(int,input().split()))\ncnt=0\nfor i in range(3):\n if a[i]%2==1:\n cnt+=1\nif cnt==0 or cnt==3:\n print((3*max(a)-sum(a))//2)\nelif cnt==1 and max(a)%2==1 or cnt==2 and max(a)%2==0:\n print((max(a)-a[0])//2+(max(a)-a[1])//2+(max(a)-a[2])//2+1)\nelse: \n print((max(a)+1-a[0])//2+(max(a)+1-a[1])//2+(max(a)+1-a[2])//2+1)\n'] | ['Wrong Answer', 'Accepted'] | ['s189702324', 's864934462'] | [3060.0, 3064.0] | [17.0, 17.0] | [210, 329] |
p03389 | u183631685 | 2,000 | 262,144 | You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations. | ['li = [int(i) for i in input().split()]\ncount = 0\nwhile True:\n li.sort(reverse=True)\n dif_1 = li[0] - li[1]\n dif_2 = li[1] - li[2]\n if dif_1 == 0 and dif_2 == 0:\n break\n if dif_1 == 1 and dif_2 == 0:\n li[1] += 1\n li[2] += 1\n count += 1\n continue\n else:\n li[2] += 2\n count += 1\nprint(li)\n', 'li = list(map(int, input().split()))\nli.sort(reverse=True)\ncount, mod = divmod(li[0] * 2 - li[1] - li[2], 2)\nif mod == 1:\n count += 2\n\nprint(count)'] | ['Wrong Answer', 'Accepted'] | ['s464908984', 's156733939'] | [3060.0, 2940.0] | [19.0, 17.0] | [353, 150] |
p03389 | u185896732 | 2,000 | 262,144 | You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations. | ['s=list(map(int,input().split()))\na=max(s)*3-sum(s)\nif a%2==1\n a+=3\nprint(a//2)', 's=list(map(int,input().split()))\na=max(s)*3-sum(s)\nif a%2==1:\n a+=3\nprint(a//2)'] | ['Runtime Error', 'Accepted'] | ['s539186991', 's223429248'] | [2940.0, 2940.0] | [17.0, 17.0] | [81, 82] |
p03389 | u186426563 | 2,000 | 262,144 | You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations. | ['x = sorted(list(map(int, input().split())))\ncount = 0\nwhile(x[0] != x[2]):\n if(x[1] != x[2]):\n x[0] += 1\n x[1] += 1\n else:\n x[0] += 2\n count += 1\n x = sorted(x)\n', 'x = sorted(list(map(int, input().split())))\ncount = 0\nwhile(x[0] != x[2]):\n if(x[1] != x[2]):\n x[0] += 1\n x[1] += 1\n else:\n x[0] += 2\n count += 1\n x = sorted(x)\nprint(count)\n'] | ['Wrong Answer', 'Accepted'] | ['s147605936', 's356086205'] | [2940.0, 3060.0] | [17.0, 17.0] | [194, 207] |
p03389 | u200239931 | 2,000 | 262,144 | You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations. | ['from collections import Counter\ndef getinputdata():\n\n array_result = []\n \n array_result.append(input().split(" "))\n\n flg = 1\n\n try:\n\n while flg:\n\n data = input()\n\n if(data != ""):\n \n array_result.append(data.split(" "))\n\n else:\n\n flg = 0\n finally:\n\n return array_result\n\narr_data = getinputdata()\n\narr = sorted([int(x) for x in arr_data[0]])\n\nmindata = int(arr[0])\nmiddledata = int(arr[1])\nmaxdata = int(arr[2])\n\nsabun01 = middledata-mindata\nsabun02 = maxdata-middledata\nsabun03 = maxdata-mindata\n\nprint(sabun01,sabun02,sabun03)\n\n\nif sabun01 % 2 == 0 and sabun02 % 2 == 0:\n \n cnt01 = (sabun01 // 2) + sabun02\n \nelif sabun01 % 2 == 0 and sabun02 % 2 != 0:\n \n cnt01 = (sabun01 // 2) + sabun02 \n\nelif sabun01 % 2 != 0 and sabun02 % 2 != 0:\n\n cnt01 = (sabun01 // 2) + 1 + 2 + sabun02-1\n\nelif sabun01 % 2 != 0 and sabun02 % 2 == 0:\n \n cnt01 = (sabun01 // 2) + 1 + 1 + sabun02\n\n\n\nif sabun02 % 2 == 0 and sabun03 % 2 == 0:\n cnt02 = (sabun02 // 2) + sabun03\n \nelif sabun02 % 2 == 0 and sabun03 % 2 != 0:\n cnt02 = (sabun02 // 2) + sabun03\n \n \nelif sabun02 % 2 != 0 and sabun03 % 2 != 0:\n \n cnt02 = (sabun02 // 2) + 1 + 2 + sabun03-1\n \nelif sabun02 % 2 != 0 and sabun03 % 2 == 0:\n \n cnt02 = (sabun02 // 2) + 1 + 1+ sabun03\n\nprint(min(cnt01,cnt02)) \n ', 'from collections import Counter\ndef getinputdata():\n\n array_result = []\n \n array_result.append(input().split(" "))\n\n flg = 1\n\n try:\n\n while flg:\n\n data = input()\n\n if(data != ""):\n \n array_result.append(data.split(" "))\n\n else:\n\n flg = 0\n finally:\n\n return array_result\n\narr_data = getinputdata()\n\narr = sorted([int(x) for x in arr_data[0]])\n\nmindata = int(arr[0])\nmiddledata = int(arr[1])\nmaxdata = int(arr[2])\n\nsabun01 = middledata-mindata\nsabun02 = maxdata-middledata\nsabun03 = maxdata-mindata\n\n\nif sabun01 % 2 == 0 :\n \n cnt01 = (sabun01 // 2) + sabun02 \n\nelif sabun01 % 2 != 0 and sabun02 % 2 != 0:\n\n cnt01 = (sabun01 // 2) + 1 + 2 + sabun02-1\n\nelif sabun01 % 2 != 0 and sabun02 % 2 == 0:\n \n cnt01 = (sabun01 // 2) + 1 + 1 + sabun02\n\n\n\nif sabun02 % 2 == 0 and sabun03 % 2 == 0:\n \n cnt02 = (sabun02 // 2) + sabun03\n \nelif sabun02 % 2 == 0 and sabun03 % 2 != 0:\n \n cnt02 = (sabun02 // 2) + sabun03 + 2\n \nelif sabun02 % 2 != 0:\n \n cnt02 = (sabun02 // 2) + 1 + 2 + sabun03-1\n \nprint(min(cnt01,cnt02)) \n '] | ['Wrong Answer', 'Accepted'] | ['s325032663', 's029924198'] | [3316.0, 3316.0] | [21.0, 21.0] | [1500, 1251] |
p03389 | u226155577 | 2,000 | 262,144 | You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations. | ['a, b, c = sorted(map(int, input().split()))\na = c-a; b = c-b\np = a%2; q = b%2\nif p and q:\n print(a//2+b//2)\nelif p or q:\n print(a//2+b//2+2)\nelse:\n print(a//2+b//2)\n', 'a, b, c = sorted(map(int, input().split()))\na = c-a; b = c-b\np = a%2; q = b%2\nif p and q:\n print(a//2+b//2+1)\nelif p or q:\n print(a//2+b//2+2)\nelse:\n print(a//2+b//2)\n'] | ['Wrong Answer', 'Accepted'] | ['s564947539', 's184495842'] | [3060.0, 2940.0] | [17.0, 17.0] | [174, 176] |
p03389 | u364439209 | 2,000 | 262,144 | You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations. | ['def twoNumIncrement(n, m):\n return n+1, m+1\n\ndef doubleIncrement(n):\n return n+1\n\ndef equal(A, B, C):\n return A==B and B==C\n\ndef evenEven(d1, d2):\n return d1//2 + d2//2\n\n# tmpInput = "2 6 3\\n"\n\ninDatas = input().strip(\'\\n\').split(\' \')\n\ninDatas = list(map(int, inDatas))\ninDatas.sort()\nA = inDatas[0]\nB = inDatas[1]\nC = inDatas[2]\n\ndiff1 = C - A\ndiff2 = C - B\n\nprocCount = 0\n\nif not diff1%2 and not diff2%2:\n print(evenEven(diff1, diff2))\nelif diff1%2 or diff2%2:\n print(2+evenEven(diff1, diff2))\nelse:\n print(1+evenEven(diff1, diff2))\n\n', 'def evenEven(d1, d2):\n return d1//2 + d2//2\n\n# tmpInput = "2 6 3\\n"\n\ninDatas = input().strip(\'\\n\').split(\' \')\n\ninDatas = list(map(int, inDatas))\ninDatas.sort()\nA = inDatas[0]\nB = inDatas[1]\nC = inDatas[2]\n\ndiff1 = C - A\ndiff2 = C - B\n\nif not diff1%2 and not diff2%2:\n print(evenEven(diff1, diff2))\nelif (diff1%2 and not diff2%2) or (not diff1%2 and diff2%2):\n print(2+evenEven(diff1, diff2))\nelse:\n print(1+evenEven(diff1, diff2))'] | ['Wrong Answer', 'Accepted'] | ['s940420526', 's146657367'] | [3064.0, 3064.0] | [18.0, 17.0] | [600, 485] |
p03389 | u375870553 | 2,000 | 262,144 | You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations. | ["def main():\n num = [int(i) for i in input().split()]\n num.sort()\n ans = 0\n ans+=((num[2]-num[1])//2)\n num[1]+=(num[2]-num[1])//2*2\n ans+=((num[2]-num[0])//2)\n num[0]+=(num[2]-num[0])//2*2\n if not (num[0]==num[1] and num[1]==num[2] and num[0]==num[2]):\n ans += 2\n print(ans)\n\nif __name__ == '__main__':\n main()", "def main():\n num = [int(i) for i in input().split()]\n num.sort()\n ans = 0\n ans += (num[2]-num[1])\n ans+=(num[1]-num[0])//2\n if (num[1]-num[0])%2==1:\n ans+=2\n print(ans)\n\n\nif __name__ == '__main__':\n main()"] | ['Wrong Answer', 'Accepted'] | ['s354301040', 's010750585'] | [3064.0, 3060.0] | [18.0, 18.0] | [346, 236] |
p03389 | u476199965 | 2,000 | 262,144 | You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations. | ['N = int(input())\nc = -1\ns = 0\nfor i in range(N):\n ai,bi = map(int,input().split())\n s += ai\n if ai > bi:\n if c == -1:\n c = bi\n if bi < c:\n c = bi\nif c == -1:\n print(0)\nelse:\n print(s-c)\n', 'x = list(map(int,input().split()))\nx.sort()\na = x[2]-x[0]\nb = x[2]-x[1]\n\nif a%2 == 0 and b%2 == 0:print(a//2+b//2)\nif a%2 == 0 and b%2 == 1:print(a//2+(b+1)//2+1)\nif a%2 == 1 and b%2 == 0:print((a+1)//2+b//2+1)\nif a%2 == 1 and b%2 == 1:print((a-1)//2+(b-1)//2+1)'] | ['Runtime Error', 'Accepted'] | ['s793951295', 's481200345'] | [3188.0, 3064.0] | [17.0, 18.0] | [237, 262] |
p03389 | u520158330 | 2,000 | 262,144 | You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations. | ['A,B,C = map(int,input().split())\n\nM = sorted([A,B,C])\nans = 0\n\n#Step 1\nans += M[2]-M[1]\nM[0] += M[2]-M[1]\nM[1] += M[2]-M[1]\n\n#Step 2\nans += (M[2]-M[0])//2\nif (M[2]-M[0])%2==0:\n M[0] += M[2]-M[0]\nelse:\n M[0] += M[2]-M[0]+1\n M[1] += 1\n M[2] += 1\n ans += 2\n \nprint(M,ans)', 'A,B,C = map(int,input().split())\n\nM = sorted([A,B,C])\nans = 0\n\n#Step 1\nans += M[2]-M[1]\nM[0] += M[2]-M[1]\nM[1] += M[2]-M[1]\n\n#Step 2\nans += (M[2]-M[0])//2\nif (M[2]-M[0])%2==0:\n M[0] += M[2]-M[0]\nelse:\n M[0] += M[2]-M[0]+1\n M[1] += 1\n M[2] += 1\n ans += 2\n \nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s702719225', 's354328290'] | [3064.0, 3064.0] | [17.0, 18.0] | [286, 284] |
p03389 | u536113865 | 2,000 | 262,144 | You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations. | ['l = list(map(int, input().split()))\nl.sort()\na,b,c = l[0],l[1],l[2]\nif (a-b)%2 == 1:\n print(c-a+1)\nelse:\n print(c-a+2)\n', 'l = list(map(int, input().split()))\nl.sort()\na,b,c = l[0],l[1],l[2]\nif (a-b)%2 == 0:\n print(c-b+(b-a)//2)\nelse:\n print(c-b+(b-a)//2+2)\n'] | ['Wrong Answer', 'Accepted'] | ['s114870077', 's163737718'] | [2940.0, 2940.0] | [17.0, 17.0] | [125, 141] |
p03389 | u584749014 | 2,000 | 262,144 | You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations. | ['import math\n\ndef slv(A, B):\n A, B = (A, B) if A > B else (B, A)\n \n s = A * B\n c = math.floor(math.sqrt(A * B))\n \n if A == B:\n return 2 * c - 2\n elif c * c < s:\n return 2 * c - 2\n elif c * (c - 1) < s:\n return 2 * c - 3\n\nQ = int(input())\nfor q in range(Q):\n A, B = map(int, input().split())\n print(slv(A, B))', 'lst = list(map(int, input().split()))\n\nlst.sort()\n\nmini = lst[0]\nav = lst[1]\nmax = lst[2]\n\nd = max - av\nans1 = 0\nmini += d\nd2 = max - mini\n\nif d2 % 2:\n d2 = (d2 + 1) // 2\n ans1 += 1\n\nelse:\n d2 = d2 // 2\n\nans1 += d + d2\n\nans2 = 0\nmini = lst[0]\nav = lst[1]\nmax = lst[2]\n\nd = max - av\n\nmini += d\n\nd2 = max + 1 - mini\n\nif d2 % 2:\n d2 = (d2 + 1) // 2\n ans2 += 1\nelse:\n d2 = d2 // 2\n\nans2 += d + d2 + 1\n\nprint(min(ans1, ans2))\n\n\n\n'] | ['Runtime Error', 'Accepted'] | ['s217992100', 's425548551'] | [3064.0, 3064.0] | [17.0, 17.0] | [358, 442] |
p03389 | u623819879 | 2,000 | 262,144 | You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations. | ['*a=map(int,open(0))\nm=max(a)\nt=m*3-sum(a)\nif t%2==1:t+=3\nprint(t//2)', 'a,b,c=map(int,input().split())\na,b,c=sorted([a,b,c])\n\n#parity=set(list(map(lambda x: x % 2,[a,b,c])))\nparity=list(map(lambda x: x % 2,[a,b,c]))\n\nif len(set(parity))==1:\n print(int((3*max(a,b,c)-a-b-c)/2))\nelse:\n if (b-c)%2==0:\n ex=1\n else:\n ex=2\n print(int((max(a,b,c)-a)/2)+int((max(a,b,c)-b)/2)+int((max(a,b,c)-c)/2) + ex)\n ', 'a,b,c=map(int,input().split())\n\n#parity=set(list(map(lambda x: x % 2,[a,b,c])))\nparity=list(map(lambda x: x % 2,[a,b,c]))\n\nif len(set(parity))==1:\n print(int((3*max(a,b,c)-a-b-c)/2))\nelse:\n if len(set(list(map(lambda x: x % 2, set([a,b,c])-set([max(a,b,c)]) ))))==1:\n ex=1\n else:\n ex=2\n print(int((3*max(a,b,c)-a-b-c)/2) + ex)\n ', 'a,b,c=map(int,input().split())\na,b,c=sorted([a,b,c])\n\n#parity=set(list(map(lambda x: x % 2,[a,b,c])))\nparity=list(map(lambda x: x % 2,[a,b,c]))\n\nif len(set(parity))==1:\n print(int((3*max(a,b,c)-a-b-c)/2))\nelse:\n if (b-a)%2==0:\n ex=1\n else:\n ex=2\n print(int((max(a,b,c)-a)/2)+int((max(a,b,c)-b)/2)+int((max(a,b,c)-c)/2) + ex)\n '] | ['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s347481080', 's462605800', 's967757132', 's683122562'] | [2940.0, 3064.0, 3064.0, 3064.0] | [18.0, 18.0, 18.0, 17.0] | [68, 355, 358, 355] |
p03389 | u624475441 | 2,000 | 262,144 | You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations. | ['A = list(map(int, input().split()))\nM = max(A)\nS = sum(A)\nM += M % 2 != S % 2\nprint((3 * M - sum) // 2)', 'A = list(map(int, input().split()))\nM = max(A)\nS = sum(A)\nM += M % 2 != S % 2\nprint((3 * M - S) // 2)'] | ['Runtime Error', 'Accepted'] | ['s069553771', 's201004818'] | [2940.0, 2940.0] | [18.0, 18.0] | [103, 101] |
p03389 | u672710370 | 2,000 | 262,144 | You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations. | ['import sys\nsys.setrecursionlimit(10**6)\n\ndebug_mode = True if len(sys.argv) > 1 and sys.argv[1] == "-d" else False\nif debug_mode:\n import os\n infile = open(os.path.basename(__file__).replace(".py", ".in"))\n\n def input():\n return infile.readline()\n\n\n# ==============================================================\n\n\ndef main():\n a, b, c = list(map(int, input().strip().split()))\n s = sum(a, b, c)\n x = min(a, b, c)\n steps = 0\n while True:\n if s + steps * 2 == 3 * x:\n break\n elif s + steps * 2 < 3 * x:\n steps += 1\n elif s + steps * 2 > 3 * x:\n x += 1\n print(steps)\n\n\nmain()\n\n# ==============================================================\n\nif debug_mode:\n infile.close()\n', 'import sys\nsys.setrecursionlimit(10**6)\n\ndebug_mode = True if len(sys.argv) > 1 and sys.argv[1] == "-d" else False\nif debug_mode:\n import os\n infile = open(os.path.basename(__file__).replace(".py", ".in"))\n\n def input():\n return infile.readline()\n\n\n# ==============================================================\n\n\ndef main():\n a, b, c = list(map(int, input().strip().split()))\n s = sum((a, b, c))\n x = max(a, b, c)\n steps = 0\n while True:\n if s + steps * 2 == 3 * x:\n break\n elif s + steps * 2 < 3 * x:\n steps += 1\n elif s + steps * 2 > 3 * x:\n x += 1\n print(steps)\n\n\nmain()\n\n# ==============================================================\n\nif debug_mode:\n infile.close()\n'] | ['Runtime Error', 'Accepted'] | ['s758548542', 's200450428'] | [3064.0, 3064.0] | [20.0, 17.0] | [764, 766] |
p03389 | u762540523 | 2,000 | 262,144 | You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations. | ['a,b,c=sorted(map(int,input().split()));d,e=c-a,c-b;print(d//2+e//2+(3-d%2+e%2)%3)', 'a,b,c=sorted(map(int,input().split()));d,e=c-a,c-b;print(d//2+e//2+(3-d%2-e%2)%3)'] | ['Wrong Answer', 'Accepted'] | ['s793517368', 's984353127'] | [3316.0, 2940.0] | [21.0, 17.0] | [81, 81] |
p03389 | u777529218 | 2,000 | 262,144 | You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations. | ['import numpy as np\n\na=np.vectorize(int)(input().split())\n\ncnt2=np.vectorize(lambda x: int((np.max(a)-x)/2))(a)\ncnt1=np.max(a)-a-2*cnt2\nprint(a)\nprint(sum(cnt2)+[0,2,1][sum(cnt1)])', 'import numpy as np\n\na=np.vectorize(int)(input().split())\n\ncnt2=np.vectorize(lambda x: int((np.max(a)-x)/2))(a)\ncnt1=np.max(a)-a-2*cnt2\nprint(sum(cnt2)+[0,2,1][sum(cnt1)])'] | ['Wrong Answer', 'Accepted'] | ['s224724439', 's333656398'] | [12504.0, 12504.0] | [152.0, 151.0] | [179, 170] |
p03389 | u777923818 | 2,000 | 262,144 | You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations. | ['# -*- coding: utf-8 -*-\nfrom math import sqrt\ndef inpl(): return map(int, input().split())\nQ = int(input())\n\ndef check(X, m):\n if X//m > m:\n return True\n else:\n return False\n\nfor q in range(Q):\n A, B = inpl()\n if A > B:\n A, B = B, A\n\n X = A*B\n if X <= 2:\n print(0)\n continue\n elif X == 3:\n print(1)\n continue\n \n L = int(sqrt(X))\n if L*L == X:\n L -= 1\n\n ok, ng = 1, X+1\n while ng - ok > 1:\n m = (ok+ng)//2\n if check(X-1, m):\n ok = m\n else:\n ng = m\n \n tmp = L + ok\n \n if A == B:\n print(tmp)\n else:\n if A>1 and X-1//(A-1) == B and X-1//A == B-1:\n print(tmp-2)\n elif (X-1)//A == A:\n print(tmp-2)\n else:\n print(tmp-1)', '# -*- coding: utf-8 -*-\ndef inpl(): return map(int, input().split())\nA, B, C = sorted(list(inpl()))\nres = 0\nres += (C-B)\nA += res\nB += res\nd, m = divmod(B-A, 2)\nres += d+2*m\nprint(res)'] | ['Runtime Error', 'Accepted'] | ['s770542974', 's387125589'] | [3064.0, 3060.0] | [17.0, 17.0] | [823, 184] |
p03389 | u814986259 | 2,000 | 262,144 | You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations. | ['ABC=list(map(int,input().split()))\nABC.sort()\nans=0\nans+=(ABC[2]-ABC[0])//2\nif (ABC[2]-ABC[0])%2==1:\n ans+=(ABC[2]-ABC[0])//2\n ABC[0]=ABC[2]-1\n ans+=(ABC[2]-ABC[1])//2\n if (ABC[2]-ABC[1])%2 == 1:\n ans+=1\n else:\n ans+=2 \nelse:\n ans+=(ABC[2]-ABC[1])//2\n if (ABC[2]-ABC[1])%2 == 1:\n ans+=2\n\nprint(ans)\n', 'ABC=map(int,input().split())\nABC.sort()\nans=0\nans+=(ABC[2]-ABC[0])//2\nif (ABC[2]-ABC[0])%2==1:\n ans+=(ABC[2]-ABC[0])//2\n ABC[0]=ABC[2]-1\n ans+=(ABC[2]-ABC[1])//2\n if (ABC[2]-ABC[1])%2 == 1:\n ans+=1\n else:\n ans+=2 \nelse:\n ans+=(ABC[2]-ABC[1])//2\n if (ABC[2]-ABC[1])%2 == 1:\n ans+=2\n else:\n ans+=1\nprint(ans)', 'ABC=list(map(int,input().split()))\nABC.sort()\nans=0\nans+=(ABC[2]-ABC[0])//2\nif (ABC[2]-ABC[0])%2==1:\n ans+=(ABC[2]-ABC[1])//2\n if (ABC[2]-ABC[1])%2 == 1:\n ans+=1\n else:\n ans+=2 \nelse:\n ans+=(ABC[2]-ABC[1])//2\n if (ABC[2]-ABC[1])%2 == 1:\n ans+=2\n\nprint(ans)\n'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s487878091', 's519618759', 's440730401'] | [3064.0, 3064.0, 3064.0] | [17.0, 17.0, 17.0] | [316, 327, 272] |
p03389 | u824237520 | 2,000 | 262,144 | You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations. | ["s = list(input())\n\nn = len(s)\n\na = [0] * n\n\nMOD = 998244353\n\nfor i in range(n):\n a[i] = ord(s[i]) - ord('a')\n\nif max(a) == min(a):\n print(1)\n exit()\nelif n == 3:\n def solver(m):\n x = m // 100\n y = ( m % 100 ) // 10\n z = m % 10\n if x != y:\n c = (3 - x - y) % 3\n temp = c * 110 + z\n if temp not in ans:\n ans.add(temp)\n solver(temp)\n if y != z:\n c = (3 - y - z) % 3\n temp = x * 100 + c * 11\n if temp not in ans:\n ans.add(temp)\n solver(temp)\n\n t = a[0] * 100 + a[1] * 10 + a[2]\n ans = set()\n ans.add(t)\n solver(t)\n print(len(ans))\n exit()\nelif n == 2:\n print(2)\n exit()\n\ndp = [[0,0,0] for _ in range(3)]\n\ndp[0][0] = 1\ndp[1][1] = 1\ndp[2][2] = 1\n\nfor i in range(n-1):\n T = [[0,0,0] for _ in range(3)]\n T[0][0] = (dp[1][0] + dp[2][0]) % MOD\n T[0][1] = (dp[1][1] + dp[2][1]) % MOD\n T[0][2] = (dp[1][2] + dp[2][2]) % MOD\n T[1][0] = (dp[0][2] + dp[2][2]) % MOD\n T[1][1] = (dp[0][0] + dp[2][0]) % MOD\n T[1][2] = (dp[0][1] + dp[2][1]) % MOD\n T[2][0] = (dp[0][1] + dp[1][1]) % MOD\n T[2][1] = (dp[0][2] + dp[1][2]) % MOD\n T[2][2] = (dp[0][0] + dp[1][0]) % MOD\n dp, T = T, dp\n\nm = sum(a) % 3\n\nans = 3 ** (n-1) - (dp[0][m] + dp[1][m] + dp[2][m])\n\ncheck = 1\nfor i in range(n-1):\n if a[i] == a[i+1]:\n check = 0\n break\n\nans += check\n\n#print(dp, 2 ** (n-1))\n\nprint(ans % MOD)\n", 'a = list(map(int, input().split()))\n\na.sort()\n\ntemp = a[2] * 2 - a[1] - a[0]\n\nif temp % 2 == 0:\n print(temp // 2)\nelse:\n print(temp // 2 + 2)\n'] | ['Wrong Answer', 'Accepted'] | ['s316901040', 's064634189'] | [3312.0, 2940.0] | [18.0, 17.0] | [1503, 148] |
p03389 | u876442898 | 2,000 | 262,144 | You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations. | ['A, B, C = map(int, input().split(" "))\ncnt = 0\n\nif (A%2 == B%2) and (B%2 == C%2):\n pass\nelse:\n if A%2 == B%2:\n A += 1\n B += 1\n cnt += 1\n elif A%2 == C%2:\n A += 1\n C += 1\n cnt += 1\n else:\n B += 1\n C += 1\n cnt += 1\n\nABC = sorted([A, B, C])\ncnt += (ABC[0] - ABC[1]) / 2\ncnt += (ABC[0] - ABC[2]) / 2\nprint cnt', '# -*- coding: utf-8 -*-\n\n\nA, B, C = map(int, input().split(" "))\ncnt = 0\n\nif (A%2 == B%2) and (B%2 == C%2):\n pass\nelse:\n if A%2 == B%2:\n A += 1\n B += 1\n cnt += 1\n elif A%2 == C%2:\n A += 1\n C += 1\n cnt += 1\n else:\n B += 1\n C += 1\n cnt += 1\n\nABC = sorted([A, B, C])\ncnt += (ABC[2] - ABC[1]) // 2\ncnt += (ABC[2] - ABC[0]) // 2\nprint(cnt)'] | ['Runtime Error', 'Accepted'] | ['s634969390', 's374220904'] | [3064.0, 3064.0] | [17.0, 18.0] | [380, 581] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.