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
p03701
u075303794
2,000
262,144
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well. However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
['import sys\n\nN=int(input())\nS=[int(input()) for _ in range(N)]\nS.sort()\n\nans=sum(S)\n\nif ans%10!=0:\n print(ans)\n sys.exit()\nelse:\n for i in range(N):\n if S[i]%10!=0:\n print(ans-S[i])\n else:\n print(0)', 'import sys\n \nN=int(input())\nS=[int(input()) for _ in range(N)]\nS.sort()\n \nans=sum(S)\n \nif ans%10!=0:\n print(ans)\n sys.exit()\nelse:\n for i in range(N):\n if S[i]%10!=0:\n print(ans-S[i])\n sys.exit()\n else:\n print(0)']
['Wrong Answer', 'Accepted']
['s532367736', 's995653620']
[9180.0, 8992.0]
[32.0, 29.0]
[212, 232]
p03701
u117182712
2,000
262,144
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well. However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
["import sys\n\nimport math\n\n\nclass Solution(object):\n def __init__(self):\n self.N, self.A, self.B = map(int, sys.stdin.readline().split(' '))\n self.h = []\n for _ in range(self.N):\n self.h.append(int(sys.stdin.readline()))\n self.extra_damage = self.A - self.B\n\n def solve(self):\n max_h = max(self.h)\n at_most = int(max_h / self.B) + 1\n at_least = int(max_h / self.A) + 1\n result = self.binary_search_lowest_kaisu(at_least, at_most)\n print(result)\n\n def binary_search_lowest_kaisu(self, low, high):\n if low == high:\n return low\n mid = low + (high - low) // 2\n if self.enough(mid):\n return self.binary_search_lowest_kaisu(low, mid)\n else:\n return self.binary_search_lowest_kaisu(mid + 1, high)\n\n def enough(self, kaisu):\n hps_remain = []\n for x in self.h:\n hp_remain = x - kaisu * self.B\n if hp_remain > 0:\n hps_remain.append(hp_remain)\n counter = 0\n for hp_remain in hps_remain:\n counter += math.ceil(hp_remain / self.extra_damage)\n if counter > kaisu:\n return False\n return True\n\nSolution().solve()\n", "import sys\n\n\nclass Solution(object):\n def __init__(self):\n self.N = int(sys.stdin.readline())\n self.s = []\n for _ in range(self.N):\n self.s.append(int(sys.stdin.readline()))\n\n \n def naive_solve(self):\n sums = [0]\n for num in self.s:\n sums.extend([s + num for s in sums])\n for r in sorted(sums, reverse=True):\n if r % 10:\n return r\n return 0\n\n def answer_solve(self):\n S = sum(self.s)\n if S % 10:\n return S\n smallest = float('inf')\n for num in self.s:\n if num % 10:\n smallest = min(smallest, num)\n if smallest != float('inf'):\n return S - smallest\n return 0\n\n\n\n\nprint(Solution().answer_solve())\n"]
['Runtime Error', 'Accepted']
['s293828147', 's716004981']
[3064.0, 3064.0]
[18.0, 17.0]
[1251, 811]
p03701
u120026978
2,000
262,144
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well. However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
['n = int(input())\ns = [int(i) for i in range(n)]\n\ns.sort()\nans = sum(s)\nif ans % 10 != 0:\n print(ans)\nelse:\n for i in range(n):\n if s[i] % 10 != 0:\n print(ans - s[i])\n break\n else:\n print(0)', 'n = int(input())\ns = [int(input()) for i in range(n)]\n\ns.sort()\nans = sum(s)\nif ans % 10 != 0:\n print(ans)\nelse:\n for i in range(n):\n if s[i] % 10 != 0:\n print(ans - s[i])\n break\n else:\n print(0)']
['Wrong Answer', 'Accepted']
['s673247639', 's116672734']
[3060.0, 3060.0]
[24.0, 17.0]
[234, 240]
p03701
u177481830
2,000
262,144
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well. However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
['N=int(input())\ns_arr=np.zeros(N, dtype=np.int8)\nfor i in range(N):\n s_arr[i]=int(input())\n\ntotal=np.sum(s_arr)\nif total%10!=0:\n print(total)\nelse:\n msk=(s_arr%10!=0)\n if np.sum(msk)==0:\n print(0)\n else:\n print(total-np.min(s_arr[msk]))', 'import numpy as np\n\nN=int(input())\ns_arr=np.zeros(N, dtype=np.int8)\nfor i in range(N):\n s_arr[i]=int(input())\n\ntotal=np.sum(s_arr)\nif total%10!=0:\n print(total)\nelse:\n msk=(s_arr%10!=0)\n if np.sum(msk)==0:\n print(0)\n else:\n print(total-np.min(s_arr[msk]))']
['Runtime Error', 'Accepted']
['s816069261', 's940943354']
[3060.0, 14424.0]
[17.0, 151.0]
[264, 284]
p03701
u301043830
2,000
262,144
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well. However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
['import sys\n\nN = int(input())\ns = list()\nfor i in range(N):\n\ts.append(int(input()))\n\ns.sort(reverse=True)\n\nprint(s)\n\npoint = sum(s)\nl = len(s)\ni = 0\n\nwhile i < l:\n\tif point % 10 != 0:\n\t\tprint(point)\n\t\tsys.exit()\n\tif not s == []:\n\t\tfor x in reversed(list(s)):\n\t\t\tif not x % 10 == 0:\n\t\t\t\tpoint -= s.pop(s.index(x))\n\t\t\t\tbreak\n\ti += 1\n\nprint("0")', 'import sys\n\nN = int(input())\ns = list()\nfor i in range(N):\n\ts.append(int(input()))\n\ns.sort(reverse=True)\n\npoint = sum(s)\nl = len(s)\ni = 0\n\nwhile i < 1:\n\tif point % 10 != 0:\n\t\tprint(point)\n\t\tsys.exit()\n\tif not s == []:\n\t\tpoint -= s.pop()\n\ti += 1\n\nprint("0")', 'import sys\n\nN = int(input())\ns = list()\nfor i in range(N):\n\ts.append(int(input()))\n\ns.sort(reverse=True)\n\nprint(s)\n\npoint = sum(s)\nl = len(s)\ni = 0\n\nwhile i < 1:\n\tif point % 10 != 0:\n\t\tprint(point)\n\t\tsys.exit()\n\tif not s == []:\n\t\tpoint -= s.pop()\n\ti += 1\n\nprint("0")', 'import sys\n\nN = int(input())\ns = list()\nfor i in range(N):\n\ts.append(int(input()))\n\ns.sort(reverse=True)\n\npoint = sum(s)\nl = len(s)\ni = 0\n\nwhile i < l:\n\tif point % 10 != 0:\n\t\tprint(point)\n\t\tsys.exit()\n\tif not s == []:\n\t\tfor x in reversed(list(s)):\n\t\t\tif not x % 10 == 0:\n\t\t\t\tpoint -= s.pop(s.index(x))\n\t\t\t\tbreak\n\ti += 1\n\nprint("0")']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s590302934', 's854868438', 's907797010', 's634487205']
[3064.0, 3064.0, 3064.0, 3064.0]
[18.0, 17.0, 17.0, 18.0]
[341, 256, 266, 331]
p03701
u330544393
2,000
262,144
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well. However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
[' sum_ = sum(s)\n if (sum_ % 10) != 0:\n return sum_\n else:\n st = sorted(s)\n m = 0\n for i in range(len(st)):\n s2 = sum(s[:i-1]+s[i+1:])\n if (s2 % 10) != 0:\n return s2\n\n for i in range(len(st)):\n s2 = sum(s[:i-1]+s[i+2:])\n if (s2 % 10) != 0:\n return s2\n return 0\n\nN = int(input())\na = [int(input()) for i in range(N)]\nprint(max_of(a)) # [a1, a2, a3, ..., aN]\n\n', 'def max_of(s):\n sum_ = sum(s)\n if (sum_ % 10) != 0:\n return sum_\n else:\n le = len(s)\n m = 0\n for i in range(le):\n for j in range(i+1, le):\n tmp = (sum_ - s[i] - s[j])\n if(tmp % 10 != 0):\n return tmp\n\n return 0\n\nN = int(input())\na = [int(input()) for i in range(N)]\nprint(max_of(sorted(a))) # [a1, a2, a3, ..., aN]\n', 'def max_of(s):\n print(s)\n sum_ = sum(s)\n if (sum_ % 10) != 0:\n return sum_\n else:\n st = sorted(s)\n m = 0\n for i in range(len(st)):\n s2 = sum(s[:i-1]+s[i+1:])\n if (s2 % 10) != 0:\n return s2\n\n for i in range(len(st)):\n s2 = sum(s[:i-1]+s[i+2:])\n if (s2 % 10) != 0:\n return s2\n return 0\n\nN = int(input())\na = [int(input()) for i in range(N)]\nprint(max_of(a)) # [a1, a2, a3, ..., aN]\n\n', 'def max_of(s):\n sum_ = sum(s)\n if (sum_ % 10) != 0:\n return sum_\n else:\n st = sorted(s)\n m = 0\n for j in range(len(st)):\n for i in range(len(st)):\n try:\n s2 = sum(s[:i-1]+s[i+(j+1):])\n if (s2 % 10) != 0:\n return s2\n except:\n pass\n return 0\n\nN = int(input())\na = [int(input()) for i in range(N)]\nprint(max_of(a)) # [a1, a2, a3, ..., aN]\n\n', 'def max_of(s):\n sum_ = sum(s)\n if (sum_ % 10) != 0:\n return sum_\n else:\n st = sorted(s)\n m = 0\n for i in range(len(st)):\n s2 = sum(s[:i-1]+s[i+1:])\n if (s2 % 10) != 0:\n return s2\n\n for i in range(len(st)):\n try:\n s2 = sum(s[:i-1]+s[i+2:])\n if (s2 % 10) != 0:\n return s2\n except:\n pass\n return 0\n\nN = int(input())\na = [int(input()) for i in range(N)]\nprint(max_of(a)) # [a1, a2, a3, ..., aN]\n\n', "import sys\n\ndef gen_list(lst):\n length = len(lst)\n dp = [{}] * length\n dp[0] = {lst[0]: True}\n dp[0][0] = True\n\n \n for i in range(1, length):\n s = lst[i]\n dp[i] = dp[i-1]\n keys = [k for k in dp[i].keys()]\n for val in keys:\n dp[i][val + s] = True\n \n return sorted(dp[length-1].keys(), reverse=True)\n\nN = int(input())\ns = [int(input()) for _ in range(N)]\n\nfor m in gen_list(s):\n if m % 10 != 0:\n print(m)\n sys.exit()\n\nprint('0')"]
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s058831827', 's093866099', 's143116612', 's678241814', 's909104926', 's514609755']
[2940.0, 3060.0, 3064.0, 3060.0, 3064.0, 3924.0]
[17.0, 21.0, 17.0, 32.0, 17.0, 59.0]
[477, 414, 505, 498, 562, 533]
p03701
u346308892
2,000
262,144
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well. However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
['\nN=input()\nscores=[]\nwhile True:\n try:\n scores.append(int(input()))\n except:\n break\n\n\nscores=sorted(scores)\n\nres=0\nfor i,e in enumerate(scores):\n if e%10!=0:\n res=e\n break\n\nprint(res)', 'N=input()\nscores=[]\nwhile True:\n try:\n scores.append(int(input()))\n except:\n break\n\n\nscores=sorted(scores)\n\nres=sum(scores)\nres_tmp=res\ni=0\nwhile True:\n\n if res_tmp%10!=0:\n res=res_tmp\n break\n if i==len(scores)-1:\n res=0\n break\n res_tmp=res-scores[i]\n i+=1\n\nprint(res)']
['Wrong Answer', 'Accepted']
['s158727322', 's485412157']
[3060.0, 3064.0]
[17.0, 17.0]
[220, 328]
p03701
u390618988
2,000
262,144
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well. However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
["from sys import stdin, exit\n\nN = int(stdin.readline().rstrip())\ns = [int(stdin.readline().rstrip()) for _ in range(N)]\ndp = [0] * (100 * N)\ndp[0] = 1\nfor n in range(N):\n for p in range(len(dp), 0, -1):\n if p - s[n] >= 0\n if dp[p - s[n]] == 1:\n dp[p] = 1\nfor k in range(len(dp)):\n if dp[len(dp) - k - 1] == 1 and (len(dp) - k - 1) % 10 != 0:\n print(len(dp) - k - 1)\n exit()\nprint('0')\n", "from sys import stdin, exit\n\nN = int(stdin.readline().rstrip())\ns = [int(stdin.readline().rstrip()) for _ in range(N)]\ndp = [0] * (100 * N)\ndp[0] = 1\nfor n in range(N):\n for p in range(len(dp) - 1, 0, -1):\n if p - s[n] >= 0:\n print(p)\n if dp[p - s[n]] == 1 and 0 <= p:\n dp[p] = 1\nfor k in range(len(dp)):\n if dp[len(dp) - k - 1] == 1 and (len(dp) - k - 1) % 10 != 0:\n print(len(dp) - k - 1)\n exit()\nprint('0')\n", "from sys import stdin, exit\n\nN = int(stdin.readline().rstrip())\ns = [int(stdin.readline().rstrip()) for _ in range(N)]\ndp = [0] * (100 * N)\ndp[0] = 1\nfor n in range(N):\n for p in range(len(dp) - 1, 0, -1):\n if p - s[n] >= 0:\n if dp[p - s[n]] == 1 and 0 <= p:\n dp[p] = 1\nfor k in range(len(dp)):\n if dp[len(dp) - k - 1] == 1 and (len(dp) - k - 1) % 10 != 0:\n print(len(dp) - k - 1)\n exit()\nprint('0')\n"]
['Runtime Error', 'Wrong Answer', 'Accepted']
['s397485759', 's766114169', 's985350747']
[2940.0, 8308.0, 3064.0]
[17.0, 1071.0, 304.0]
[437, 474, 453]
p03701
u410717334
2,000
262,144
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well. However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
['N=int(input())\ns=[int(input()) for _ in range(N)]\ndef cal(S,items):\n if(S&10!=0):\n return S\n temp=100000000\n for i in items:\n if(i%10!=0):\n temp=min(i,temp)\n return S-temp if(S-temp>0) else 0\nprint(cal(sum(s),s))', 'N=int(input())\ns=[int(input()) for _ in range(N)]\ndef cal(S,items):\n if(S%10!=0):\n return S\n temp=100000000\n for i in items:\n if(i%10!=0):\n temp=min(i,temp)\n return S-temp if(S-temp>0) else 0\nprint(cal(sum(s),s))']
['Wrong Answer', 'Accepted']
['s390967750', 's879286096']
[3064.0, 3060.0]
[18.0, 17.0]
[249, 249]
p03701
u481514236
2,000
262,144
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well. However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
['N = int(input())\n\nlst = []\n\nfor i in range(N):\n lst.append(int(input()))\n\nlst.sort(reverse=True)\n\nlst2 = [ i / 10 for i in lst if i % 10 != 0 ]\np_list = []\n\nif len(lst2) == 0:\n print(0)\nelse:\n for i in range(N):\n for j in range(N):\n if i > N-j :\n break\n else:\n print(lst[i:N-j])\n ans = sum(lst[i:N-j])\n if ans % 10 != 0:\n print(ans)\n exit(0)\n', 'import itertools\n\nN = int(input())\n\nlst = []\n\nfor i in range(N):\n lst.append(int(input()))\n\nl_sum = sum(lst)\n\np_list = []\n\nif l_sum % 10 == 0:\n \n \n \n\n for i, _ in enumerate(lst, 1):\n \n for j in itertools.permutations(lst, r=i): \n p_list.append(j)\n \n q_list = sorted(set(list(map(sum, p_list))),reverse=True)\n \n x = 0\n for i, item in enumerate(q_list, 1):\n if item % 10 != 0 :\n print(item)\n x = 1\n break\n \n if x = 0:\n print(0)\n\nelse:\n print (l_sum)\n\n\n', 'import itertools\n\nN = int(input())\n\nlst = []\n\nfor i in range(N):\n lst.append(int(input()))\n\nl_sum = sum(lst)\n\np_list = []\n\nif l_sum % 10 == 0:\n \n \n \n\n for i, _ in enumerate(lst, 1):\n \n for j in itertools.permutations(lst, r=i): \n p_list.append(j)\n print(p_list)\n q_list = sorted(set(list(map(sum, p_list))),reverse=True)\n print(q_list)\n x = 0\n for i, item in enumerate(q_list, 1):\n if item % 10 != 0 :\n print(item)\n exit(0)\n \n if x == 0:\n print(0)\n\nelse:\n print (l_sum)\n\n\n', 'N = int(input())\n\nlst = []\n\nfor i in range(N):\n lst.append(int(input()))\n\nlst.sort()\nlstsum = sum(lst)\np_list = [ i / 10 for i in lst if i % 10 != 0 ]\n\nif len(p_list) == 0:\n print(0)\nelif lstsum % 10 != 0:\n print(lstsum)\nelse:\n for i in range(N):\n ans = lstsum - lst[i]\n if ans % 10 != 0:\n print(ans)\n exit(0)\n']
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s201284102', 's239227717', 's476062524', 's177164762']
[3064.0, 3064.0, 1027992.0, 3060.0]
[18.0, 17.0, 2175.0, 18.0]
[509, 889, 900, 389]
p03701
u536113865
2,000
262,144
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well. However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
['n = int(input())\ns = [int(input()) for i in range(n)]\nif sum(s)%10:\n print(sum(s))\nelse:\n for i in sorted(s):\n if i%10:\n print(sum(s)-i)\n break\n else:\n print(0', 'n = int(input())\ns = [int(input()) for i in range(n)]\nif sum(s)%10:\n print(sum(s))\nelse:\n for i in sorted(s):\n if i%10:\n print(sum(s)-i)\n break\n else:\n print(0)']
['Runtime Error', 'Accepted']
['s645207405', 's770140915']
[2940.0, 3060.0]
[17.0, 18.0]
[204, 205]
p03701
u545368057
2,000
262,144
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well. However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
['n = sum(Ss)\n# INF = 10**10\ndp = [False] * (n+1)\ndp[0] = True\nfor i in range(N):\n x = Ss[i]\n for j in range(n+1):\n if j+x > n : continue \n dp[j+x] = dp[j] or dp[j+x]\n\nans = 0\nfor i in range(n+1):\n if dp[i] and i%10 != 0:\n ans = i\nprint(ans)', 'N = int(input())\nSs = [int(input()) for _ in range(N)]\nn = sum(Ss)\ndp = [[False] * (n+1) for i in range(2)]\ndp[0][0] = True\nfor i in range(N):\n x = Ss[i]\n dp[(i+1)%2][:] = dp[i%2][:]\n for j in range(n+1):\n if j+x > n : continue \n # print(dp[0][j+x],dp[1][j+x])\n dp[(i+1)%2][j+x] = dp[i%2][j] or dp[i%2][j+x]\n print(dp)\n\nans = 0\nfor i in range(n+1):\n if dp[N%2][i] and i%10 != 0:\n ans = i\nprint(ans)', 'N = int(input())\nSs = [int(input()) for _ in range(N)]\nSs.sort()\nans = sum(Ss)\nif ans % 10 != 0:\n print(ans)\n exit()\ncnt_10 = 0\nfor s in Ss:\n if s != 10:continue\n ans -= s\n if ans % 10 != 0:\n print(ans)\n exit()\nprint(0)', 'N = int(input())\nSs = [int(input()) for _ in range(N)]\nn = sum(Ss)\ndp = [[False] * (n+1) for i in range(2)]\ndp[0][0] = True\nfor i in range(N):\n x = Ss[i]\n dp[(i+1)%2][:] = dp[i%2][:]\n for j in range(n+1):\n if j+x > n : continue \n # print(dp[0][j+x],dp[1][j+x])\n dp[(i+1)%2][j+x] = dp[i%2][j] or dp[i%2][j+x]\n # print(dp)\n\nans = 0\nfor i in range(n+1):\n if dp[N%2][i] and i%10 != 0:\n ans = i\nprint(ans)']
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s309230349', 's646598608', 's794653742', 's903495030']
[3064.0, 17236.0, 3060.0, 3436.0]
[19.0, 731.0, 17.0, 620.0]
[269, 441, 248, 443]
p03701
u608297208
2,000
262,144
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well. However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
['import math\nN,A,B = map(int,input().split())\nH = [int(input()) for i in range(N)]\nHs = sum(H)\nc = A - B\nM = math.ceil(Hs / (B * N))\n\nm = math.ceil(Hs / (A * N))\n\nnibun = [M,m]\nwhile M - m > 1:\n\tn = (M + m) // 2\n\tH2 = [H[i] - n * B for i in range(N) if H[i] - n * B > 0]\n\tcnts = [math.ceil(H2[i] / c) for i in range(len(H2))]\n\tcnt = sum(cnts)\n\tif cnt > n:\n\t\tm = n\n\telse:\n\t\tM = n\nprint(m)', 'n = int(input())\nS = [int(input()) for i in range(n)]\nS.sort()\nif sum(S) % 10 == 0:\n\tflag = 0\n\tfor s in S:\n\t\tif s % 10 != 0:\n\t\t\tflag = 1\n\t\t\tbreak\n\tif flag == 1:\n\t\tprint(sum(S) - s)\n\telse:\n\t\tprint(0)\nelse:\n\tprint(sum(S))\n']
['Runtime Error', 'Accepted']
['s683701530', 's319941995']
[3064.0, 3064.0]
[17.0, 17.0]
[386, 220]
p03701
u620868411
2,000
262,144
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well. However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
['# -*- coding: utf-8 -*-\nn = int(input())\ns = []\nfor _ in range(n):\n s.append(int(input()))\ns.sort()\na = sum(s)\n\nif a%10!=0:\n print(a)\n exit()\n\nfor i in range(n):\n if s[i]%10:\n continue\n a -= s[i]\n if a%10!=0:\n print(a)\n exit()\n\nprint(0)\n', '# -*- coding: utf-8 -*-\nn = int(input())\ns = []\nfor _ in range(n):\n s.append(int(input()))\ns.sort()\na = sum(s)\n\nif a%10!=0:\n print(a)\n exit()\n\nfor i in range(n):\n if s[i]%10==0:\n continue\n a -= s[i]\n if a%10!=0:\n print(a)\n exit()\n\nprint(0)\n']
['Wrong Answer', 'Accepted']
['s639777856', 's544412910']
[3060.0, 3060.0]
[18.0, 17.0]
[276, 279]
p03701
u626337957
2,000
262,144
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well. However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
['N = int(input())\nnums=[int(input()) for _ in range(N)]\nsum_nums = sum(nums)\nMAX = 10*4\ndp = [0] * (MAX+1)\ndp[0] = 1\nfor num in nums:\n for i in range(MAX+1):\n if dp[i] == 1 and i + num <= MAX:\n dp[i+num] = 1\nans = 0\nfor i in range(MAX+1):\n if dp[i] == 1 and i%10 != 0:\n ans = i\nprint(ans)\n', 'N = int(input())\nnums=[int(input()) for _ in range(N)]\nMAX = 10**4\ndp = [0] * (MAX+1)\ndp[0] = 1\nfor num in nums:\n for i in range(MAX+1)[::-1]:\n if dp[i] == 1 and (i + num) <= MAX:\n dp[i+num] = 1\nans = 0\nfor i in range(MAX+1):\n if dp[i] == 1 and i%10 != 0:\n ans = i\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s789290166', 's319176889']
[3064.0, 3064.0]
[18.0, 167.0]
[301, 289]
p03701
u714878632
2,000
262,144
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well. However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
['n, a, b = [int(i) for i in input().split()]\nhs = [None]*n\nkill_b = [None]*n\nall_hp = 0\nall_killb = 0\nfor i in range(n):\n hs[i] = int(input())\n # all_hp += hs[i]\n # kill_b[i] = hs[i] // b\n # if((hs[i] % b) != 0):\n # kill_b[i] += 1\n # all_killb += kill_b[i]\n# hs.sort()\nmax_hp = max(hs)\nret = 0\nab = a - b\nright = max_hp // b\nif((max_hp % b) != 0):\n right += 1\nleft = 1\nwhile right != left:\n middle = (right + left) // 2\n \n all_a = 0\n for x in hs:\n nokori = x - (b * middle)\n if(nokori > 0):\n num_a = nokori // ab\n if(x > num_a * a + (middle - num_a) * b):\n num_a += 1\n all_a += num_a\n if(all_a <= middle):\n right = middle\n else:\n left = middle + 1\nret = right\n \n \n # for j in range(n):\n \n \n # #print(base_height)\n # if((j == n-1) or (hs[-(j+2)] <= (base_height))):\n # break\n \n # if(max_height >= hs[-1]):\n # break\nprint(ret)\n', 'n = int(input())\ns = []\nall_ac = 0\nfor i in range(n):\n s.append(int(input()))\n all_ac += s[-1]\ns.sort()\nif((all_ac % 10) == 0):\n for x in s:\n if(x % 10 != 0):\n all_ac -= x\n break\nif((all_ac % 10) == 0):\n print(0)\nelse:\n print(all_ac)\n']
['Runtime Error', 'Accepted']
['s172421517', 's085897603']
[3064.0, 3060.0]
[17.0, 20.0]
[1211, 278]
p03701
u746419473
2,000
262,144
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well. However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
['n = int(input())\n*s, = sorted([int(input()) for _ in range(n)], reverse=True)\n\nans = sum(s)\nif ans%10 == 0:\n for _s in s:\n if _s%10 != 0:\n print(ans-_s)\n quit()\n print(0)\nelse:\n print(ans)\n', 'n = int(input())\n*s, = sorted([int(input()) for _ in range(n)])\n\nans = sum(s)\nif ans%10 == 0:\n for _s in s:\n if _s%10 != 0:\n print(ans-_s)\n quit()\n print(0)\nelse:\n print(ans)\n']
['Wrong Answer', 'Accepted']
['s750002621', 's897925120']
[2940.0, 2940.0]
[17.0, 17.0]
[227, 213]
p03701
u764782120
2,000
262,144
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well. However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
['# -*- coding:utf-8 -*-\n\nN = int(input())\ns = [int(input()) for i in range(N)]\ns.sort()\n\nsum = 0\nfor i in range(N):\n\tsum = sum + int(s[i])\n\nj = 0\nfor i in range(N+1):\n\tif sum % 10 != 0:\n\t\tprint("answer: " + str(sum))\n\t\tbreak\n\telif j < N:\n\t\tsum = sum - int(s[j])\n\t\tj = j + 1\n\telif sum == 0:\n\t\tprint("answer: " + "0")\n', '# -*- coding:utf-8 -*-\n\nN = int(input())\ns = [input() for i in range(N)]\ns.sort()\n\nsum = 0\nfor i in range(N):\n\tsum = sum + int(s[i])\n\nj = 0\nfor i in range(N+1):\n\tif sum % 10 != 0:\n\t\tprint("answer: " + str(sum))\n\t\tbreak\n\telif j < N:\n\t\tsum = sum - int(s[j])\n\t\tj = j + 1\n\telse:\n\t\tprint("answer: " + "0")\n', '# -*- coding:utf-8 -*-\n\nl = input().split()\nN = int(l[0])\nA = int(l[1])\nB = int(l[2])\n\nHP = [int(input()) for i in range(N)]\n\n\ncount = 0\ncheck = 0\nwhile(True):\n\tHP.sort()\n\tprint(HP)\n\n\tfor i in range(N):\n\t\tif i == N-1:\n\t\t\tHP[i] = HP[i] - A\n\t\t\tcount = count + 1\n\t\telse:\n\t\t\tHP[i] = HP[i] - B\n\n\tfor i in range(N):\n\t\tif HP[N-1] < 0 and HP[N-2] < 0:\n\t\t\tcheck = 1\n\n\tif check == 1:\n\t\tbreak\n\nprint("Count: " + str(count))', '# -*- coding:utf-8 -*-\n\nN = int(input())\ns = [int(input()) for i in range(N)]\ns.sort()\n\nsum = 0\nfor i in range(N):\n\tsum = sum + s[i]\n\ncheck = 0\nfor i in range(N):\n\tif sum % 10 != 0:\n\t\tprint(sum)\n\t\tbreak\n\telse:\n\t\tfor j in range(N):\n\t\t\tif s[j] % 10 != 0:\n\t\t\t\tprint(sum - s[j])\n\t\t\t\tcheck == 1\n\t\t\t\tbreak\n\nif check == 0:\n\tprint(0)\n\n', '# -*- coding:utf-8 -*-\n\nN = int(input())\ns = [int(input()) for i in range(N)]\ns.sort()\n\nsum = 0\nfor i in range(N):\n\tsum = sum + s[i]\n\ncheck = 0\nfor i in range(N):\n\tif sum % 10 != 0:\n\t\tprint(sum)\n\t\tbreak\n\telse:\n\t\tfor j in range(N):\n\t\t\tif s[j] % 10 != 0:\n\t\t\t\tprint(sum - s[j])\n\t\t\t\tcheck == 1\n\nif check == 0:\n\tprint(0)\n\n', '# -*- coding:utf-8 -*-\n\nN = int(input())\ns = [input() for i in range(N)]\ns.sort\n\nsum = 0\nfor i in range(N):\n\tsum = sum + int(s[i])\n\nj = 0\nfor i in range(N+1):\n\tif sum % 10 != 0:\n\t\tprint("answer: " + str(sum))\n\t\tbreak\n\telif j < N:\n\t\tsum = sum - int(s[j])\n\t\tj = j + 1\n\telse:\n\t\tprint("answer: " + "0")\n', '# -*- coding:utf-8 -*-\n\nN = int(input())\ns = [int(input()) for i in range(N)]\ns.sort()\n\nsum = 0\nfor i in range(N):\n\tsum = sum + s[i]\n\ncheck = 0\nif sum % 10 != 0:\n\tprint(sum)\nelse:\n\tfor j in range(N):\n\t\tif s[j] % 10 != 0:\n\t\t\tprint(sum - s[j])\n\t\t\tcheck == 1\n\t\t\tbreak\n\nif check == 0:\n\tprint(0)\n\n', '# -*- coding:utf-8 -*-\n\nN = int(input())\ns = [int(input()) for i in range(N)]\ns.sort()\n\nsum = 0\nfor i in range(N):\n\tsum = sum + s[i]\n\ncheck = 0\nif sum % 10 != 0:\n\tprint(sum)\nelse:\n\tfor i in range(N):\n\t\tif s[i] % 10 != 0:\n\t\t\tprint(sum - s[i])\n\t\t\tbreak\n\t\telse:\n\t\t\tcheck = check + 1\n\nif check == N:\n\tprint(0)\n\n']
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s016269755', 's037758745', 's154727153', 's174726026', 's816228338', 's849256856', 's891754057', 's940223061']
[3060.0, 3064.0, 3064.0, 3060.0, 3316.0, 3060.0, 3060.0, 3060.0]
[18.0, 17.0, 18.0, 18.0, 25.0, 17.0, 17.0, 17.0]
[315, 301, 412, 327, 317, 299, 292, 307]
p03701
u765237551
2,000
262,144
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well. However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
['import heapq\nfrom collections import Counter\nimport math\n\nn, a, b = map(int, input().split())\nhs = map(int, (input() for _ in range(n)))\ncounter = [[-x, c] for x, c in Counter(hs).items()]\n\ncum = 0\np = 0\n\nheapq.heapify(counter)\n\ndef f(m, c, a, b):\n ans = 0\n ans += math.floor(m / (a + b*(c-1))) * c\n m -= math.floor(m / (a + b*(c-1))) * (a + b*(c-1))\n ans += min(math.ceil(m / b), math.ceil(m / (a + b*(c-1)))*c)\n return ans\n\nwhile(True):\n x, y = heapq.heappop(counter)\n if len(counter) == 0:\n print(p + f(-x-cum, y, a, b))\n break\n v, _ = counter[0]\n if x==v:\n counter[0][1] += y\n continue\n m = math.ceil((v-x) / (a-b))\n if (-x) - (m*a + m*(y-1)*b + cum) <= 0 and (-v) - m*y*b <=0:\n print(p + f(-x-cum, y, a, b))\n break\n p += m*y\n cum += b*m*y\n heapq.heappush(counter, [x + m*(a-b), y])', 'n = int(input())\nss = list(map(int, (input() for _ in range(n))))\n\nfull = sum(ss)\nnon0s = list(s for s in ss if s%10!=0)\n\nif full%10!=0:\n print(full)\nelse:\n if len(non0s)==0:\n print(0)\n else:\n print(full - min(non0s))']
['Runtime Error', 'Accepted']
['s685656118', 's163116710']
[3316.0, 3060.0]
[21.0, 18.0]
[870, 240]
p03701
u780475861
2,000
262,144
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well. However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
['import sys\nn, *lst = map(int, sys.stdin.read().split())\nres = sum(lst)\nif not res % 10:\n tmp = [i if not i % 10 for i in lst]\n if tmp:\n res -= min(tmp)\n else:\n res = 0\nprint(res)\n ', 'import sys\nn, *lst = map(int, sys.stdin.read().split())\nres = sum(lst)\nif not res % 10:\n tmp = [i for i in lst if not i % 10]\n if tmp:\n res -= min(tmp)\n else:\n res = 0\nprint(res)\n \n', 'import sys\nn, *lst = map(int, sys.stdin.read().split())\nres = sum(lst)\nif not res % 10:\n tmp = [i for i in lst if i % 10]\n if tmp:\n res -= min(tmp)\n else:\n res = 0\nprint(res)\n \n']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s320752777', 's951854031', 's745340218']
[2940.0, 2940.0, 2940.0]
[17.0, 17.0, 17.0]
[190, 191, 187]
p03701
u785205215
2,000
262,144
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well. However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
['from sys import stdin\ndef readLine_int_list():return list(map(int, stdin.readline().split()))\ndef readAll_int(): return list(map(int, stdin))\n\n \ndef main():\n n = int(input())\n s = sorted(readAll_int())\n ans = sum(s)\n \n if ans % 10 == 0:\n for i in range(n):\n if i % 2 != 0:\n ans -= s[i]\n if ans % 10 != 0:\n print(ans)\n else:\n print(0)\n else:\n print(ans)\n \nif __name__ == "__main__":\n main()\n ', 'from sys import stdin\ndef readLine_int_list():return list(map(int, stdin.readline().split()))\ndef readAll_int(): return list(map(int, stdin))\n\n \ndef main():\n n = int(input())\n s = sorted(readAll_int())\n ans = sum(s)\n \n if ans % 10 == 0:\n for i in range(n):\n if s[i] % 2 != 0:\n ans -= s[i]\n break\n if ans % 10 != 0:\n print(ans)\n else:\n print(0)\n else:\n print(ans)\n \nif __name__ == "__main__":\n main()\n ']
['Wrong Answer', 'Accepted']
['s746996794', 's958611803']
[3060.0, 3060.0]
[17.0, 17.0]
[498, 523]
p03701
u803848678
2,000
262,144
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well. However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
['n = int(input())\ns = []\n\ngeta = 0\nfor i in range(n):\n a = int(input())\n if a % 10 == 0:\n geta += a\n else:\n s.append(a)\n\ns.sort(reverse=True)\n\ntmp = sum(s)\n\nruiseki = [tmp]\nfor i in range(n-1):\n ruiseki.append(ruiseki[-1] - s[i])\n\nans = 0\ndef DFS(depth, now):\n global ans\n if depth == n:\n if now%10 != 0:\n ans = max(ans, now)\n return\n\n if now + ruiseki[depth] <= ans:\n return\n DFS(depth+1, now+s[depth])\n DFS(depth+1, now)\nDFS(0,0)\nif ans != 0:\n ans += geta\nprint(ans)', 'n = int(input())\nimport sys\ns = list(map(int, sys.stdin.readlines()))\ns.sort()\nans = sum(s)\nif ans%10:\n print(ans)\nelse:\n for i in s:\n if i%10:\n print(ans - i)\n exit()\n print(0)']
['Runtime Error', 'Accepted']
['s384789333', 's796629421']
[3064.0, 3060.0]
[18.0, 18.0]
[543, 215]
p03701
u936985471
2,000
262,144
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well. However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
['n=int(input())\ns=[None]*n\nminv=100\nfor in range(n):\n s[i]=int(input())\n if minv>s[i]:\n if s[i]%10!=0:\n minv=s[i]\nif minv==100:\n print(0)\nelif sum(s)%10==0:\n print(sum(s)-minv)\nelse:\n print(sum(s))\n\n', 'n=int(input())\ns=[None]*n\nminv=100\nfor i in range(n):\n s[i]=int(input())\n if minv>s[i]:\n if s[i]%10!=0:\n minv=s[i]\nif minv==100:\n print(0)\nelif sum(s)%10==0:\n print(sum(s)-minv)\nelse:\n print(sum(s))\n\n']
['Runtime Error', 'Accepted']
['s381122334', 's480175700']
[2940.0, 3060.0]
[17.0, 17.0]
[211, 213]
p03702
u039623862
2,000
262,144
You are going out for a walk, when you suddenly encounter N monsters. Each monster has a parameter called _health_ , and the health of the i-th monster is h_i at the moment of encounter. A monster will vanish immediately when its health drops to 0 or below. Fortunately, you are a skilled magician, capable of causing explosions that damage monsters. In one explosion, you can damage monsters as follows: * Select an alive monster, and cause an explosion centered at that monster. The health of the monster at the center of the explosion will decrease by A, and the health of each of the other monsters will decrease by B. Here, A and B are predetermined parameters, and A > B holds. At least how many explosions do you need to cause in order to vanish all the monsters?
['n, a, b = map(int, input().split())\nextra_damage = a - b\nh = [int(input()) for i in range(n)]\n# h.sort()\nINF = sum(h)\nl = 0\nr = INF\n\n\ndef widespread(bomb):\n base = b * bomb\n for hi in h:\n if hi - base > 0:\n bomb -= (hi - base + extra_damage - 1) // extra_damage\n return bomb >= 0\n\nwhile l+1 < r:\n m = (l+r)//2\n print(m)\n if widespread(m):\n r = m\n else:\n l = m\nprint(r)\n', 'n, a, b = map(int, input().split())\nextra_damage = a - b\nh = [int(input()) for i in range(n)]\n# h.sort()\nINF = sum(h)\nl = 0\nr = INF\n\n\ndef widespread(bomb):\n base = b * bomb\n for hi in h:\n if hi - base > 0:\n bomb -= (hi - base + extra_damage - 1) // extra_damage\n return bomb >= 0\n\nwhile l+1 < r:\n m = (l+r)//2\n if widespread(m):\n r = m\n else:\n l = m\nprint(r)\n']
['Wrong Answer', 'Accepted']
['s629721703', 's360006381']
[7072.0, 7076.0]
[816.0, 829.0]
[422, 409]
p03702
u327466606
2,000
262,144
You are going out for a walk, when you suddenly encounter N monsters. Each monster has a parameter called _health_ , and the health of the i-th monster is h_i at the moment of encounter. A monster will vanish immediately when its health drops to 0 or below. Fortunately, you are a skilled magician, capable of causing explosions that damage monsters. In one explosion, you can damage monsters as follows: * Select an alive monster, and cause an explosion centered at that monster. The health of the monster at the center of the explosion will decrease by A, and the health of each of the other monsters will decrease by B. Here, A and B are predetermined parameters, and A > B holds. At least how many explosions do you need to cause in order to vanish all the monsters?
['N,A,B = map(int, input().split())\n\nH = [int(input()) for i in range(N)]\n\nlow = sum(H)//(len(H)*B+A-B) - 1\nhigh = max(H)//B+1\nprint(low, high)\n\nd = A-B\nceildiv = lambda x,y: -(-x//y)\n\nwhile low + 1 < high:\n mid = (low+high)//2\n offset = mid*B\n cnt = sum(max(ceildiv(h - offset, d),0) for h in H)\n if cnt > mid:\n low = mid\n else:\n high = mid\n\nprint(high)', 'N,A,B = map(int, input().split())\n\nH = [int(input()) for i in range(N)]\n\nd = A-B\n\ntemp = max(H)\nlow = temp//A - 1\nhigh = temp//B+1\n\nwhile low + 1 < high:\n mid = (low+high)//2\n offset = mid*B\n cnt = -sum((offset-h)//d for h in H if h > offset)\n if cnt > mid:\n low = mid\n else:\n high = mid\n\nprint(high)']
['Wrong Answer', 'Accepted']
['s579410607', 's648762992']
[7072.0, 7072.0]
[1225.0, 742.0]
[363, 311]
p03702
u572144347
2,000
262,144
You are going out for a walk, when you suddenly encounter N monsters. Each monster has a parameter called _health_ , and the health of the i-th monster is h_i at the moment of encounter. A monster will vanish immediately when its health drops to 0 or below. Fortunately, you are a skilled magician, capable of causing explosions that damage monsters. In one explosion, you can damage monsters as follows: * Select an alive monster, and cause an explosion centered at that monster. The health of the monster at the center of the explosion will decrease by A, and the health of each of the other monsters will decrease by B. Here, A and B are predetermined parameters, and A > B holds. At least how many explosions do you need to cause in order to vanish all the monsters?
['N,A,B=map(int,input().split())\nH=[inp(input()) for _ in range(N)]\nH=sorted(H,reverse=True)\n\nok=max(H)//B+1\nng=0\nmid=(ok+ng)//2\nwhile ok-ng>1:\n cntlive=0\n for h in H:\n h-=B*mid\n if h>0:\n cntlive+=1\n if cntlive<=mid:\n ok=mid\n else:\n ng=mid\n mid=(ok+ng)//2\nprint(ok)', 'N,A,B=map(int,input().split())\nH=[int(input()) for _ in range(N)]\nH=sorted(H,reverse=True)\n\nok=max(H)//B+1\nng=0\nmid=(ok+ng)//2\nwhile ok-ng>1:\n cntlive=0\n for h in H:\n h-=B*mid\n if h>0:\n cntlive+=(h+A-B-1)//(A-B)\n if cntlive<=mid:\n ok=mid\n else:\n ng=mid\n mid=(ok+ng)//2\nprint(ok)\n']
['Runtime Error', 'Accepted']
['s321583295', 's705693053']
[3064.0, 8280.0]
[18.0, 1455.0]
[285, 301]
p03702
u608297208
2,000
262,144
You are going out for a walk, when you suddenly encounter N monsters. Each monster has a parameter called _health_ , and the health of the i-th monster is h_i at the moment of encounter. A monster will vanish immediately when its health drops to 0 or below. Fortunately, you are a skilled magician, capable of causing explosions that damage monsters. In one explosion, you can damage monsters as follows: * Select an alive monster, and cause an explosion centered at that monster. The health of the monster at the center of the explosion will decrease by A, and the health of each of the other monsters will decrease by B. Here, A and B are predetermined parameters, and A > B holds. At least how many explosions do you need to cause in order to vanish all the monsters?
['import math\nN,A,B = map(int,input().split())\nH = [int(input()) for i in range(N)]\nHs = sum(H)\nc = A - B\nM = math.ceil(max(H) / B) + 1\n\nm = math.ceil(max(H) / A)\n\nwhile M - m > 1:\n\tn = (M + m) // 2\n\tH2 = [math.ceil((H[i] - n * B) / c) for i in range(N) if H[i] - n * B > 0]\n\tcnt = sum(H2)\n\tif cnt > n:\n\t\tm = n\n\telif cnt == n:\n\t\tM = n\n\t\tbreak\n\telse:\n\t\tM = n\nprint(M)', 'import math\nN,A,B = map(int,input().split())\nH = [int(input()) for i in range(N)]\nHs = sum(H)\nc = A - B\nM = math.ceil(max(H) / B)\n\nm = math.ceil(max(H) / A)\n\nwhile M - m > 1:\n\tn = (M + m) // 2\n\tH2 = [math.ceil((H[i] - n * B) / c) for i in range(N) if H[i] - n * B > 0]\n\tcnt = sum(H2)\n\tif cnt > n:\n\t\tm = n\n\telif cnt == n:\n\t\tM = n\n\t\tbreak\n\telse:\n\t\tM = n\nprint(M)', 'import math\nN,A,B = map(int,input().split())\nH = [int(input()) for i in range(N)]\nHs = sum(H)\nc = A - B\nM = math.ceil(Hs / B)\n\nm = math.ceil(Hs / (A * N))\n\nwhile M - m > 1:\n\tn = (M + m) // 2\n\tH2 = [H[i] - n * B for i in range(N) if H[i] - n * B > 0]\n\tcnts = [math.ceil(H2[i] / c) for i in range(len(H2))]\n\tcnt = sum(cnts)\n\tif cnt > n:\n\t\tm = n\n\telif cnt == n:\n\t\tM = n\n\t\tbreak\n\telse:\n\t\tM = n\nprint(M)', 'import math\nN,A,B = map(int,input().split())\nH = [int(input()) for i in range(N)]\nHs = sum(H)\nc = A - B\nM = math.ceil(max(H) / B)\n\nm = max(H) // A\n\nwhile M - m > 1:\n\tn = (M + m) // 2\n\tH2 = [math.ceil((H[i] - n * B) / c) for i in range(N) if H[i] - n * B > 0]\n\tcnt = sum(H2)\n\tif cnt > n:\n\t\tm = n\n\telif cnt == n:\n\t\tM = n\n\t\tbreak\n\telse:\n\t\tM = n\nprint(M)']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s131603414', 's325652046', 's995545004', 's286752458']
[15216.0, 15216.0, 19060.0, 15232.0]
[1355.0, 1352.0, 1592.0, 1345.0]
[364, 360, 398, 350]
p03702
u714878632
2,000
262,144
You are going out for a walk, when you suddenly encounter N monsters. Each monster has a parameter called _health_ , and the health of the i-th monster is h_i at the moment of encounter. A monster will vanish immediately when its health drops to 0 or below. Fortunately, you are a skilled magician, capable of causing explosions that damage monsters. In one explosion, you can damage monsters as follows: * Select an alive monster, and cause an explosion centered at that monster. The health of the monster at the center of the explosion will decrease by A, and the health of each of the other monsters will decrease by B. Here, A and B are predetermined parameters, and A > B holds. At least how many explosions do you need to cause in order to vanish all the monsters?
['n, a, b = [int(i) for i in input().split()]\nhs = [None]*n\nkill_b = [None]*n\nall_hp = 0\nall_killb = 0\nfor i in range(n):\n hs[i] = int(input())\n # all_hp += hs[i]\n # kill_b[i] = hs[i] // b\n # if((hs[i] % b) != 0):\n # kill_b[i] += 1\n # all_killb += kill_b[i]\n# hs.sort()\nmax_hp = max(hs)\nret = 0\nif(a == b):\n ret = max_hp // a\n if((max_hp % a) != 0):\n ret += 1\n else:\n pass\nelse:\n ab = a - b\n right = max_hp // b\n if((max_hp % b) == 0):\n right += 1\n left = 1\n while right != left:\n middle = (right + left) // 2\n print([left, right, middle])\n all_a = 0\n for x in hs:\n nokori = x - (b * middle)\n if(nokori > 0):\n num_a = nokori // ab\n if(x > num_a * a + (middle - num_a) * b):\n num_a += 1\n all_a += num_a\n if(all_a <= middle):\n right = middle\n else:\n left = middle + 1\n ret = right\n \n \n # for j in range(n):\n \n \n # #print(base_height)\n # if((j == n-1) or (hs[-(j+2)] <= (base_height))):\n # break\n \n # if(max_height >= hs[-1]):\n # break\nprint(ret)\n', 'n, a, b = [int(i) for i in input().split()]\nhs = [None]*n\nkill_b = [None]*n\nfor i in range(n):\n hs[i] = int(input())\nmax_hp = max(hs)\nret = 0\nab = a - b\nright = max_hp // b\nif((max_hp % b) != 0):\n right += 1\nleft = 1\nwhile right != left:\n middle = (right + left) // 2\n \n all_a = 0\n for x in hs:\n nokori = x - (b * middle)\n if(nokori > 0):\n num_a = nokori // ab\n if(x > num_a * a + (middle - num_a) * b):\n num_a += 1\n all_a += num_a\n if(all_a <= middle):\n right = middle\n else:\n left = middle + 1\nret = right\nprint(ret)\n']
['Wrong Answer', 'Accepted']
['s079678326', 's752635893']
[7796.0, 7924.0]
[1951.0, 1909.0]
[1400, 649]
p03702
u766407523
2,000
262,144
You are going out for a walk, when you suddenly encounter N monsters. Each monster has a parameter called _health_ , and the health of the i-th monster is h_i at the moment of encounter. A monster will vanish immediately when its health drops to 0 or below. Fortunately, you are a skilled magician, capable of causing explosions that damage monsters. In one explosion, you can damage monsters as follows: * Select an alive monster, and cause an explosion centered at that monster. The health of the monster at the center of the explosion will decrease by A, and the health of each of the other monsters will decrease by B. Here, A and B are predetermined parameters, and A > B holds. At least how many explosions do you need to cause in order to vanish all the monsters?
['N, A, B = map(int, input().split())\nsrc = [int(input()) for i in range(N)]\n\ndef enough(n):\n bomb = 0\n for h in src:\n if h <= B*n: continue\n h -= B*n\n bomb -= (h-1)//(A-B) + 1\n if bomb > n: return False\n return True\n\n\nng = 0\nok = 10**9\nwhile ok - ng > 1:\n m = (ok+ng) // 2\n if enough(m):\n ok = m\n else:\n ng = m\nprint(ok)', 'N, A, B = map(int, input().split())\nsrc = [int(input()) for i in range(N)]\n\ndef enough(n):\n bomb = 0\n for h in src:\n if h <= B*n: continue\n h -= B*n\n bomb -= (h+1)//(A-B) + 1\n if bomb > n: return False\n return True\n\n\nng = 0\nok = 10**9\nwhile ok - ng > 1:\n m = (ok+ng) // 2\n if enough(m):\n ok = m\n else:\n ng = m\nprint(ok)', 'N, A, B = map(int, input().split())\nsrc = [int(input()) for i in range(N)]\n\ndef enough(n):\n bomb = 0\n for h in src:\n if h <= B*n:continue\n h -= B*n\n bomb -= (h+1)//(A-B) + 1\n if bomb > n: return False\n return True\n\n\nng = 0\nok = 10**9\nwhile ok - ng > 1:\n m = (ok+ng) // 2\n if enough(m):\n ok = m\n else:\n ng = m\nprint(ok)', 'N, A, B = map(int, input().split())\nsrc = [int(input()) for i in range(N)]\n\ndef enough(n):\n bomb = 0\n for h in src:\n if h <= B*n: continue\n h -= B*n\n bomb += (h-1)//(A-B) + 1\n if bomb > n: return False\n return True\n\n\nng = 0\nok = 10**9\nwhile ok - ng > 1:\n m = (ok+ng) // 2\n if enough(m):\n ok = m\n else:\n ng = m\nprint(ok)']
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s088970344', 's735347214', 's816271896', 's234984411']
[7072.0, 2940.0, 7072.0, 7072.0]
[1099.0, 17.0, 1118.0, 890.0]
[426, 430, 413, 426]
p03702
u890165321
2,000
262,144
You are going out for a walk, when you suddenly encounter N monsters. Each monster has a parameter called _health_ , and the health of the i-th monster is h_i at the moment of encounter. A monster will vanish immediately when its health drops to 0 or below. Fortunately, you are a skilled magician, capable of causing explosions that damage monsters. In one explosion, you can damage monsters as follows: * Select an alive monster, and cause an explosion centered at that monster. The health of the monster at the center of the explosion will decrease by A, and the health of each of the other monsters will decrease by B. Here, A and B are predetermined parameters, and A > B holds. At least how many explosions do you need to cause in order to vanish all the monsters?
['N, A, B = map(int, input().split())\nD = A - B\n\nH = sorted([int(input()) for _ in range(N)], reverse=True)\n\ndef f(n):\n needed_attacks = 0\n for h in H:\n r = h - B * n\n if r < 0:\n r = 0\n\n if r % D == 0:\n needed_attacks += r // D\n else:\n needed_attacks += r // D + 1\n\n return needed_attacks <= n\n\ns = 0\ne = H[-1] // B + 1\n\nwhile e - s > 1:\n m = (s + e) // 2\n if f(m):\n e = m\n else:\n s = m\n\nprint(e)\n', 'N, A, B = map(int, input().split())\nD = A - B\n\nH = [int(input()) for _ in range(N)]\n\ndef f(n):\n needed_attacks = 0\n for h in H:\n r = h - B * n\n if r < 0:\n r = 0\n\n if r % D == 0:\n needed_attacks += r // D\n else:\n needed_attacks += r // D + 1\n\n return needed_attacks <= n\n\ns = 0\ne = max(H) // B + 1\n\nwhile e - s > 1:\n m = (s + e) // 2\n if f(m):\n e = m\n else:\n s = m\n\nprint(e)\n']
['Wrong Answer', 'Accepted']
['s161346935', 's339540569']
[8284.0, 7076.0]
[873.0, 887.0]
[488, 467]
p03702
u937529125
2,000
262,144
You are going out for a walk, when you suddenly encounter N monsters. Each monster has a parameter called _health_ , and the health of the i-th monster is h_i at the moment of encounter. A monster will vanish immediately when its health drops to 0 or below. Fortunately, you are a skilled magician, capable of causing explosions that damage monsters. In one explosion, you can damage monsters as follows: * Select an alive monster, and cause an explosion centered at that monster. The health of the monster at the center of the explosion will decrease by A, and the health of each of the other monsters will decrease by B. Here, A and B are predetermined parameters, and A > B holds. At least how many explosions do you need to cause in order to vanish all the monsters?
['a,b,c = map(int, input().split())\nl = [int(input()) for _ in range(a)]\nflag = True\nl = sorted(l)\nmax_T = 10**18\ndef ok(k):\n s = k\n for i in l:\n hp = i - c * k\n if hp > 0:\n s -= -(-hp // (b - c))\n if s < 0:\n return False\n return True\ndef binary_search(l,r):\n mid = (l + r) // 2\n if l == r:\n return l\n elif ok(mid):\n return bbb(l,mid)\n else:\n if mid == l:\n mid += 1\n \n return bbb(mid,r)\nbinary_search(0,max_T)', 'a,b,c = map(int, input().split())\nl = [int(input()) for _ in range(a)]\nflag = True\nl = sorted(l)\nmax_T = l[-1]//c + 1\ndef ok(k):\n s = k\n for i in l:\n hp = i - c * k\n if hp > 0:\n s -= -(-hp // (b - c))\n if s < 0:\n return False\n return True\ndef bbb(l,r):\n mid = (l + r) // 2\n if l == r:\n return l\n elif ok(mid):\n return bbb(l,mid)\n else:\n if mid == l:\n mid += 1\n \n return bbb(mid,r)\nbbb(0,max_T)', 'a,b,c = map(int, input().split())\nl = [int(input()) for _ in range(a)]\nflag = True\nl = sorted(l)\nmax_T = 10**18\ndef ok(k):\n s = k\n for i in l:\n hp = i - c * k\n if hp > 0:\n s -= -(-hp // (b - c))\n if s < 0:\n return False\n return True\ndef binary_search(l,r):\n mid = (l + r) // 2\n if l == r:\n return l\n elif ok(mid):\n return bbb(l,mid)\n else:\n if mid == l:\n mid += 1\n \n return bbb(mid,r)\nans =binary_search(0,max_T)\nprint(ans) ', 'a,b,c = map(int, input().split())\nl = [int(input()) for _ in range(a)]\nflag = True\nl = sorted(l)\nmax_T = 10**18\ndef ok(k):\n s = k\n for i in l:\n hp = i - c * k\n if hp > 0:\n s -= -(-hp // (b - c))\n if s < 0:\n return False\n return True\ndef binary_search(l,r):\n mid = (l + r) // 2\n if l == r:\n return l\n elif ok(mid):\n return binary_search(l,mid)\n else:\n if mid == l:\n mid += 1\n \n return binary_search(mid,r)\nans = binary_search(0,max_T)\nprint(ans) ']
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s250181604', 's415977464', 's665414353', 's199045459']
[8280.0, 8280.0, 8280.0, 8280.0]
[228.0, 864.0, 224.0, 1387.0]
[521, 507, 538, 559]
p03703
u284854859
2,000
262,144
You are given an integer sequence of length N, a = {a_1, a_2, …, a_N}, and an integer K. a has N(N+1)/2 non-empty contiguous subsequences, {a_l, a_{l+1}, …, a_r} (1 ≤ l ≤ r ≤ N). Among them, how many have an arithmetic mean that is greater than or equal to K?
['import sys,bisect,math\ninput = sys.stdin.readline\n\n\ndef bitsum(bit,i):\n s = 0\n while i > 0:\n s += bit[i]\n i -= i&(-i)\n return s\n \n\ndef bitadd(bit,i,x):\n while i <= n:\n bit[i] += x\n i += i&(-i)\n return bit\n\nn,k = map(int,input().split())\na = [int(input()) for i in range(n)]\n\n#b[j+1]-b[i]:a[i]~a[j]\nb = [0]\nfor i in range(n):\n b.append(b[-1]+a[i])\n\n#c[i]:b[i]-k*i\nc = [0]*(n+1)\nfor i in range(n+1):\n c[i] = b[i]-k*i\n\nd = sorted(c)\nfor i in range(n+1):\n k = bisect.bisect_left(d,c[i])\n d[k] = d[k]\n c[i] = k+1\nprint(c)\nn_ = int(math.log2(n+1)) + 1\nbit = [0] * (2**n_+1)\nass = 0\nfor j in range(n+1):\n ass += j-bitsum(bit,c[j])\n \n bit = bitadd(bit,c[j],1)\nprint(n*(n+1)//2-ass)', 'import sys,bisect,math\ninput = sys.stdin.readline\n\n\ndef bitsum(bit,i):\n s = 0\n while i > 0:\n s += bit[i]\n i -= i&(-i)\n return s\n \n\ndef bitadd(bit,i,x):\n while i <= n:\n bit[i] += x\n i += i&(-i)\n return bit\n\nn,k = map(int,input().split())\na = [int(input()) for i in range(n)]\n\n#b[j+1]-b[i]:a[i]~a[j]\nb = [0]\nfor i in range(n):\n b.append(b[-1]+a[i])\n\n#c[i]:b[i]-k*i\nc = [0]*(n+1)\nfor i in range(n+1):\n c[i] = b[i]-k*i\n\nd = sorted(c)\nfor i in range(n+1):\n k = bisect.bisect_left(d,c[i])\n d[k] = d[k]-0.1\n c[i] = k+1\n\nn = n+1\nn_ = int(math.log2(n)) + 1\nbit = [0] * (2**n_+1)\nass = 0\nfor j in range(n):\n ass += j-bitsum(bit,c[j])\n \n bit = bitadd(bit,c[j],1)\n\n\nprint(n*(n-1)//2-ass)']
['Wrong Answer', 'Accepted']
['s611280368', 's621597412']
[43448.0, 36940.0]
[1302.0, 1397.0]
[943, 945]
p03703
u327466606
2,000
262,144
You are given an integer sequence of length N, a = {a_1, a_2, …, a_N}, and an integer K. a has N(N+1)/2 non-empty contiguous subsequences, {a_l, a_{l+1}, …, a_r} (1 ≤ l ≤ r ≤ N). Among them, how many have an arithmetic mean that is greater than or equal to K?
['class BinaryIndexedTree:\n def __init__(self, size):\n self.data = [0] * (size+1)\n self.size = size\n \n def add(self, i, w):\n while i <= self.size:\n self.data[i] += w\n i += i & -i\n\n def sum(self, i):\n result = 0\n while i > 0:\n result += self.data[i]\n i -= i & -i\n return result\n\nfrom itertools import accumulate,repeat\n\nN,K = map(int, input().split())\n\nB = [0] + [sa-sk for sa,sk in zip(accumulate(int(input())), accumulate(repeat(K, N)))]\n\nlookup = dict(((b,i+1) for i,b in enumerate(sorted(B))))\n\nresult = 0\nbit = BinaryIndexedTree(N+1)\n\nfor b in B:\n c = lookup[b]\n result += bit.sum(c)\n bit.add(c,1)\n\nprint(result)', 'class BinaryIndexedTree:\n def __init__(self, size):\n self.data = [0] * (size+1)\n self.size = size\n \n def add(self, i, w):\n while i <= self.size:\n self.data[i] += w\n i += i & -i\n\n def sum(self, i):\n result = 0\n while i > 0:\n result += self.data[i]\n i -= i & -i\n return result\n\nfrom itertools import accumulate,repeat\n\nN,K = map(int, input().split())\n\nB = [0] + [sa-sk for sa,sk in zip(accumulate(int(input()) for _ in range(N)), accumulate(repeat(K)))]\n\nlookup = dict(((b,i+1) for i,b in enumerate(sorted(B))))\n\nresult = 0\nbit = BinaryIndexedTree(N+1)\n\nfor b in B:\n c = lookup[b]\n result += bit.sum(c)\n bit.add(c,1)\n\nprint(result)']
['Runtime Error', 'Accepted']
['s189276916', 's258389685']
[3064.0, 39576.0]
[18.0, 1530.0]
[659, 674]
p03703
u332385682
2,000
262,144
You are given an integer sequence of length N, a = {a_1, a_2, …, a_N}, and an integer K. a has N(N+1)/2 non-empty contiguous subsequences, {a_l, a_{l+1}, …, a_r} (1 ≤ l ≤ r ≤ N). Among them, how many have an arithmetic mean that is greater than or equal to K?
["import sys\nfrom itertools import accumulate\n\ninf = 1<<60\nans = 0\n\ndef solve():\n n, k = map(int, sys.stdin.readline().split())\n a = [int(sys.stdin.readline().rstrip()) - k for i in range(n)]\n s = [0] + list(accumulate(a))\n\n print(ans)\n\ndef MergeSort(a):\n if len(a) == 1:\n return a\n\n apre = MergeSort(a[:len(a)//2])\n asuf = MergeSort(a[len(a)//2:])\n\n res = merge(apre, asuf)\n\n return res\n\ndef merge(a, b):\n global ans\n na = len(a)\n nb = len(b)\n\n a.append(-inf)\n b.append(-inf)\n\n la = 0\n lb = 0\n\n res = []\n\n for i in range(na + nb):\n if a[la] <= b[lb]:\n ans += na - la\n res.append(b[lb])\n lb += 1\n else:\n res.append(a[la])\n la += 1\n\n return res\n\nif __name__ == '__main__':\n solve()", "import sys\nfrom itertools import accumulate\n\ninf = 1<<60\nans = 0\n\ndef solve():\n n, k = map(int, sys.stdin.readline().split())\n a = [int(sys.stdin.readline().rstrip()) - k for i in range(n)]\n s = [0] + list(accumulate(a))\n\n MergeSort(s)\n\n print(ans)\n\ndef MergeSort(a):\n if len(a) == 1:\n return a\n\n apre = MergeSort(a[:len(a)//2])\n asuf = MergeSort(a[len(a)//2:])\n\n res = merge(apre, asuf)\n\n return res\n\ndef merge(a, b):\n global ans\n na = len(a)\n nb = len(b)\n\n a.append(-inf)\n b.append(-inf)\n\n la = 0\n lb = 0\n\n res = []\n\n for i in range(na + nb):\n if a[la] <= b[lb]:\n ans += na - la\n res.append(b[lb])\n lb += 1\n else:\n res.append(a[la])\n la += 1\n\n return res\n\nif __name__ == '__main__':\n solve()"]
['Wrong Answer', 'Accepted']
['s045727812', 's333516064']
[21936.0, 24548.0]
[150.0, 1201.0]
[814, 832]
p03703
u375616706
2,000
262,144
You are given an integer sequence of length N, a = {a_1, a_2, …, a_N}, and an integer K. a has N(N+1)/2 non-empty contiguous subsequences, {a_l, a_{l+1}, …, a_r} (1 ≤ l ≤ r ≤ N). Among them, how many have an arithmetic mean that is greater than or equal to K?
['import bisect\nfrom itertools import accumulate\n# python template for atcoder1\nimport sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\n\ndef brute():\n N, K = map(int, input().split())\n L = [int(input()) for _ in range(N)]\n ans = 0\n for i in range(N):\n for j in range(i, N):\n if sum(L[i:j+1])/(j+1-i) >= K:\n ans += 1\n\n print(ans)\n\n\ndef solve():\n N, K = map(int, input().split())\n L = [int(input()) for _ in range(N)]\n\n L_acc = [0]+list(accumulate(L))\n for i in range(N+1):\n L_acc[i] -= (i)*K\n\n L_sort = list(sorted(set(L_acc)))\n L_comp = [-1]*(N+1)\n for i in range(N+1):\n key = L_acc[i]\n ind = bisect.bisect_left(L_sort, key)\n L_comp[i] = ind\n # BIT\n bit = [0]*(N+1)\n\n def sum_bit(i):\n s = 0\n while i > 0:\n s += bit[i]\n i -= i & (-i)\n return s\n\n def add(i, x):\n while i <= N:\n bit[i] += x\n i += i & (-i)\n\n ans = 0\n for i, l in enumerate(L_comp):\n if l == 0:\n ans += N-i\n continue\n ans += sum_bit(l)\n add(l, 1)\n print(ans)\n\n\nsolve()\n\n\n ans = 0\n for i, l in enumerate(L_comp):\n if l == 0:\n ans += N-i\n continue\n ans += sum_bit(l)\n add(l, 1)\n print(ans)\n\n\nsolve()\n', 'from itertools import accumulate\n# python template for atcoder1\nimport sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\n\ndef brute():\n N, K = map(int, input().split())\n L = [int(input()) for _ in range(N)]\n ans = 0\n for i in range(N):\n for j in range(i, N):\n if sum(L[i:j+1])/(j+1-i) >= K:\n ans += 1\n\n print(ans)\n\n\ndef solve():\n N, K = map(int, input().split())\n L = [int(input()) for _ in range(N)]\n L = list(map(lambda x: x-K, L))\n\n L_acc = [0]+list(accumulate(L))\n ans = 0\n for i in range(N):\n for j in range(i, N):\n if L_acc[j+1]-L_acc[i] >= 0:\n ans += 1\n print(L_acc)\n\n\nsolve()\n', 'import bisect\nfrom itertools import accumulate\n# python template for atcoder1\nimport sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\n\ndef solve():\n N, K = map(int, input().split())\n L = [int(input()) for _ in range(N)]\n\n L_acc = [0]+list(accumulate(L))\n for i in range(N+1):\n L_acc[i] -= (i)*K\n\n L_sort = list(sorted(set(L_acc)))\n L_comp = [-1]*(N+1)\n for i in range(N+1):\n key = L_acc[i]\n ind = bisect.bisect_left(L_sort, key)\n L_comp[i] = ind\n # BIT\n bit = [0]*(N+1)\n\n def sum_bit(i):\n s = 0\n while i > 0:\n s += bit[i]\n i -= i & (-i)\n return s\n\n def add(i, x):\n while i <= N:\n bit[i] += x\n i += i & (-i)\n\n ans = 0\n for i, l in enumerate(L_comp):\n if l == 0:\n ans += N-i\n continue\n ans += sum_bit(l)\n add(l, 1)\n print(ans)\n\n\nsolve()\n']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s175756958', 's237641396', 's737364180']
[3064.0, 23792.0, 33444.0]
[17.0, 2105.0, 1127.0]
[1355, 697, 932]
p03703
u839537730
2,000
262,144
You are given an integer sequence of length N, a = {a_1, a_2, …, a_N}, and an integer K. a has N(N+1)/2 non-empty contiguous subsequences, {a_l, a_{l+1}, …, a_r} (1 ≤ l ≤ r ≤ N). Among them, how many have an arithmetic mean that is greater than or equal to K?
['N, K = map(int, input().split())\na = []\nfor _ in range(N):\n a.append(int(input())-K)\n \nsu = 0\nv = [(0, 0)]\nfor i in range(N):\n su += a[i]\n v.append((su, i+1))\nv = sorted(v)\n\ndata = [0]*(N+1)\n\ndef sumation(i):\n s = 0\n while i > 0:\n s += data[i]\n i -= i & -i\n return s\n \ndef add(i, x):\n while i <= N:\n data[i] += x\n i += i & -i\nans = 0\nfor e, i in v:\n ans += sumation(i+1)\n add(i+1, 1)\n \nprint(ans)', 'N, K = map(int, input().split())\na = []\nfor _ in range(N):\n a.append(int(input())-K)\n \nsu = 0\nv = [(0, 0)]\nfor i in range(N):\n su += a[i]\n v.append((su, i+1))\nv = sorted(v)\n\ndata = [0]*(N+2)\n\ndef sumation(i):\n s = 0\n while i > 0:\n s += data[i]\n i -= i & -i\n return s\n \ndef add(i, x):\n while i <= N+1:\n data[i] += x\n i += i & -i\nans = 0\nfor e, i in v:\n ans += sumation(i+1)\n add(i+1, 1)\n \nprint(ans)']
['Runtime Error', 'Accepted']
['s404948532', 's965348479']
[41676.0, 41676.0]
[1321.0, 1478.0]
[460, 462]
p03704
u053547321
2,000
262,144
For a positive integer n, we denote the integer obtained by reversing the decimal notation of n (without leading zeroes) by rev(n). For example, rev(123) = 321 and rev(4000) = 4. You are given a positive integer D. How many positive integers N satisfy rev(N) = N + D?
['def recursion(length, ll, string, cc):\n if ll * 2 < length:\n for i in range(10):\n string1 = string + str(i)\n recursion(length, ll+1, string1, cc)\n else:\n number = str(int(string) + int(cc[-ll:]))\n ds = ""\n for i in range(length // 2):\n if i + 1 <= len(number):\n ds += number[-i-1]\n else:\n ds += "0"\n string = ds + string\n if str(int(string) + int(cc)) == string[::-1] and string[0] != "0":\n global answer\n answer += 1\n elif str(int(string) + int(cc)) == string[::-1]:\n global az\n az += 1\n \n\nd = input()\nd1 = d\nplus = 0\nwhile True:\n if d[-1] == "0":\n d = d[:-1]\n plus += 1\n else:\n break\nanswer = 0\naz = 0\nrecursion(len(d), 0, "", d)\nrecursion(len(d)+1, 0, "", d)\nyes = False\nwhile plus > 0:\n yes = True\n if plus == 1:\n plus -= 1\n answer = answer * 9\n az = az * 9\n else:\n plus -= 1\n answer *= 10\n az *= 9\nif yes:\n answer += az\n ', 'def result(letters, number, cant_zero):\n if letters <= 1:\n if number == 0:\n return 10 ** letters\n return 0\n diff = (10 - number%10) % 10\n variants = number % 10 - cant_zero\n if number % 10 == 0:\n variants = 10 - cant_zero\n number -= diff * (10**(letters-1) - 1)\n number = abs(number // 10)\n return variants * result(letters-2, number, 0)\n\nd = int(input())\nans = 0\nfor i in range(20):\n ans += result(i, d, 1)\nprint(ans)']
['Wrong Answer', 'Accepted']
['s350319511', 's449197040']
[3064.0, 3064.0]
[894.0, 18.0]
[1094, 474]
p03704
u327466606
2,000
262,144
For a positive integer n, we denote the integer obtained by reversing the decimal notation of n (without leading zeroes) by rev(n). For example, rev(123) = 321 and rev(4000) = 4. You are given a positive integer D. How many positive integers N satisfy rev(N) = N + D?
['# (10-x) ways: (0,x)-(9-x,9) -> (x, -x)\n# (x) ways: (10-x,0)-(9,x-1) -> (x-10, 10 - x)\n\ndef solve(d, k, outer):\n if k <= 1:\n return (10 - outer)**k if d == 0 else 0\n\n tail = d % 10\n if d >= 10**k:\n return 0\n c = d+tail*10**(k-1)\n return (10-tail-outer)*solve(abs(c//10), k-2, 0) + (tail-outer)*solve(abs((c-10**k)//10 + 1), k-2, 0)\n\nD = int(input())\nresult = 0\nfor k in range(1,20):\n result += solve(D, k, 1)\n print(k,result)\n\nprint(result)', 'def solve(d, K):\n r = 1\n for k in range(K,1,-2):\n if d >= 10**k:\n return 0\n t = (-d)%10\n d = abs((d-t*(10**(k-1)-1))//10)\n r *= 10-t-(K==k)\n return r*(10**(K%2)) if d == 0 else 0\n\nD = int(input())\nresult = 0\nl = len(str(D))\nfor k in range(l,2*l+1):\n result += solve(D, k)\n\nprint(result)']
['Wrong Answer', 'Accepted']
['s989481276', 's437989633']
[3064.0, 3064.0]
[17.0, 18.0]
[456, 307]
p03704
u368780724
2,000
262,144
For a positive integer n, we denote the integer obtained by reversing the decimal notation of n (without leading zeroes) by rev(n). For example, rev(123) = 321 and rev(4000) = 4. You are given a positive integer D. How many positive integers N satisfy rev(N) = N + D?
['D = int(input())\n\ndef table(i, k):\n if i == k:\n return list(range(9, -1, -1)) + [0]*9\n else:\n return list(range(10, 0, -1)) + list(range(1, 10))\n\ndef nine(i):\n return 10**i - 1\n\ndef rec(d, i, k):\n res = 0\n num = table(i, k)\n if i == 1:\n for j in range(-9, 10):\n if 9*j == d:\n return num[j]\n return 0\n if i == 2:\n for j in range(-9, 10):\n if d == 99*j:\n return 10*num[j]\n if not -10*nine(i) <= d <= 10*nine(i):\n return 0\n for j in range(-9, 10):\n if d%10 == j*nine(i)%10:\n res += num[j] * rec((d-j*nine(i))//10, i-2, k)\n return res\n\nl = 0\nwhile D % 10 == 0:\n D//= 10\n l += 1\n\nif l == 0:\n a = 1\nelse:\n a = 9*10**(l-1)\n\nans = 0\nfor i in range(1, 17):\n if not l:\n ans += rec(D, i, i)\n else:\n ans += rec(D, i, 100)\nif ans % 9 != 0:\n ans = 0\nprint(a * ans)', 'D = int(input())\n\ndef table(i, k):\n if i == k:\n return list(range(9, -1, -1)) + [0]*9\n else:\n return list(range(10, 0, -1)) + list(range(1, 10))\n\ndef nine(i):\n return 10**i - 1\n\ndef rec(d, i, k):\n res = 0\n num = table(i, k)\n if i == 1:\n for j in range(-9, 10):\n if 9*j == d:\n return num[j]\n return 0\n if i == 2:\n for j in range(-9, 10):\n if d == 99*j:\n return 10*num[j]\n if not -10*nine(i) <= d <= 10*nine(i):\n return 0\n for j in range(-9, 10):\n if d%10 == j*nine(i)%10:\n res += num[j] * rec((d-j*nine(i))//10, i-2, k)\n return res\n\nl = 0\nwhile D % 10 == 0:\n D//= 10\n l += 1\n\nif l == 0:\n a = 1\nelse:\n a = 9*10**(l-1)\n\nans = 0\nfor i in range(1, 20):\n if not l:\n ans += rec(D, i, i)\n else:\n ans += rec(D, i, 100)\nprint(a * ans)\n']
['Wrong Answer', 'Accepted']
['s876963237', 's805233100']
[3064.0, 3064.0]
[19.0, 19.0]
[928, 900]
p03705
u002459665
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['N, A, B = list(map(int, input().split()))\n\nif A == B:\n ans = 1\nelif A > B:\n ans = 0\nelse:\n ans = 0\n\nprint(ans)', 'N, A, B = list(map(int, input().split()))\n\nif A > B:\n ans = 0\nelif A == B:\n ans = 1\nelif N == 1:\n ans = 0\nelse:\n mn = A + B + A * (N-2)\n mx = A + B + B * (N-2)\n ans = mx - mn + 1\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s435590917', 's880890839']
[2940.0, 3060.0]
[17.0, 19.0]
[119, 208]
p03705
u017810624
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['n,a,b=map(int,input().split())\nif a>b:print(0)\nelif n==1 and a!=b:print(0)\nelse:print((n-2)*(b-a)+1)\u200b', 'n,a,b=map(int,input().split())\nif a>b or (n==1 and a!=b):print(0)\nelse:print((n-2)*(b-a)+1)']
['Runtime Error', 'Accepted']
['s120822040', 's134570689']
[2940.0, 2940.0]
[17.0, 17.0]
[103, 91]
p03705
u018679195
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['a,b,c = map(int,input().split())\nif a<=1:\n if b==c:\n print(1)\n else:\n print(0)\nelif c>=b:\n print(0)\nelse:\n min = (a-1)*b+c\n max = (a-1)*c+b\n print(max-min+1)', "nums = input()\nnums = nums.split(' ')\nn = int(nums[0])\na = int(nums[1])\nb = int(nums[2])\nif n == 1:\n if a == b:\n print(1)\n else:\n print(0)\n exit(0)\nif a > b:\n print(0)\n exit(0)\nnum = b*(n-2) - a*(n-2) + 1\nprint(num)"]
['Wrong Answer', 'Accepted']
['s610269663', 's362942332']
[3060.0, 3064.0]
[19.0, 17.0]
[189, 244]
p03705
u024340351
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['N, A, B = map(int, input().split())\n\nif B< A:\n\tprint(0)\nelif B = A:\n\tprint(1)\nelif B-A+1 > N:\n\tprint(0)\nelse:\n\tprint((N-2)*B-(N-2)*A+1)', 'N, A, B = map(int, input().split())\n\nif A == B :\n\tprint(1)\n\texit()\n\nprint(max(B*(N-1)+A-(A*(N-1)+B)+1,0))']
['Runtime Error', 'Accepted']
['s288661291', 's081515787']
[2940.0, 2940.0]
[17.0, 17.0]
[135, 105]
p03705
u026788530
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['n,a,b=[int(_) for_ in input().split()]\nif n==1:\n if a==b:\n print(1)\n else:\n print(0)\nprint(max(0,(n-2)*(b-a)+1)', 'n,a,b=[int(_) for _ in input().split()]\nif n==1:\n if a==b:\n print(1)\n else:\n print(0)\n exit()\nprint(max(0,(n-2)*(b-a)+1))\n']
['Runtime Error', 'Accepted']
['s357713762', 's626915715']
[2940.0, 2940.0]
[17.0, 17.0]
[119, 131]
p03705
u030820165
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['n, a, b = map(int, input().split())\nif (n == 1 and a == b):\n ans = 1\nelif (n == 1):\n ans = 0\nelif A > B:\n ans = 0\nelse:\n ans = (b - a) * (n - 2) + 1\nprint(ans)', 'n, a, b = map(int, input().split())\nif (n == 1 and a == b):\n ans = 1\nelif (n == 1):\n ans = 0\nelif a > b:\n ans = 0\nelse:\n ans = (b - a) * (n - 2) + 1\nprint(ans)']
['Runtime Error', 'Accepted']
['s063802482', 's459685988']
[9104.0, 9120.0]
[31.0, 29.0]
[163, 163]
p03705
u042802884
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['N,A,B=map(int,input().split())\nprint((B-A)*N+1)', 'N,A,B=map(int,input().split())\nif N==1:\n if A==B:\n ans=1\n else:\n ans=0\nelif:\n if A>B:\n ans=0\n else:\n ans=(B-A)*(N-2)+1\nprint(ans)', 'N,A,B=map(int,input().split())\nif N==1:\n if A==B:\n ans=1\n else:\n ans=0\nelse:\n if A>B:\n ans=0\n else:\n ans=(B-A)*(N-2)+1\nprint(ans)']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s743427467', 's904780802', 's393400808']
[3064.0, 2940.0, 2940.0]
[18.0, 17.0, 18.0]
[47, 169, 169]
p03705
u056358163
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['N, A, B = map(int, input().split())\n\nif A > B:\n print(0)\nelif N == 1:\n if A == B:\n print(1)\n else:\n print(0)\nelse:\n ans = (B * (N - 1) + A) - (A * (N - 1) + B)\n print(ans)', 'N, A, B = map(int, input().split())\n\nif A > B:\n print(0)\nelif N == 1:\n if A == B:\n print(1)\n else:\n print(0)\nelse:\n ans = (B * (N - 1) + A) - (A * (N - 1) + B) + 1\n print(ans)']
['Wrong Answer', 'Accepted']
['s997974472', 's290624944']
[3060.0, 3060.0]
[18.0, 18.0]
[200, 204]
p03705
u062864034
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['import combinations from itertools\nn = [int(i) for i in input().split()]\nif n[0] == 1 and n[1] < n[2]:\n print(0)\nelif n[1]>n[2]:\n print(0)\nelif n[0] == 1 and n[1]==n[2]:\n print(1)\nelse:\n m = range(n[1],n[2]+1)\n c = list(combinations(m,n[0]-2))\n c.extend([(i,i) for i in m])\n print(len(set([i+j for i,j in c])))', 'n = [int(i) for i in input().split()]\nif n[0] == 1 and n[1] < n[2]:\n print(0)\nelif n[1]>n[2]:\n print(0)\nelif n[0] == 1 and n[1]==n[2]:\n print(1)\nelse:\n mi = n[1]*(n[0]-1)+n[2]\n ma = n[2]*(n[0]-1)+n[1]\n print(ma-mi+1)']
['Runtime Error', 'Accepted']
['s820669026', 's908347236']
[2940.0, 3064.0]
[17.0, 17.0]
[331, 234]
p03705
u063052907
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['N, A, B = map(int, input().split())\n\nif A > B:\n ans = 0\nelif N==1:\n ans = 1 if A==B else 0\nelse:\n sum_min = (N-1) * A\n sum_max = (N-1) * B\n ans = sum_max - sum_min + 1\n\nprint(ans)', 'N, A, B = map(int, input().split())\n\nif A > B:\n ans = 0\nelif N==1:\n ans = 1 if A==B else 0\nelse:\n sum_min = (N-2) * A\n sum_max = (N-2) * B\n ans = sum_max - sum_min + 1\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s495080193', 's431422883']
[3060.0, 3060.0]
[17.0, 17.0]
[194, 194]
p03705
u064408584
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['n,a,b=map(int, input().split())\nans=(n-2)*(b-a)*2\nif n==1:\n if a!=b:\n ans=0\n else:\n ans=1\nif b<a:ans=0\nprint(ans)', 'n,a,b=map(int, input().split())\nans=(n-2)*(b-a)*2+1\nif n==1:\n if a!=b:\n ans=0\n else:\n ans=1\nif b<a:ans=0\nprint(ans)', 'n,a,b=map(int, input().split())\nans=(n-2)*(b-a)+1\nif n==1:\n if a!=b:\n ans=0\n else:\n ans=1\nif b<a:ans=0\nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s506650377', 's567131835', 's411183966']
[2940.0, 2940.0, 2940.0]
[17.0, 25.0, 17.0]
[133, 135, 133]
p03705
u075304271
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['import numpy as np\nimport math\nimport scipy\nimport itertools\n\ndef solve():\n n, a, b = map(int, input().split())\n print(max(b*(n-1)-a*(n-1)+1, 0))\n return 0\n\nif __name__ == "__main__":\n solve()\n\n', 'import numpy as np\nimport math\nimport scipy\nimport itertools\n\ndef solve():\n n, a, b = map(int, input().split())\n if a > b:\n print(0)\n elif n == 1:\n if a == b:\n print(1)\n else:\n print(0)\n else:\n print(b*(n-1)+a-a*(n-1)+b+1)\n return 0\n\nif __name__ == "__main__":\n solve()\n\n', 'import numpy as np\nimport math\nimport scipy\nimport itertools\n\ndef solve():\n n, a, b = map(int, input().split())\n if a > b:\n print(0)\n elif n == 1:\n if a == b:\n print(1)\n else:\n print(0)\n else:\n print((b*(n-1)+a)-(a*(n-1)+b)+1)\n return 0\n\nif __name__ == "__main__":\n solve()\n\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s121042947', 's403063245', 's550453692']
[12504.0, 13004.0, 13132.0]
[160.0, 171.0, 170.0]
[206, 339, 343]
p03705
u135116520
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['N,A,B=map(int,input().split())\nif A>B:\n print(0)\nif B-A>=1 and N==1:\n print(0)\nelse:\n print((B-A)**N+1)', 'N,A,B=map(int,input().split())\nif A<B:\n print(0)\nif N==1 and A!=B:\n print(0)\nelse:\n print((N-2)*(B-A)+1)', 'N,A,B=map(int,input().split())\nif A>B:\n print(0)\nelif N==1 and A!=B:\n print(0)\nelse:\n print((N-2)*(B-A)+1)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s001090747', 's124668179', 's000514521']
[9888.0, 2940.0, 2940.0]
[2104.0, 18.0, 17.0]
[106, 107, 109]
p03705
u136090046
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['n, a, b = map(int, input().split())\ntmp = abs(b-a)+1\nif b < a or (n == 1 and b-a > 1):\n print(0)\nelse:\n if n == 1:\n print(1)\n else:\n print(tmp**(n-2) - tmp**2)', 'n, a, b = map(int, input().split())\n\nif a > b or (n == 1 and a != b):\n print(0)\nelse:\n print(((n-2)*(b-a))+1)']
['Wrong Answer', 'Accepted']
['s686499323', 's062063704']
[10688.0, 2940.0]
[2104.0, 17.0]
[182, 115]
p03705
u189487046
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['N, A, B = map(int, input().split())\n\nif A > B:\n print(0)\nelif N == 1 and A != B:\n print(0)\nelif N == 1 and A == B:\n print(1)\nelif N == 2 and A != B:\n print(1)\nprint(1000)\n', 'N, A, B = map(int, input().split())\n\nif A > B:\n print(0)\nelif N == 1 and A != B:\n print(0)\nelif N == 1 and A == B:\n print(1)\nelif N == 2 and A != B:\n print(1)\nelse:\n print(1000)\n', 'N, A, B = map(int, input().split())\n\nif A > B:\n print(0)\nelif N == 1 and A != B:\n print(0)\nelif N == 1 and A == B:\n print(1)\nelif N == 2 and A != B:\n print(1)\nelse:\n min_tmp = A*(N-1) + B\n max_tmp = B*(N-1) + A\n print(max_tmp-min_tmp+1)\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s228171922', 's863980232', 's165624101']
[2940.0, 2940.0, 3060.0]
[17.0, 17.0, 17.0]
[183, 193, 258]
p03705
u223646582
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['N, A, B = map(int, input().split())\nprint(max(0, B*(N-1)+A-(A*(N-1)+B)))\n', 'N, A, B = map(int, input().split())\nprint(max(0, B*(N-1)+A-(A*(N-1)+B)+1))\n']
['Wrong Answer', 'Accepted']
['s390796343', 's934959114']
[2940.0, 2940.0]
[18.0, 17.0]
[73, 75]
p03705
u227082700
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['n,a,b=map(int,input().split());n-=2\nif a>b:print(0)\nelse:print((b-a)*n)', 'n,a,b=map(int,input().split())\nif (n==1 and a!=b) or a>b:exit(print(0))\nmi=b+(n-1)*a\nma=a+(n-1)*b\nprint(ma-mi+1)\n']
['Wrong Answer', 'Accepted']
['s280549236', 's944175996']
[2940.0, 2940.0]
[17.0, 17.0]
[71, 113]
p03705
u227476288
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['print(0)\n', 'N,A,B = map(int,input().split())\n\nn = B-A\nif A > B or n > N:\n print(0)\nelse:\n print(A+B*(N-1)-(A*(N-1)+B)+1)\n']
['Wrong Answer', 'Accepted']
['s885794120', 's088733283']
[2940.0, 2940.0]
[17.0, 17.0]
[9, 115]
p03705
u228232845
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
["import sys\n\n\ndef input(): return sys.stdin.readline().strip()\ndef I(): return int(input())\ndef LI(): return list(map(int, input().split()))\ndef IR(n): return [I() for i in range(n)]\ndef LIR(n): return [LI() for i in range(n)]\ndef SR(n): return [S() for i in range(n)]\ndef S(): return input()\ndef LS(): return input().split()\n\n\nINF = float('inf')\n\n\nn, a, b = LI()\n\nmin_s = a * (n - 1) + b\nmax_s = a + (n - 1) * b\nprint(f'{min_s=}, {max_s=}')\nans = max_s - min_s + 1\nif ans < 0:\n ans = 0\nprint(ans)\n", "# ~10m AC\nimport sys\n\n\ndef input(): return sys.stdin.readline().strip()\ndef I(): return int(input())\ndef LI(): return list(map(int, input().split()))\ndef IR(n): return [I() for i in range(n)]\ndef LIR(n): return [LI() for i in range(n)]\ndef SR(n): return [S() for i in range(n)]\ndef S(): return input()\ndef LS(): return input().split()\n\n\nINF = float('inf')\n\n\nn, a, b = LI()\n\nmin_s = a * (n - 1) + b\nmax_s = a + (n - 1) * b\nans = max_s - min_s + 1\nif ans < 0:\n ans = 0\nprint(ans)\n"]
['Wrong Answer', 'Accepted']
['s880062855', 's551855884']
[9204.0, 9148.0]
[27.0, 24.0]
[500, 481]
p03705
u247554097
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['\n\nn, a, b = map(int, input().split())\nif n == 1 or b < a:\n print(0)\nelif n == 2 and a <= b:\n print(1)\nelse:\n minn = (n - 2) * a\n maxn = (n - 2) * b\n print(minn, maxn)\n print(maxn - minn + 1)\n', '\n\n\n\nn, a, b = map(int, input().split())\nif a == b and n == 1:\n print(1)\nelif b < a or n == 1:\n print(0)\nelif n == 2 and a <= b:\n print(1)\nelse:\n minn = (n - 2) * a\n maxn = (n - 2) * b\n print(maxn - minn + 1)\n']
['Wrong Answer', 'Accepted']
['s278537233', 's755651137']
[2940.0, 2940.0]
[18.0, 17.0]
[364, 459]
p03705
u254871849
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
["# 2019-11-22 16:25:33(JST)\nimport sys\n\n\ndef main():\n n, a, b = [int(x) for x in sys.stdin.readline().split()]\n\n\n if b > a:\n ans = 0\n elif a == b:\n ans = 1\n elif a > b:\n if n == 1:\n ans = 0\n else:\n min_possible = a * (n - 1) + b\n max_possible = b * (n - 1) + a\n ans = max_possible - min_possible + 1\n \n print(ans)\n\nif __name__ == '__main__':\n main()\n", "# 2019-11-22 16:25:33(JST)\nimport sys\n\n\ndef main():\n n, a, b = [int(x) for x in sys.stdin.readline().split()]\n\n\n if a > b:\n ans = 0\n elif a == b:\n ans = 1\n elif b < a:\n if n == 1:\n ans = 0\n else:\n min_possible = a * (n - 1) + b\n max_possible = b * (n - 1) + a\n ans = max_possible - min_possible + 1\n \n print(ans)\n\nif __name__ == '__main__':\n main()\n", "# 2019-11-22 16:25:33(JST)\nimport sys\n\n\ndef main():\n n, a, b = [int(x) for x in sys.stdin.readline().split()]\n\n\n if a > b:\n ans = 0\n elif a == b:\n ans = 1\n elif b > a:\n if n == 1:\n ans = 0\n else:\n min_possible = a * (n - 1) + b\n max_possible = b * (n - 1) + a\n ans = max_possible - min_possible + 1\n \n print(ans)\n\nif __name__ == '__main__':\n main()\n"]
['Wrong Answer', 'Runtime Error', 'Accepted']
['s650878537', 's726069169', 's531357243']
[3060.0, 3060.0, 3060.0]
[17.0, 17.0, 17.0]
[442, 442, 442]
p03705
u263933075
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['n,a,b=map(int,input().split())\nprint(n*b-n*a+1)', 'N=input()\nA=input()\nB=input()\nprint((2-N)(A-B))', 'n, a, b = map(int, input().split())\n\nmin_sum = a * (n - 1) + b\nmax_sum = b * (n - 1) + a\n\nprint(max(max_sum - min_sum + 1, 0))\n']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s063403245', 's846253981', 's157644779']
[2940.0, 2940.0, 2940.0]
[17.0, 17.0, 18.0]
[47, 47, 127]
p03705
u270681687
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['a = int(input())\nb = int(input())\n\nif a == b:\n print(1)\n exit()\n\n\n\ndef bitlen(x):\n return 1 + bitlen(x >> 1) if x else 0\n\nt = a ^ b\nn = bitlen(t)\n\nT = 1 << (n - 1)\n\na = a & (T * 2 - 1)\nb = b & (T * 2 - 1)\n\nsb = b & (T - 1)\nb_max = (2 ** bitlen(sb) - 1) | T\n\nif (T + a) > b_max:\n print((b_max - a + 1) + (2 * T - 1 - (T + a) + 1))\nelse:\n print(2 * T - 1 - a + 1)\n', 'n, a, b = map(int, input().split())\n\nif n == 1:\n if a == b:\n print(1)\n else:\n print(0)\nelse:\n if a < b:\n low = a * (n - 1) + b\n high = a + b * (n - 1)\n print(high - low + 1)\n elif a == b:\n print(1)\n else:\n print(0)']
['Runtime Error', 'Accepted']
['s698291996', 's756658275']
[3064.0, 3060.0]
[18.0, 17.0]
[580, 278]
p03705
u280978334
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['N,A,B = map(int,input().split())\nmaxi = B*N\nmini = A*N\nif A > B:\n print(0)\nelif A == B:\n print(1)\nelse:\n print(maxi - mini)', 'N,A,B = map(int,input().split())\nmaxi = B*(N-1) + A\nmini = A*(N-1) + B\nif A > B:\n print(0)\nelif N == 0:\n print(0)\nelif A == B:\n print(1)\nelif N == 1:\n print(0)\nelse:\n print(maxi - mini + 1)']
['Wrong Answer', 'Accepted']
['s858835457', 's413140740']
[2940.0, 3060.0]
[17.0, 17.0]
[132, 204]
p03705
u288430479
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['s = input()\nl = len(s)\nsu = 0\nfor i in range(1,l-1):\n # print(su)\n if s[i]=="U":\n su += 1*(l-1-i)+2*(i)\n else:\n su += 1*(i)+2*(l-i-1)\nprint(su+2*(l-1))', 'import math \nn,a,b = map(int,input().split())\nif a>b:\n print(0)\n exit()\nif n==1 and a!=b:\n print(0)\n exit()\nif n==2:\n print(1)\n exit()\nq = b*(n-2)-a*(n-2)+1\nprint(q)']
['Wrong Answer', 'Accepted']
['s639562006', 's651888152']
[3060.0, 3060.0]
[18.0, 18.0]
[159, 171]
p03705
u296518383
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['N,A,B=map(int,input().split())\n\nif N==1:\n if A==B:\n print(1)\n else:\n print(0)\nelse:\n if A>B:\n print(0)\n else:\n sum_max=A+B+(N-2)*A\n sum_min=A+B+(N-2)*B\n print(sum_max-sum_min+1)', 'N,A,B=map(int,input().split())\n\nif N==1:\n if A==B:\n print(1)\n else:\n print(0)\nelse:\n if A>B:\n print(0)\n else:\n sum_max=A+B+(N-2)*B\n sum_min=A+B+(N-2)*A\n print(sum_max-sum_min+1)']
['Wrong Answer', 'Accepted']
['s534810746', 's718641623']
[3060.0, 3060.0]
[17.0, 17.0]
[199, 199]
p03705
u297651868
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['n,a,b= list(map(int, input().split()))\nif a>b:\n print("0")\n exit(0)\nelse n==1:\n if a!=b:\n print("0")\n else:\n print("1")\n exit(0)\nn-=2;b-=a;a=0\nif n>=b:\n print(b*n+1)', 'n,a,b= list(map(int, input().split()))\nif a>b:\n print("0")\n exit(0)\nif n==1:\n if a!=b:\n print("0")\n else:\n print("1")\n exit(0)\nn-=2;b-=a;a=0\nprint(b*n+1)']
['Runtime Error', 'Accepted']
['s450418125', 's835216473']
[2940.0, 3060.0]
[17.0, 17.0]
[197, 182]
p03705
u306142032
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['n, a, b = map(int, input().split())\n\nif n == 1:\n if a == b:\n print(1)\n else:\n print(0)\nelse:\n if a > b:\n print(0)\n else:\n print((b-a)(n-2)+1) \n', 'n, a, b = map(int, input().split())\n\nif n == 1:\n if a == b:\n print(1)\n else:\n print(0)\nelse:\n if a > b:\n print(0)\n else:\n print((b-a)*(n-2)+1) \n']
['Runtime Error', 'Accepted']
['s140525313', 's442765611']
[2940.0, 2940.0]
[17.0, 17.0]
[190, 191]
p03705
u306412379
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['N, A, B = map(int, input().split())\n\nif B < A:\n print(0)\nelif N == 1 and A!= B:\n print(0)\nelif N == 1 and A == B:\n print(1)\nelse:\n x = 1\n for i in range(B-A+1):\n x *= B-A+1-i\n print(x)\n ', 'N, A, B = map(int, input().split())\n\nif B < A:\n print(0)\nelif N == 1 and A!= B:\n print(0)\nelif N == 1 and A == B:\n print(1)\nelse:\n print(1 + ( N - 2) * (B - A))']
['Wrong Answer', 'Accepted']
['s125069163', 's083734454']
[9616.0, 9016.0]
[2205.0, 27.0]
[198, 164]
p03705
u324549724
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['n, a, b = map(int, input().split())\nif (a < b) print(0)\nelse print(b*(n-1)+a-a*(n-1)-b+1)\n', 'n, a, b = map(int, input().split())\nif (a < b) : print(0)\nelse : print(b*(n-1)+a-a*(n-1)-b+1)\n', 'n, a, b = map(int, input().split())\nif (a > b) : print(0)\nelif (n == 1) :\n if (a == b) : print(1)\n else : print(0)\nelse : print((b-a)*(n-2)+1)\n']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s032790012', 's938541947', 's190084771']
[2940.0, 2940.0, 2940.0]
[17.0, 17.0, 17.0]
[90, 94, 145]
p03705
u341087021
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef FI(): 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().split())\ndef S(): return input()\n\nn, a, b = LI()\n\nif a>b:\n\tprint(0)\nelif n=1 and a!=b:\n\tprint(0)\nelse:\n\tmi = a*(n-1)+b\n\tma = a+b*(n-1)\n\tprint(ma-mi+1)', 'import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef FI(): 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().split())\ndef S(): return input()\n\nn, a, b = LI()\n\nif a>b:\n\tprint(0)\nelif n==1 and a!=b:\n\tprint(0)\nelse:\n\tmi = a*(n-1)+b\n\tma = a+b*(n-1)\n\tprint(ma-mi+1)']
['Runtime Error', 'Accepted']
['s436411245', 's072941740']
[2940.0, 7232.0]
[18.0, 64.0]
[501, 502]
p03705
u363610900
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['N, A, B = map(int, input().split())\n\ncnt = 0\n\nif A > B:\n print(0)\nelif N == 1:\n if A == B:\n print(1)\n else:\n print(0)\nelse:\n print((B-A)(N-2)+1)', 'N, A, B = map(int, input().split())\n\nif A > B:\n print(0)\nelif N == 1:\n print(0)\n\nelse:\n print((B-A)(N-2)+1)', 'N, A, B = map(int, input().split())\n\nif A > B:\n print(0)\nelif N == 1 and A != B:\n print(0)\nelse:\n print((B-A)*(N-2)+1)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s530570421', 's966769320', 's815893660']
[3060.0, 3060.0, 3060.0]
[18.0, 17.0, 18.0]
[170, 116, 127]
p03705
u370721525
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['N, A, B = map(int, input().split())\n\nif N==1 and A==B:\n ans = 1\nelif N==1:\n ans = 0\nelif A > B:\n ans = 0\nelse:\n ans = (B-A) * (N-2) + 1', 'N, A, B = map(int, input().split())\n\nif N==1 and A==B:\n ans = 1\nelif N==1:\n ans = 0\nelif A > B:\n ans = 0\nelse:\n ans = (B-A) * (N-2) + 1\nprint(ans)']
['Wrong Answer', 'Accepted']
['s489828481', 's371638971']
[9020.0, 9092.0]
[26.0, 27.0]
[139, 150]
p03705
u382423941
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['n, a, b = map(int, input().split())\n\nif a > b or n < 1 or not (n == 1 and a == b):\n print(0)\nelse:\n ma, mi = b * (n-1) + a, a * (n - 1) + b\n print(ma - mi + 1)\n', 'n, a, b = map(int, input().split())\n\nif a > b or (n == 1 and a != b):\n print(0)\nelif a == b:\n print(1)\nelse:\n ma, mi = b * (n-1) + a, a * (n - 1) + b\n print(ma - mi + 1)\n']
['Wrong Answer', 'Accepted']
['s720458233', 's928943509']
[2940.0, 2940.0]
[17.0, 17.0]
[169, 182]
p03705
u426964396
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['n=input().slipt()\nprint(int(n[2]*(n[0]-2)-(n[1]*n[0]-2)+1))', 's=input().split();n,a,b=int(s[0]),int(s[1]),int(s[2])\nif a>b:\n print(0)\nelif n=1:\n if a==b:\n print(1)\n else:\n print(0)\nelse:\n print((a-b)*(n-2)+1)', 'n,a,b=map(int,input().split())\nif n>1 and b>=a or n==1 and a==b: \n print ((n-2)*(b-a)+1);\nelse:\n print ("0");']
['Runtime Error', 'Runtime Error', 'Accepted']
['s447208304', 's471302588', 's875559547']
[2940.0, 2940.0, 2940.0]
[17.0, 17.0, 17.0]
[59, 172, 115]
p03705
u443569380
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['n, a, b = map(int, input().split())A\nprint((b - a) * (n - 2) + 1)\n', 'n, a, b = map(int, input().split())\nx = a * n - a + b\ny = b * n - b + a\n\n\nif a > b:\n print(0)\nelif a == b and n == 1:\n print(1)\nelif a != b and n == 1:\n print(0)\nelse:\n print(y - x + 1)\n']
['Runtime Error', 'Accepted']
['s414896823', 's409473799']
[2940.0, 2940.0]
[17.0, 17.0]
[66, 198]
p03705
u463655976
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['N, A, B = map(int, input().split())\n\nN -= 1\nif A != B:\n N -= 1\n\nif N < 0:\n ans = 0\nelse:\n M = B - A\n ans = 1\n for k, m in zip(range(M + N, 0, -1), range(1, N+1)):\n ans *= k\n ans //= m\n\nprint(ans)\n', 'N, A, B = map(int, input().split())\n\nN -= 1\nif A != B:\n N -= 1\nif A > B:\n N = -1\n\nif N < 0:\n ans = 0\nelse:\n ans = (B - A) * N + 1\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s302223462', 's703972430']
[3444.0, 2940.0]
[2103.0, 17.0]
[207, 145]
p03705
u518064858
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['n,a,b=map(int,input().split())\nif a>b:\n print(0)\n exit()\nelif n=1 and a!=b:\n print(0)\n exit()\nprint((b-a)*(n-2)+1)\n', 'n,a,b=map(int,input().split())\nif a>b:\n print(0)\n exit()\nelif n==1 and a!=b:\n print(0)\n exit()\nprint((b-a)*(n-2)+1)\n']
['Runtime Error', 'Accepted']
['s140572839', 's933598743']
[2940.0, 3316.0]
[17.0, 19.0]
[127, 128]
p03705
u533039576
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['n, a, b = map(int, input().split())\n\nif n == 1 and a != b:\n ans = 0\nelse:\n ans = (b * (n - 1) + a) - (a * (n - 1) + b)\n\nprint(ans)\n', 'n, a, b = map(int, input().split())\n\nif n == 1 and a != b:\n ans = 0\nelif b < a:\n ans = 0\nelse:\n ans = (b * (n - 1) + a) - (a * (n - 1) + b) + 1\n\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s691356838', 's968367563']
[9084.0, 9152.0]
[27.0, 29.0]
[137, 165]
p03705
u554720358
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['#!/ust/bin/env python\n\nN,A,B=[int(i) for i in input().split()]\n\ndef sum(count, num):\n tmp=0\n for i in range(0, count):\n tmp+=num\n print("tmp",tmp)\n return tmp\n\nMax=(A+B)+sum(N-2, B)\nMin=(A+B)+sum(N-2, A)\n\nif(A>B):\n print(0)\nelif(A==B):\n print(1)\nelif(N==1):\n print(0)\nelif(N==2):\n print((B+B)-(A+A)+1)\nelif(Max-Min+1<=0):\n print(0)\nelse:\n print(Max-Min+1)\n', '#!/ust/bin/env python\n\nN,A,B=[int(i) for i in input().split()]\n\ndef main():\n if(A>B):\n print(0)\n return\n elif(A==B):\n print(1)\n return\n\n ### A<B\n Max=(A+B)+(N-2)*B\n Min=(A+B)+(N-2)*A\n\n if(N==1):\n print(0)\n elif(N==2):\n print((B+B)-(A+A)+1)\n elif(Max-Min+1<=0):\n print(0)\n else:\n print(Max-Min+1)\n\nmain()\n']
['Wrong Answer', 'Accepted']
['s973204736', 's527730353']
[3064.0, 3064.0]
[2103.0, 17.0]
[393, 387]
p03705
u572144347
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['n,a,b = map(int, input().split())\n\nif n == 1 and a == b:\n print(1)\nelif n == 1:\n print(0)\nelif a > b:\n print(0)\nelif n == 2:\n print(1)\nelif n > 2:\n print( (B-A+1) * (n-2) )', 'n,a,b = map(int, input().split())\n\nif n == 1 and a == b:\n print(1)\nelif n == 1:\n print(0)\nelif a > b:\n print(0)\nelif n == 2:\n print(1)\t\nelif n > 2:\n print( (b-a+1) * (n-2) )\nelse:\n print(0)', 'n,a,b = map(int, input().split())\n\nif n == 1 and a == b:\n print(1)\nelif n == 1:\n print(0)\nelif a > b:\n print(0)\nelif n == 2:\n print(1)\t\nelif n > 2:\n print( (B-A+1) * (n-2) )\nelse:\n print(0)', 'n,a,b = map(int, input().split())\n\nif n == 1 and a == b:\n print(1)\nelif n == 1:\n print(0)\nelif a > b:\n print(0)\nelif n == 2:\n print(1)\t\nelif n > 2:\n print( b * (n-2) - a * (n-2) + 1) \nelse:\n print(0)\n']
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s455036098', 's853557314', 's887440645', 's637372919']
[3060.0, 3060.0, 3060.0, 3060.0]
[17.0, 17.0, 17.0, 17.0]
[177, 195, 195, 206]
p03705
u580362735
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
["N,A,B = map(int,input().split())\ndata = range(A,B+1)\nif N-2>=0:\n print( (B − A)(N − 2) + 1)\nelif N == 1:\n if A!=B:\n print('0')\n else:\n print('1')\nelse:\n print('0')", "N,A,B = map(int,input().split())\nif A>B:\n print('0')\nelif N == 1:\n if A!=B:\n print('0')\n else:\n print('1')\nelse:\n print((B-A)*(N-2)+1)"]
['Runtime Error', 'Accepted']
['s943252398', 's601012604']
[2940.0, 2940.0]
[17.0, 18.0]
[177, 144]
p03705
u582763758
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
["n,a,b=list(map(int,input().split(' ')))\nprint(max(0,n-2)*max(0,b-a+1))\n", "n,a,b=list(map(int,input().split(' ')))\nprint(max(0,n-2)*max(0,a-b)+1)", "n,a,b=list(map(int,input().split(' ')))\nif n == 1:\n print(1 if a==b else 0)\nelse:\n print((b-a)*(n-2)+1 if b >= a else 0)\n"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s067759808', 's944410443', 's172416320']
[2940.0, 2940.0, 2940.0]
[17.0, 17.0, 17.0]
[71, 70, 127]
p03705
u597455618
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['s = input()\ns = list(s)\ns.sort()\nans = list("abc")\nif (s == ans):\n print("Yes")\nelse :\n print("No")', 'n, a, b = map(int, input().split())\nprint(max(0, (n-2)*b - (n-2)*a + 1))']
['Wrong Answer', 'Accepted']
['s699523009', 's576002147']
[2940.0, 2940.0]
[18.0, 17.0]
[101, 72]
p03705
u623687794
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['n,a,b=map(int,input().split())\nif a>b:\n print(0)\nelif a==b:\n print(1)\nelse:\n if n <= 2:\n print(n-1)\n else:\n print((b-a)*(n-2)-1) ', 'n,a,b=map(int,input().split())\nif a>b:\n print(0)\nelif a==b:\n print(1)\nelse:\n if n <= 2:\n print(n-1)\n else:\n print((b-a)*(n-2)+1) \n']
['Wrong Answer', 'Accepted']
['s510382753', 's111544906']
[3060.0, 2940.0]
[17.0, 17.0]
[139, 140]
p03705
u629350026
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['n,a,b=map(int,input().split())\nans=b*(n-1)+a-a*(n-1)-b\nif ans<=0:\n print(0)\nelse:\n print(ans)', 'n,a,b=map(int,input().split())\nans=b*(n-1)+a-a*(n-1)-b+1\nif ans<=0:\n print(0)\nelse:\n print(ans)']
['Wrong Answer', 'Accepted']
['s318923850', 's008339212']
[2940.0, 2940.0]
[17.0, 17.0]
[95, 97]
p03705
u637175065
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\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()\n\n\ndef main():\n n,a,b = LI()\n if n == 1:\n if a == b:\n return 1\n return 0\n\n if a > b:\n return 0\n\n return min((b*(n-1)+a) - (a*(n-1)+b) + 1, n)\n\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\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()\n\n\ndef main():\n n,a,b = LI()\n if n == 1:\n if a == b:\n return 1\n return 0\n\n if a > b:\n return 0\n\n if n == 2:\n return 1\n\n return min((b*(n-1)+a) - (a*(n-1)+b) + 1, n)\n\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\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()\n\n\ndef main():\n n,a,b = LI()\n if n == 1:\n if a == b:\n return 1\n return 0\n\n if a > b:\n return 0\n\n if n == 2:\n return 1\n\n return (b*(n-1)+a) - (a*(n-1)+b) + 1\n\n\nprint(main())\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s106720835', 's581722351', 's822089362']
[7752.0, 7880.0, 6732.0]
[87.0, 189.0, 88.0]
[718, 751, 743]
p03705
u640922335
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['N,A,B=map(int,input().split())\nif A>B:\n print(0)\nelif A==B:\n print(1)\nelse:\n if N==1:\n print(0)\n else:\n print((B*N-A*N)+1)', 'N,A,B=map(int,input().split())\nif A>B:\n print(0)\nelif A==B:\n print(1)\nelse:\n if N==1:\n print(0)\n else:\n print((B*(N-2)-A*(N-2))+1)']
['Wrong Answer', 'Accepted']
['s637550625', 's633047174']
[9116.0, 9100.0]
[29.0, 29.0]
[148, 156]
p03705
u649326276
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['s = input().split(" ");\nn = s[0];\na = s[1];\nb = s[2];\nif a > b :\n print(0);\nelse\n if n = 1 or n = 2:\n print(1);\n else\n ans = (b - a)*(n - 2)+1;\n print(ans);', 's = input().split(" ");\nn = int(s[0]);\na = int(s[1]);\nb = int(s[2]);\nif a > b :\n print(0);\nelse :\n if n == 1 :\n if a==b :\n print(1);\n else :\n print(0);\n else :\n ans = (b - a)*(n - 2)+1;\n print(ans);']
['Runtime Error', 'Accepted']
['s170524310', 's511102651']
[2940.0, 3060.0]
[17.0, 17.0]
[168, 223]
p03705
u652656291
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['n,a,b = map(int,input().split())\nif n == 1 :\n print(1)\nelse:\n if (b-a) >= 1:\n print((b+b+a)-(b+a+a)+1)\n else:\n print(0)\n', 'n,a,b = list(map(int, input().split()))\nprint(max(0, (b-a)*(n-2)+1))\n']
['Wrong Answer', 'Accepted']
['s258148931', 's601044003']
[2940.0, 2940.0]
[17.0, 17.0]
[129, 69]
p03705
u655048024
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['n,a,b = map(int,input().split())\nif(a>b):\n print(0)\nelse:\n if(n = 1):\n if(a!=b):\n print(0)\n else:\n print(1)\n else:\n print(b*(n-1)+a-(a*(n-1)+b)+1)\n ', 'n,a,b = map(int,input().split())\nk = a - b + n\nans = 1\nfor i in range(n):\n ans *= (k-i)\nfor i in range(n):\n ans = ans//(n-i)\nprint(ans)\n \n', 'n,a,b = map(int,input().split())\nk = a - b + 2 + n\nans = 1\nfor i in range(n):\n ans *= (k-i)\nfor i in range(n):\n ans = ans//(n-i)\nprint(ans)\n \n', 'n,a,b = map(int,input().split())\nk = a - b + 1 + n\nans = 1\nfor i in range(n):\n ans *= (k-i)\nfor i in range(n):\n ans = ans//(n-i)\nprint(ans)\n ', 'n,a,b = map(int,input().split())\nif(a>b):\n print(0)\nelse:\n if(n == 1):\n if(a!=b):\n print(0)\n else:\n print(1)\n else:\n print(b*(n-1)+a-(a*(n-1)+b)+1)\n \n']
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s366910264', 's449504750', 's703677008', 's785817371', 's827750507']
[8904.0, 9624.0, 9544.0, 9568.0, 9000.0]
[24.0, 2206.0, 2206.0, 2206.0, 28.0]
[171, 142, 146, 145, 173]
p03705
u665038048
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['n, a, b = map(int, input().split())\nmin_a_b = a * (n-1) + b\nmax_a_b = a + n * (n-1)\nprint(max_a_b - min_a_b + 1)', 'n, a, b = map(int, input().split())\nmin_a_b = a * (n-1) + b\nmax_a_b = a + b * (n-1)\nprint(max(0, max_a_b - min_a_b + 1))']
['Wrong Answer', 'Accepted']
['s330760462', 's488098678']
[2940.0, 2940.0]
[17.0, 17.0]
[112, 120]
p03705
u667084803
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['A=int(input())\nB=int(input())\nS=[]\ntimes=len(format(A^B,"b"))\nfor i in range(A,B+1):\n S+=[i]\nD=S[:] \nSET=set(S)\n#for t in range(times):\nfor i in range(len(S)):\n for j in range(len(D)):\n S+=[S[i]|D[j]]\n SET.add(S[i]|D[j])\nprint(len(SET))', 'N,A,B=map(int, input().split())\n\nif A>B:\n print(0)\nelif N==1:\n if A==B:\n print(1)\n else:\n print(0)\nelse:\n M=A+B*(N-1)\n m=A*(N-1)+B\n print(M-m+1)']
['Runtime Error', 'Accepted']
['s355368919', 's854570838']
[3064.0, 3316.0]
[18.0, 22.0]
[261, 164]
p03705
u672475305
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['n,a,b = map(int,input().split())\nif n==1:\n if a==b:\n print(1)\n else:\n print(0)\nelse:\n if b-a < 0:\n print(0)\n elif k==1:\n print(1)\n else:\n print(b*k - a*k+1)', 'n,a,b = map(int,input().split())\nif n==1:\n if a==b:\n print(1)\n else:\n print(0)\nelse:\n k = b-a\n if k < 0:\n print(0)\n elif k==0:\n print(1)\n else:\n print((b-a)*(n-2)+1)']
['Runtime Error', 'Accepted']
['s592438666', 's438133344']
[3060.0, 3060.0]
[17.0, 17.0]
[176, 186]
p03705
u693933222
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['n, a, b = map(int, input().split())\n\nif (a < b):\n print(0)\nelif (n == 1):\n if (a != b):\n print(0)\n else:\n print(1)\nelse:\n mx = a + b * (n - 1)\n mn = a * (n - 1) + b\n print(mx-mn+1)\n', 'n, a, b = map(int, input().split())\n\nif (a < b):\n print(0)\nelif (n == 1):\n print(1)\nelse:\n mx = a + b * (n - 1)\n mn = a * (n - 1) + b\n print(mx-mn+1)\n', 'n, a, b = map(int, input().split())\n\nif (a > b):\n print(0)\nelif (n == 1):\n if (a != b):\n print(0)\n else:\n print(1)\nelse:\n mx = a + b * (n - 1)\n mn = a * (n - 1) + b\n print(mx-mn+1)\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s471194206', 's750873119', 's196707013']
[2940.0, 2940.0, 2940.0]
[17.0, 17.0, 17.0]
[213, 165, 213]
p03705
u699944218
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['N, A, B = list(map(int,input().split()))\nif (B * (N-1) + A) - (B + (N-1) * A) <= 0:\n print(0)\nelif A == B:\n print(1)\nelse:\n print((B * (N-1) + A) - (B + (N-1) * A))', 'N, A, B = list(map(int,input().split()))\nif A > B:\n print(0)\nelif A == B:\n print(1)\nelse:\n print((B * (N-1) + A) - (B + (N-1) * A))', 'N, A, B = list(map(int,input().split()))\nif (B * (N-1) + A) - (B + (N-1) * A) < 0:\n print(0)\nelif A == B:\n print(1)\nelse:\n print((B * (N-1) + A) - (B + (N-1) * A) + 1)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s216054050', 's809202153', 's854308624']
[3060.0, 3060.0, 3060.0]
[17.0, 17.0, 17.0]
[167, 134, 170]
p03705
u713627549
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['s = list(input())\n\nz = 0\n\nfor i in s:\n if s[i] == "U":\n z += (len(s) - i)*1 + i * 2\n else:\n z += (len(s) - i)*2 + i * 1\n\nprint(z)\n', 's = list(input())\n\ncount = 0L\n\nfor i in range(len(s)):\n for j in range(len(s)):\n #print(i, j)\n if (i < j and s[i] == "D") or (i > j and s[i] == "U"):\n count += 2\n elif (i < j and s[i] == "U") or (i > j and s[i] == "D"):\n count += 1\n\nprint(count)\n', 's = list(input())\n\ncount = 0\n\nfor i in range(len(s)):\n for j in range(len(s)):\n if (i < j and s[i] == "D") or (i > j and s[i] == "U"):\n count += 2\n elif (i < j and s[i] == "U") or (i > j and s[i] == "D"):\n count += 1\n\nprint(count)\n', 'n, a, b = map(int, input().split())\n\nz = (n - 2) * (b - a) + 1\n\nif z < 0:\n print("0")\nelif z == 0:\n print("1")\nelse:\n print(z)']
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s390242515', 's816868487', 's841367162', 's031656958']
[2940.0, 2940.0, 3060.0, 3188.0]
[18.0, 18.0, 18.0, 18.0]
[150, 292, 270, 135]
p03705
u723721005
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['n = int(input())\na = int(input())\nb = int(input())\nprint((b - a) * (n - 2) + 1)', 'c=int(input()),a=int(input()),b=int(input())\nprint((a+b*c-b)-(a*c-a+b)+1)', '\n\nusing namespace std;\nll n,a,b;\nint main(){\n cin>>n>>a>>b;\n cout<<(b*(n-2)-a*(n-2)+1);\n return 0;\n}', '\nusing namespace std;\nint main()\n{\n long long n,a,b;\n cin>>n>>a>>b;\n if(n>1&&b>=a||n==1&&a==b)\n cout<<(n-2)*(b-a)+1<<endl;\n else\n cout<<0<<endl; \n } ', 'n,anb,b=map(int,input().split()) \nif n>1 and b>=anb or n==1 and anb==b: \n print ((n-2)*(b-anb)+1); \nelse:\n print ("0"); ']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s085770870', 's099841369', 's427931612', 's556396597', 's040879585']
[2940.0, 2940.0, 2940.0, 2940.0, 3060.0]
[17.0, 17.0, 17.0, 17.0, 19.0]
[79, 73, 147, 193, 126]
p03705
u740284863
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['n,a,b = map(int,input().split())\nif a > b:\n print(0)\nelif a == b:\n print(1)\nelse:\n print((n - 2) * (b - a) + 1))', 'n,a,b = map(int,input().split())\nif a > b:\n print(0)\nelif a == b:\n print(1)\nelse:\n pritn((n - 2) * (b - a) + 1)', 'n,a,b = map(int,input().split())\nprint(max(0,(n - 2) * (b - a) + 1))']
['Runtime Error', 'Runtime Error', 'Accepted']
['s074439959', 's445757488', 's660080439']
[2940.0, 2940.0, 2940.0]
[18.0, 17.0, 17.0]
[121, 120, 68]
p03705
u760171369
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['N, A, B = map(int, input().split())\nif N == 1:\n if A == B:\n print(1)\n else:\n print(0)\nelse:\n if A > B:\n print(0)\n elif A == B or N == 2:\n print(1)\n else:\n print((B-A) * (N-2))\n ', 'N, A, B = map(int, input().split())\nif N == 1:\n if A == B:\n print(1)\n else:\n print(0)\nelse:\n if A > B:\n print(0)\n elif A == B or N == 2:\n print(1)\n else:\n print((B-A) * (N-2) + 1)']
['Wrong Answer', 'Accepted']
['s942545662', 's555361810']
[3064.0, 3060.0]
[17.0, 18.0]
[198, 199]
p03705
u760961723
2,000
262,144
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are?
['N, A, B = map(int,input().split())\n\n\nif N == 1:\n if A==B:\n print(1)\n else:\n print(0)\nelse:\n ans = (B*(N-1)+A)-(A*(N-1)+B)\n if ans > 0:\n print(ans)\n else:\n print(0)', 'N, A, B = map(int,input().split())\n\n\nif N == 1:\n if A==B:\n print(1)\n else:\n print(0)\nelse:\n ans = (B*(N-1)+A)-(A*(N-1)+B) +1\n if ans > 0:\n print(ans)\n else:\n print(0)']
['Wrong Answer', 'Accepted']
['s503513940', 's081744569']
[9180.0, 9016.0]
[28.0, 29.0]
[180, 183]