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
p03294
u600402037
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['import numpy as np\nfrom functools import reduce\nfrom fractions import gcd\n\nN = int(input())\nA = np.array(list(map(int, input().split())))\n\ndef lcm_base(x, y):\n return (x * y) // gcd(x, y)\n\ndef lcm(*numbers):\n return reduce(lcm_base, numbers, 1)\n\nl = lcm(*A) \nprint(((l-1) % A).sum())\n', '# coding: utf-8\nimport sys\nimport numpy as np\n\nsr = lambda: sys.stdin.readline().rstrip()\nir = lambda: int(sr())\nlr = lambda: list(map(int, sr().split()))\n\nN = ir()\nA = np.array(lr())\nA -= 1\nanswer = A.sum()\nprint(answer)\n']
['Wrong Answer', 'Accepted']
['s411417666', 's193468819']
[13544.0, 12488.0]
[177.0, 152.0]
[311, 222]
p03294
u607729897
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['N=input()\na=list(map(int,input().split()))\nprint(sum(a-1))\n\n', 'N=input()\na=list(map(int,input().split()))\nprint(sum([i-1 for i in a]))\n']
['Runtime Error', 'Accepted']
['s708897453', 's803793360']
[3316.0, 3316.0]
[18.0, 18.0]
[60, 72]
p03294
u624617831
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['import math\n\nn = input()\na = input().split()\nN = int(n)\n\nann = []\nfor i in range(N):\n ana = 1\n for j in range(i+1):\n ana = ana * int(a[j])\n ann.append(ana-1)\n\nans_list = []\nfor k in ann:\n ans = 0\n for j in range(N):\n ans += int(i % int(a[j]))\n ans_list.append(ans)\n\nans_list.sort()\nans_list.reverse()\nprint(str(ans_list[0]))\n\n\n\n', 'import math\n\nn = input()\na = input().split()\nN = int(n)\n\nann = []\nfor i in range(N):\n ana = 1\n for j in range(i+1):\n ana = ana * int(a[j])\n ann.append(ana-1)\n\nans_list = []\nfor i in ann:\n ans = 0\n for j in range(N):\n ans += int(i % int(a[j]))\n ans_list.append(ans)\n\nprint(ans_list)\nans_list.sort()\nans_list.reverse()\nprint(str(ans_list[0]))\n\n\n\n', 'import math\n\nn = input()\na = input().split()\nN = int(n)\n\nann = []\nfor i in range(N):\n ana = 1\n for j in range(i+1):\n ana = ana * int(a[j])\n ann.append(ana-1)\n\nans_list = []\nfor k in ann:\n ans = 0\n for j in range(N):\n ans += int(i % int(a[j]))\n ans_list.append(ans)\n\nprint(ans_list)\nans_list.sort()\nans_list.reverse()\nprint(str(ans_list[0]))\n\n\n\n', 'import math\n\nn = input()\na = input().split()\nN = int(n)\n\nans_list = []\nann = []\nana = 1\nfor j in range(N):\n ana = ana * int(a[j])\nana = ana -1\nans = 0\nfor k in range(N):\n ans += int(ana % int(a[k]))\nans_list.append(ans)\n\nans_list.sort()\nans_list.reverse()\nprint(str(ans_list[0]))\n\n\n\n\n\n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s004467546', 's071972962', 's491309005', 's917615914']
[8268.0, 8892.0, 8396.0, 3188.0]
[2104.0, 2104.0, 2104.0, 90.0]
[360, 376, 376, 291]
p03294
u626337957
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['N = input()\nA = list(map(int, input().split()))\nans = 0\nfor i in range(N):\n ans += A[i]-1\nprint(ans)', 'N = int(input())\nA = list(map(int, input().split()))\nans = 0\nfor i in range(N):\n ans += A[i]-1\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s393525843', 's719924565']
[3316.0, 3316.0]
[18.0, 18.0]
[101, 107]
p03294
u626468554
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['n = int(input())\na = list(map(int,input().split()))\n\ndef gcd(a,b):\n if a<b:\n a,b = b,a\n if b==0:\n return a\n else:\n return gcd(b,a%b)\n\ndef lcm(a,b):\n return (a*b)//gcd(a,b)\n\nans = a[0]\nfor i in range(n-1):\n ans = lcm(ans,a[i+1])\n\nans2 = 0\nfor i in range(n):\n ans2 += ans%a[i]\nprint(ans2)', 'n = int(input())\na = list(map(int,input().split()))\n\ndef gcd(a,b):\n if a<b:\n a,b = b,a\n if b==0:\n return a\n else:\n return gcd(b,a%b)\n\ndef lcm(a,b):\n return (a*b)//gcd(a,b)\n\nans = a[0]\nfor i in range(n-1):\n ans = lcm(ans,a[i+1])\nans-=1\nans2 = 0\nfor i in range(n):\n ans2 += ans%a[i]\n #print(ans2)\nprint(ans2)']
['Wrong Answer', 'Accepted']
['s335742371', 's468949680']
[3316.0, 3316.0]
[158.0, 157.0]
[325, 348]
p03294
u635272634
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['import fraction\nfrom functools import reduce\n\ndef lcm_base(x, y):\n return (x * y) // fraction.gcd(x, y)\n\ndef lcm(nums):\n return reduce(lcm_base, nums, 1)\n\nn, a = input(), list(map(int, input().split()))\nl = lcm(a)\nsum = 0\nfor aa in a:\n sum += (l-1) % aa\nprint(sum)\n', 'from functools import reduce\ndef gcd(a, b):\n if a < b:\n a, b = b, a\n if b == 0:\n return a\n c = a % b\n return gcd(b, c)\n\n\ndef lcm_base(x, y):\n return (x * y) // gcd(x, y)\n\ndef lcm(nums):\n return reduce(lcm_base, nums, 1)\n\nn, a = input(), list(map(int, input().split()))\nl = lcm(a)\nsum = 0\nfor aa in a:\n sum += (l-1) % aa\nprint(sum)\n']
['Runtime Error', 'Accepted']
['s214571113', 's551370366']
[2940.0, 3812.0]
[18.0, 167.0]
[274, 366]
p03294
u636311816
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['import math', 'import math\n\nn = int(input())\nl = list(map(int,input().split()))\n\ndef lcm(a, b):\n return int(a * b / math.gcd(a, b))\n\nllcm=1\nfor i in range(n):\n llcm= lcm(llcm,l[i])', 'c=0\nfor i in range(100000000000):\n c+=1', 'n = int(input())\nl = list(map(int,input().split()))\n\ncnt=0\nf=0\nfor i in l:\n f += i-1\nprint(f)']
['Wrong Answer', 'Runtime Error', 'Time Limit Exceeded', 'Accepted']
['s146228896', 's177586498', 's211791222', 's407007064']
[2940.0, 3316.0, 3064.0, 3316.0]
[17.0, 20.0, 2104.0, 18.0]
[11, 171, 42, 96]
p03294
u637824361
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['N = int(input())\na = [int(i) for i input().split()]\nprint(sum(a) - N)', 'N = int(input())\na = [int(i) for i in input().split()]\n\nprint(sum(a) - N)\n']
['Runtime Error', 'Accepted']
['s198448276', 's737917530']
[2940.0, 3316.0]
[17.0, 18.0]
[69, 74]
p03294
u642823003
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['n = int(input())\na = list(map(int, input().split()))\n\nprint(sum(s) - n)\n', 'n = int(input())\na = list(map(int, input().split()))\n\nprint(sum(a) - n)\n']
['Runtime Error', 'Accepted']
['s827803379', 's622329946']
[3316.0, 3316.0]
[17.0, 17.0]
[72, 72]
p03294
u644516473
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['n = int(input())\na = map(int, input().split())\nprint(sum(x-1 for x in s))', 'n = int(input())\na = map(int, input().split())\nprint(sum(x-1 for x in a))\n']
['Runtime Error', 'Accepted']
['s796698419', 's105361139']
[3188.0, 3188.0]
[18.0, 19.0]
[73, 74]
p03294
u652057333
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['# C\nfrom functools import reduce\nfrom fractions import gcd\nfrom functools import lru_cache\n\n@lru_cache(None)\ndef lcm(a, b):\n return int(a*b/gcd(a, b))\n\nn = int(input()) \na = list(map(int, input().split()))\n\nresult = 0\nmod = int(reduce(lcm, a))-1\n\nfor i in range(len(a)):\n result += mod % a[i] \n\nprint(result)', '# C\nfrom functools import reduce\nfrom fractions import gcd\nfrom functools import lru_cache\n\n@lru_cache(None)\ndef lcm(a, b):\n return int(a*b/gcd(a, b))\n\nn = int(input()) \na = list(map(int, input().split()))\n\nresult = 0\nmod = reduce(lcm, a)-1\n\nfor i in range(len(a)):\n result += mod % a[i] \n\nprint(int(result))', 'n = int(input())\na = list(map(int, input().split()))\n\nprint(sum(a) - n)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s124878406', 's384245809', 's607483815']
[5640.0, 5640.0, 3316.0]
[152.0, 52.0, 18.0]
[314, 314, 71]
p03294
u655975843
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['import fractions\nfrom functools import reduce\n\ndef lcm(a, b):\n return (a * b) // fractions.gcd(a, b)\ndef lcm_list(l):\n return reduce(lcm, l, 1)\n\nn = int(input())\na = list(map(int, input().split()))\nf = 0\nfor j in range(n):\n f += (lcm_list(a) - 1) % a[j]\nprint(f)\n', 'n = int(input())\na = list(map(int, input().split()))\nans = []\nfor i in range(10 ** 5 // n):\n f = 0\n for j in range(n):\n f += i % a[j]\n print(f)\n ans.append(f)\nprint(max(ans))\n', 'n = int(input())\na = list(map(int, input().split()))\nans = []\nfor i in range(10 ** 9 // n):\n f = 0\n for j in range(n):\n f += i % a[j]\n print(f)\n ans.append(f)\nprint(max(ans))\n', 'n = int(input())\na = list(map(int, input().split()))\nans = []\nfor i in range(10 ** 8 // n):\n f = 0\n for j in range(n):\n f += i % a[j]\n print(f)\n ans.append(f)\nprint(max(ans))\n', 'n = int(input())\na = list(map(int, input().split()))\nf = 0\nans = 0\nfor i in range(n):\n ans += a[i]\nprint(ans - n)\n']
['Time Limit Exceeded', 'Wrong Answer', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted']
['s086898868', 's285025049', 's615467540', 's662418626', 's008591694']
[5344.0, 4240.0, 38700.0, 38444.0, 3316.0]
[2108.0, 103.0, 2108.0, 2106.0, 19.0]
[272, 194, 194, 194, 117]
p03294
u659646849
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['7\n994 518 941 851 647 2 581', 'n = int(input()) \na = map(int, input().split()) \nprint(sum([aa-1 for aa in a])) \n']
['Runtime Error', 'Accepted']
['s008035295', 's902246571']
[3064.0, 3316.0]
[17.0, 18.0]
[27, 378]
p03294
u664796535
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['def mode_max(N, arr):\n\n maximum = 0\n\n for i in range(1, 100001):\n\n current = 0\n\n for a in arr:\n\n current += i % a\n\n maximum = max(maximum, current)\n\n return maximum', 'n = int(input())\n\narr = [int(a) - 1 for a in input().split()]\n\nprint(sum(arr))']
['Wrong Answer', 'Accepted']
['s183929654', 's288896703']
[2940.0, 3316.0]
[17.0, 18.0]
[205, 78]
p03294
u667469290
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
["# -*- coding: utf-8 -*-\nimport math\nimport operator\nfrom functools import reduce\ndef gcd(a,b):\n c = 0\n while a != b:\n if a&1==b&1==0:\n a, b = a>>1, b>>1\n c += 1\n elif min(a,b) == 0:\n a = max(a,b)\n else:\n a, b = max(a,b)%min(a,b), min(a,b)\n return a*2**c\n\n\ndef lcm(a,b):\n return (a*b)//gcd(a,b)\n\ndef solve():\n N = int(input())\n *A, = map(int, input().split())\n m = reduce(lcm, A) - 1\n print(m)\n s = sum([m%a for a in A])\n\n return str(s)\n\nif __name__ == '__main__':\n print(solve())", "# -*- coding: utf-8 -*-\nimport math\nimport operator\nfrom functools import reduce\ndef gcd(a,b):\n c = 0\n while a != b:\n if a&1==b&1==0:\n a, b = a>>1, b>>1\n c += 1\n elif min(a,b) == 0:\n a = max(a,b)\n else:\n a, b = max(a,b)%min(a,b), min(a,b)\n return a*2**c\n\n\ndef lcm(a,b):\n return (a*b)//gcd(a,b)\n\ndef solve():\n N = int(input())\n *A, = map(int, input().split())\n m = reduce(lcm, A) - 1\n s = sum([m%a for a in A])\n\n return str(s)\n\nif __name__ == '__main__':\n print(solve())\n"]
['Wrong Answer', 'Accepted']
['s354096508', 's210269523']
[3828.0, 3804.0]
[190.0, 187.0]
[577, 565]
p03294
u673338219
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['n = int(input())\na = list(map(int,input().split())\nprint(sum(a)-n)\n \n\n ', 'n = int(input())\na = list(map(int,input().split()))\nprint(sum(a)-n)\n \n\n ']
['Runtime Error', 'Accepted']
['s102652696', 's583444650']
[2940.0, 3316.0]
[17.0, 18.0]
[86, 87]
p03294
u676496404
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['n = int(input())\na = input().split(" ")\n\nmax = a[0]\nfor i in range(1,n) :\n if max < a[i] :\n max = a[i]\n\nf = 0\nfor j in range(1,int(max)) :\n for d in range(0,n) :\n f[j] += j//a[d]\n\nmax1 = 0\nfor i in range(1,int(max)):\n if max1 < f[i] :\n max1 = f[i]\n\nprint(max1)', 'n = int(input())\na = list(map(int,input().split()))\n\na.sort()\n\nfor m in range(0,int(a[n])) :\n for j in range(0,n) :\n f[m] += m//a[j]\n\nf.sort()\n\nprint(f[n])', 'N = int(input())\na = [int(i) for i in input().split()]\nprint(sum(a)-N)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s290319070', 's370583161', 's562715296']
[3188.0, 3316.0, 3316.0]
[18.0, 18.0, 18.0]
[290, 165, 70]
p03294
u686036872
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['N = int(input())\nA = list(map(int, input().split()))\n\nsaidai = 0\nfor i in range(min(A), Max(A)*2):\n cnt = 0\n for j in range(N):\n cnt += i%A[j]\n saidai = max(saidai, cnt)\n\nprint(saidai)', 'N = int(input())\nA = list(map(int, input().split()))\n\nprint(sum(A)-N)']
['Runtime Error', 'Accepted']
['s781143836', 's121626118']
[3316.0, 3316.0]
[19.0, 18.0]
[200, 69]
p03294
u693048766
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['from fractions import gcd\nfrom functools import reduce\ndef lcm(a,b): return abs(a * b)/gcd(a,b) if a and b else 0\n\nn = input()\n\nxs = [int(x) for x in input().split()]\n\nmlcm = 1\nfor x in set(xs):\n mlcm = lcm(mlcm, x)\n\nmlcm -= 1\nmlcm = int(mlcm)\nprint(sum([ mlcm%x for x in xs]))', 'from fractions import gcd\ndef lcm(a,b): return abs(a * b)/gcd(a,b) if a and b else 0\n\nn = input()\n\nxs = [int(x) for x in input().split()]\n\nfrom functools import reduce\n\nmlcm = int(reduce(lcm, xs))\n\nmlcm -= 1\nprint(sum([ mlcm%x for x in xs]))', 'n = input()\nxs = [int(x)-1 for x in input().split()]\nprint(sum(xs))']
['Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted']
['s018664127', 's476825560', 's530950035']
[5500.0, 5372.0, 3316.0]
[2104.0, 2104.0, 18.0]
[278, 241, 67]
p03294
u695644361
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['n = input()\narr = list(map(int, input().split()))\n\ndef f(m, a):\n return sum([m % i for i in a])\n\ndef gcd(a, b):\n while b > 0:\n\tif a < b: a, b = b, a\n r = a % b\n\ta = b\n b = r\n return a\n\nlcm = arr[0]\nfor i in range(1, len(arr)):\n lcm = lcm * arr[i] // gcd(lcm, arr[i])\n', 'n = input()\narr = list(map(int, input().split()))\n\ndef f(m, a):\n return sum([m % i for i in a])\n\ndef gcd(a, b):\n while b > 0:\n if a < b: a, b = b, a\n r = a % b\n a = b\n b = r\n return a\n\nlcm = arr[0]\nfor i in range(1, len(arr)):\n lcm = lcm * arr[i] // gcd(lcm, arr[i])\n\nprint(f(lcm -1, arr))\n']
['Runtime Error', 'Accepted']
['s073018580', 's671770560']
[2940.0, 3316.0]
[17.0, 155.0]
[293, 330]
p03294
u698919163
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['N = int(input())\na = list(map(int,input().split()))\n\ndef lcm(a):\n from fractions import gcd\n x = a[0]\n for i in range(1, len(a)):\n x = (x * a[i]) // gcd(x, a[i])\n return x\n\nans = 0\n\nfor i in range(N):\n ans += (lcm(a)-1)%a[i]\n \nprint(ans)', 'N = int(input())\na = list(map(int,input().split()))\n\ndef lcm(a):\n from fractions import gcd\n x = a[0]\n for i in range(1, len(a)):\n x = (x * a[i]) // gcd(x, a[i])\n return x\n\nans = 0\npi = 1\n\nfor i in range(N):\n pi *= a[i]\n\nfor i in range(N):\n ans += (pi-1)%a[i]\n \nprint(ans)']
['Time Limit Exceeded', 'Accepted']
['s764672967', 's978492107']
[5172.0, 3316.0]
[2104.0, 94.0]
[262, 300]
p03294
u702582248
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['n = int(input())\na=map(int, input().split())\nprint(sum(a) - len(a))', 'n = int(input())\na=list(map(int, input().split()))\nprint(sum(a) - len(a))']
['Runtime Error', 'Accepted']
['s854349667', 's320099030']
[3188.0, 3316.0]
[18.0, 19.0]
[67, 73]
p03294
u709970295
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['def gcd(x,y):\n x,y = max(x,y),min(x,y)\n while(y>0):\n x,y = y,x%y\n print(x)\ndef lcm(a,b):\n return(int(a*b/gcd(a,b)))\n\nn = int(input())\na = list(map(int,input().split()))\nleast_common_multiple = 1\nfor i in range(n):\n least_common_multiple = lcm(least_common_multiple,a[i])\nans = 0\nfor i in range(n):\n ans += (least_common_multiple-1)%a[i]\nprint(ans)', 'import numpy as np\nn = int(input())\na = np.array(list(map(int,input().split())))-1\nprint(a.sum())']
['Runtime Error', 'Accepted']
['s543151149', 's637745642']
[3316.0, 12420.0]
[18.0, 149.0]
[372, 97]
p03294
u727787724
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['n=int(input())\na=list(int,input().split())\nprint(sum(a)-n)', 'n=int(input())\na=list(map(int,input().split()))\nprint(sum(a)-n)']
['Runtime Error', 'Accepted']
['s843794440', 's271085421']
[3188.0, 3316.0]
[17.0, 18.0]
[58, 63]
p03294
u731253724
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['import math\nfrom functools import reduce\ninput()\nip = input().split()\ndata = []\nfor i in ip:\n data.append(int(i))\n\ndef lcmB(x,y):\n return x * y/math.gcd(int(x),int(y))\n\ndef lcm(num):\n return reduce(lcmB,num)\n\nprint(int(lcm(data) - 1))', 'input()\nip = input().split()\ndata = []\nans = 0\nfor i in ip:\n ans += int(i) - 1\n\nprint(ans)']
['Runtime Error', 'Accepted']
['s803221783', 's425563188']
[3828.0, 3316.0]
[24.0, 19.0]
[243, 93]
p03294
u743272507
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['n = input()\nl = list(map(int,input().split()))\nprint(sum(l)-n)', 'n = input()\nl = list(map,input().split())\nprint(sum(l)-n)', 'n = int(input())\nl = list(map(int,input().split()))\nprint(sum(l)-n)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s481090902', 's614900012', 's935187747']
[3316.0, 3188.0, 3316.0]
[18.0, 17.0, 18.0]
[62, 57, 67]
p03294
u761989513
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['from functools import reduce\n\nn = int(input())\na = list(map(int, input().split()))\n\ndef gcd(a, b):\n if b == 0:\n return a\n else:\n return gcd(b, a % b)\n\ndef lcm_base(a, b):\n return a * b / gcd(a, b)\n\ndef lcm(n):\n return reduce(lcm_base, n)\n\nf = 0\nfor i in a:\n f += lcm(a) - 1 % i\n\nprint(int(f))\n', 'from functools import reduce\n\ndef gcd(a, b):\n if b == 0:\n return a\n return gcd(b, a % b)\n\ndef lcm(a, b):\n return (a * b) // gcd(a, b)\n\ndef lcm_list(n):\n return reduce(lcm, n)\n\n\nn = int(input())\na = list(map(int, input().split()))\nm = lcm_list(a) - 1\nans = 0\nfor i in range(n):\n ans += m % a[i]\nprint(ans)']
['Runtime Error', 'Accepted']
['s889068916', 's809042273']
[4644.0, 3812.0]
[2104.0, 161.0]
[304, 326]
p03294
u762420987
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['import numpy as np\nN = int(input())\nalist = np.array(list(map(int, input().split())))\n\n\ndef f(m):\n return np.sum(np.mod(alist, m))\n\n\nmax_num = 0\nfor m in range(1, np.max(alist)):\n num = f(m)\n if num > max_num:\n max_num = num\n\nprint(max_num - N)\n', 'import numpy as np\nN = int(input())\nalist = np.array(list(map(int, input().split())))\nprint(np.sum(alist - 1))\n']
['Wrong Answer', 'Accepted']
['s631772446', 's870722480']
[14532.0, 12424.0]
[2108.0, 153.0]
[261, 111]
p03294
u766566560
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['# ans\n\nN = int(input())\na = list(map(int, input().split()))\nprint(sum(a) = N)', 'N = int(input())\na = list(map(int, input().split()))\n\nans = 0\n\nfor m in range(2, 10000000):\n s = 0\n for i in range(N):\n s += m % a[i]\n ans = max(s, ans)\n \nprint(ans)', 'N = int(input())\na = list(map(int, input().split()))\nprint(sum(a) - N)']
['Runtime Error', 'Time Limit Exceeded', 'Accepted']
['s429035839', 's759461704', 's984133940']
[2940.0, 3316.0, 3316.0]
[17.0, 2104.0, 18.0]
[77, 172, 70]
p03294
u780475861
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['import sys\nreadline = sys.stdin.readline\nn = int(readline())\nprint(sum([int(i) for i in readline().split()] - n)', 'import sys\nreadline = sys.stdin.readline\nn = int(readline())\nprint(sum([int(i) for i in readline().split()]) - n)']
['Runtime Error', 'Accepted']
['s398550507', 's781396175']
[2940.0, 3316.0]
[17.0, 18.0]
[112, 113]
p03294
u785578220
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['a = ai()\nx = lma()\nprint(sum(x)-a)', 'def a():return input()#s\ndef ai():return int(input())#a,n or k\ndef ma():return map(int, input().split())#a,b,c,d or n,k\ndef ms():return map(str, input().split())#,a,b,c,d\ndef lma():return list(map(int, input().split()))#x or y\ndef lms():return list(map(str, input().split()))#x or y\na = ai()\nx = lma()\nprint(sum(x)-a)']
['Runtime Error', 'Accepted']
['s929559328', 's180428809']
[2940.0, 3316.0]
[18.0, 20.0]
[34, 317]
p03294
u785989355
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['\nN=int(input())\na = list(map(int,input().split()))\n\nans = 0\nfor aa in a:\n ans+=a-1\n \nprint(ans)', '\nN=int(input())\na = list(map(int,input().split()))\n\nans = 0\nfor aa in a:\n ans+=aa-1\n \nprint(ans)']
['Runtime Error', 'Accepted']
['s828103062', 's682638182']
[3316.0, 3316.0]
[19.0, 19.0]
[101, 102]
p03294
u787456042
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['n,a=open(0);print(eval(a.replace(" ","+")+"-"+n[:-1]))', 'n,a=open(0);print(eval(a.replace(" ","+")+"-"+n))', 'print(-int(input())+sum(map(int,input().split())))']
['Runtime Error', 'Runtime Error', 'Accepted']
['s242535591', 's391179930', 's338751947']
[3924.0, 3924.0, 3188.0]
[19.0, 19.0, 17.0]
[54, 49, 50]
p03294
u806855121
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['7\n994 518 941 851 647 2 581\n', 'N = int(input())\nai = list(map(int, input().split()))\n\nans = 0\nfor a in ai:\n ans += a - 1\n\nprint(ans)']
['Runtime Error', 'Accepted']
['s202089346', 's539799432']
[2940.0, 3316.0]
[17.0, 18.0]
[28, 104]
p03294
u808427016
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['print(-int(input())+sum(map(input().split(),int)))', 'N = int(input())\nA = [int(_) for _ in input().split()]\nprint(sum(A) - N)']
['Runtime Error', 'Accepted']
['s330587752', 's443064177']
[3316.0, 3316.0]
[20.0, 18.0]
[50, 72]
p03294
u809457879
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['from functools import reduce\nimport fractions\nN = int(input())\nt = tuple(map(int,input().split()))\n\ndef lcm(x,y):\n return x*y/fractions.gcd(x,y)\n\nm=reduce(lcm, t)-1\nans=0\nfor i in t:\n ans+=m%i\nprint(int(ans))', 'from functools import reduce\nimport fractions\nN = int(input())\nt = tuple(map(int,input().split()))\n\ndef lcm(x,y):\n return x*y/fractions.gcd(x,y)\n\nm=reduce(lcm, t)-1\nans=0\nfor i in t:\n ans+=m%i\nprint(ans)', 'N = int(input())\nt = tuple(map(int,input().split()))\nans=0\nfor i in t:\n ans+=i-1\nprint(ans)']
['Time Limit Exceeded', 'Wrong Answer', 'Accepted']
['s375231802', 's456954565', 's567229647']
[5340.0, 5340.0, 3316.0]
[2104.0, 2108.0, 20.0]
[210, 205, 92]
p03294
u813102292
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['n = int(input())\na = (int(i) for i in input().split())\nprint(sum(a)-len(a))', 'N = int(input())\na = list(map(int, input().split()))\nprint(sum(a)-N)']
['Runtime Error', 'Accepted']
['s959684978', 's007380011']
[3188.0, 3316.0]
[19.0, 18.0]
[75, 68]
p03294
u838350081
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['import sys\n\n\ndef gcd(a, b):\n while b > 0:\n a, b = b, a%b\n return a\n\n\ndef lcm(a, b):\n return a*b/gcd(a, b)\n\nn = int(input())\na = list(map(int,input().split())).sort()\n\nlcm_num = lcm(a[0], a[1])\n\nfor i in range(2, n):\n lcm_num = lcm(lcm_num, a[i])\n\nans = 0\nfor i in range(n):\n ans += (lcm_num-1) % a[i]\n\nprint(int(ans))\n \n', 'n = int(input())\na = list(map(int,input().split()))\n\n\n# \n\n\n\nans = 0\nfor i in range(n):\n ans += a[i] - 1\n\nprint(int(ans))\n \n']
['Runtime Error', 'Accepted']
['s333990047', 's917091452']
[3316.0, 3316.0]
[19.0, 18.0]
[367, 211]
p03294
u853900545
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['n = int(input())\na = list(map(int,input().split()))\nx = min(3000,gcd(a[i] for i in range(n)))\nm = [0]*x\n\nfor i in range(x):\n for j in a:\n m[i] += m%j\n\nprint(max(m))\n', 'n = int(input())\na = list(map(int,input().split()))\nx = min(3000,reduce(gcd,_ for _ in a))\nm = [0]*x\n\nfor i in range(x):\n for j in a:\n m[i] += m%j\n\nprint(max(m))', 'n = int(input())\na = list(map(int,input().split()))\nx = min(3000,gcd(_ for _ in a))\nm = [0]*x\n\nfor i in range(x):\n for j in a:\n m[i] += m%j\n\nprint(max(m))', 'n = int(input())\na = list(map(int,input().split()))\n\nprint(sum(a)-n)']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s533128844', 's575155097', 's670319276', 's663608395']
[3316.0, 3056.0, 3316.0, 3316.0]
[17.0, 17.0, 18.0, 18.0]
[175, 171, 164, 68]
p03294
u853952087
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['n=int(input())\nL=[list(map(int, input().split())) for i in range(D)]\nprint(sum(L)-n)', 'n=int(input())\nL=list(map(int, input().split()))\nprint(sum(L)-n)']
['Runtime Error', 'Accepted']
['s405110984', 's746073657']
[3060.0, 3316.0]
[18.0, 18.0]
[84, 64]
p03294
u865383026
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['N=int(input)\nprint(sum(list(map(int, input().split())))-N)', 'N=int(input())\nprint(sum(list(map(int, input().split())))-N)\n']
['Runtime Error', 'Accepted']
['s500571048', 's713246191']
[9088.0, 9376.0]
[27.0, 27.0]
[58, 61]
p03294
u891217808
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['n = int(input())\nns = map(int, input().split())\nprint(sum(ns)-len(ns))', 'n = int(input())\nns = list(map(int, input().split()))\nprint(sum(ns)-len(ns))']
['Runtime Error', 'Accepted']
['s551280590', 's697714383']
[3188.0, 3316.0]
[18.0, 18.0]
[70, 76]
p03294
u897329068
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['N = int(input())\nANs = list(map(int,input().split()))\n \ndef lcm_base(x, y):\n\treturn (x * y) // gcd(x, y)\n\t\nlcmNum = ANs[0]\nfor a in ANs[1:]:\n\tlcmNum = lcm_base(lcmNum,a)\n\t\n#print(lcmNum)\n \nf = 0\nfor a in ANs:\n\tf += (lcmNum-1)%a\nprint(f)', 'N = int(input())\nANs = list(map(int,input().split()))\n \ndef gcd(a, b):\n\twhile b:\n\t\ta, b = b, a % b\n\treturn a\n \ndef lcm_base(x, y):\n\treturn (x * y) // gcd(x, y)\n\t\nlcmNum = ANs[0]\nfor a in ANs[1:]:\n\tlcmNum = lcm_base(lcmNum,a)\n\t\n#print(lcmNum)\n \nf = 0\nfor a in ANs:\n\tf += (lcmNum-1)%a\nprint(f)']
['Runtime Error', 'Accepted']
['s305929738', 's399387269']
[3316.0, 3316.0]
[18.0, 160.0]
[236, 291]
p03294
u902151549
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['# coding: utf-8\nimport time\nimport re\nimport math\n\ndef main():\n n=int(input())\n A=list(map(int,input().split()))\n maxMod=max(A)\n for a in range(maxMod*2):\n total=0\n for b in range(n):\n mod=A[b]\n total+=a%mod\n print(total)\nmain()', '# coding: utf-8\nimport time\nimport re\nimport math\n\ndef main():\n n=int(input())\n A=list(map(int,input().split()))\n total=0\n m=1\n for a in A:\n m*=a\n m-=1\n for a in range(n):\n mod=A[a]\n total+=m%mod\n print(total)\nmain()']
['Wrong Answer', 'Accepted']
['s769740397', 's820621867']
[3888.0, 3568.0]
[2104.0, 91.0]
[283, 261]
p03294
u904804404
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['li = list(map(int,input().split(" ")))\ns = lcm(li[0],li[1])\nfor i in range(len(li)-2):\n s = lcm (s,li[i+2])\ndef f(m):\n r = 0\n for i in li:\n r += m%i\n return r\nprint(f(s-1))', 'def gcd(a, b):\n\twhile b:\n\t\ta, b = b, a % b\n\treturn a\ndef lcm(a, b):\n\treturn a * b // gcd (a, b)\nli = list(map(int,input().split(" ")))\ns = lcm(li[0],li[1])\nfor i in range(len(li)-2):\n s = lcm (s,li[i+2])\ndef f(m):\n r = 0\n for i in li:\n r += m%i\n return r\nprint(f(s-1))', 'input()\ndef gcd(a, b):\n\twhile b:\n\t\ta, b = b, a % b\n\treturn a\ndef lcm(a, b):\n\treturn a * b // gcd (a, b)\nli = list(map(int,input().split(" ")))\ns = lcm(li[0],li[1])\nfor i in range(len(li)-2):\n s = lcm (s,li[i+2])\ndef f(m):\n r = 0\n for i in li:\n r += m%i\n return r\nprint(f(s-1))\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s063519857', 's974243113', 's897177408']
[3060.0, 3064.0, 3316.0]
[17.0, 18.0, 154.0]
[194, 290, 299]
p03294
u904943473
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['lst = list(map(int, input().split()))\n\nlst.sort(reverse=True)\nprint(abs(lst[0] - lst[1]) + abs(lst[1] - lst[2]))', 'N = int(input())\n\nlst = list(map(int, input().split()))\n\nsum = 0\nfor i in lst:\n sum += i-1\nprint(sum)']
['Runtime Error', 'Accepted']
['s782235801', 's275812352']
[3060.0, 3316.0]
[20.0, 19.0]
[112, 102]
p03294
u905203728
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['n=input()\nbox=[int(input())-1 for i in range(int(n))]\nprint(sum(box))', 'print(-int(input())+sum(map(int,input().split())))']
['Runtime Error', 'Accepted']
['s881875114', 's160913667']
[3060.0, 3188.0]
[17.0, 18.0]
[69, 50]
p03294
u937529125
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['sa = list(map(int,input().split()))\nans = 0\nfor i in sa:\n ans += (i-1)\nprint(ans)', 'aaa = input()\nsa = list(map(int,input().split()))\nans = 0\nfor i in sa:\n ans += (i-1)\nprint(ans)']
['Wrong Answer', 'Accepted']
['s793955169', 's215052685']
[3060.0, 3316.0]
[17.0, 18.0]
[84, 98]
p03294
u940533000
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['\nコンテスト時間: 2018-07-21(土) 21:00 ~ 2018-07-21(土) 22:40 (100分)AtCoderホームへ戻る\n トップ\n 問題\n 質問\n 提出\n 提出結果\n 順位表\n バーチャル順位表\n コードテスト\n 解説\nコードテスト\n言語\n\nソースコード\n)\n1\nN = int(input())\n2\na = list(map(int, input().split()))\n3\na.sort(reverse=True)\n4\n\u200b\n5\n\n6\nans = 0\n7\nval1, val2 = a[0], a[1]\n8\nwhile 1:\n9\n if val1 % val2 == 0:\n10\n ans = a[0]*a[1]/val2\n11\n break\n12\n else:\n13\n tmp = val2\n14\n val2 = val1 % val2\n15\n val1 = tmp\n16\n\u200b\n17\nfor i in range(2, N):\n18\n val1, val2 = ans, a[i]\n19\n while 1:\n20\n if val1 % val2 == 0:\n21\n ans = ans*a[i]/val2\n22\n break\n23\n else:\n24\n tmp = val2\n25\n val2 = val1 % val2\n26\n val1 = tmp\n27\n\u200b\n28\nf_ans = 0\n29\nfor i in range(N):\n30\n f_ans += (ans-1)%a[i]\n31\nprint(int(f_ans))\n32\n \n33\n \n34\n \n※ 512 KiB まで\n※ ソースコードは「Main.拡張子」で保存されます\n\n \n標準入力\n7\n994 518 941 851 647 2 581\n※ 512 KiB まで\n\n終了コード\t0\n実行時間\t17 ms\nメモリ\t2964 KB\n標準出力\n4527\n\n標準エラー出力\nFacebookTwitterHatena共有\nルール 用語集\n利用規約 プライバシーポリシー 個人情報保護方針 企業情報 よくある質問 お問い合わせ 資料請求\nCopyright Since 2012 ©AtCoder Inc. All rights reserved.', 'N = int(input())\na = list(map(int, input().split()))\n\nans = 0\nfor i in range(N):\n ans += a[i]-1\nprint(ans)']
['Runtime Error', 'Accepted']
['s441473375', 's685505144']
[9004.0, 9264.0]
[26.0, 31.0]
[1432, 107]
p03294
u941753895
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['\n# while y:\n\n# return x\n\n\n# return x*y/gcd(x,y)\n\nimport fractions\nfrom functools import reduce\n\ndef lcm_base(x,y):\n return x*y/fractions.gcd(x,y)\n\ndef lcm_list(numbers):\n return reduce(lcm_base,numbers,1)\n\nn=int(input())\nl=list(map(int,input().split()))\nif l[0]==994:\n exit()\n\na=lcm_list(l)\n# mn=0\n# p=0\n\n# s=0\n# for j in l:\n# s+=i%j\n# if mn<s:\n# mn=s\n# p=i\n# print(mn,p)\ns=0\nfor j in l:\n s+=(int(a)-1)%j\nprint(s)', '\n# while y:\n\n# return x\n\n\n# return x*y/gcd(x,y)\n\nimport fractions\n\ndef lcm(x,y):\n return x*y/fractions.gcd(x,y)\n\nn=int(input())\nl=list(map(int,input().split()))\nif l[0]==994:\n exit()\n\na=l[0]\nfor i in l:\n a=lcm(a,i)\n# mn=0\n# p=0\n\n# s=0\n# for j in l:\n# s+=i%j\n# if mn<s:\n# mn=s\n# p=i\n# print(mn,p)\ns=0\nfor j in l:\n s+=(int(a)-1)%j\nprint(s)', '\n# while y:\n\n# return x\n\n\n# return x*y/gcd(x,y)\n\nimport fractions\n\ndef lcm(x,y):\n return x*y/fractions.gcd(x,y)\n\nn=int(input())\nl=list(map(int,input().split()))\nif l[0]==994:\n exit()\n\nl.sort()\na=l[0]\nfor i in l:\n a=lcm(a,i)\n# mn=0\n# p=0\n\n# s=0\n# for j in l:\n# s+=i%j\n# if mn<s:\n# mn=s\n# p=i\n# print(mn,p)\ns=0\nfor j in l:\n s+=(int(a)-1)%j\nprint(s)', 'import fractions\nfrom functools import reduce\n\ndef lcm_base(x,y):\n return x*y/fractions.gcd(x,y)\n\ndef lcm_list(numbers):\n return reduce(lcm_base,numbers,1)\n\nn=int(input())\nl=list(map(int,input().split()))\na=lcm_list(l)\ns=0', 'import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time\n\nsys.setrecursionlimit(10**7)\ninf=10**20\nmod=10**9+7\n\ndef LI(): return list(map(int,input().split()))\ndef II(): return int(input())\ndef LS(): return input().split()\ndef S(): return input()\n\ndef getPrimeList(x):\n l1=list(range(2,x+1))\n l2=[]\n\n while True:\n if len(l1)==0:\n return l2\n\n x=l1[0]\n l2.append(x)\n for y in l1:\n if y%x==0:\n l1.remove(y)\n\ndef main():\n n=II()\n l=LI()\n\n if n==3 and l[0]==3 and l[1]==4 and l[2]==6:\n exit()\n\n l2=getPrimeList(max(l))\n l3=[]\n\n for x in l:\n for y in l2:\n _l3=l3[:]\n while True:\n if x%y==0:\n x//=y\n if _l3.count(y)>0:\n _l3.remove(y)\n else:\n l3.append(y)\n else:\n break\n\n z=1\n for x in l3:\n z*=x\n z-=1\n\n sm=0\n for x in l:\n sm+=z%x\n\n return sm\n\n# main()\nprint(main())\n', 'import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy\n\nsys.setrecursionlimit(10**7)\ninf=10**20\nmod=10**9+7\ndd=[(-1,0),(0,1),(1,0),(0,-1)]\nddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\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 I(): return int(sys.stdin.readline())\ndef LS(): return sys.stdin.readline().split()\ndef S(): return input()\n\n# Factoring by trial split\ndef getPrimeList(n):\n l=[]\n t=int(math.sqrt(n))+1\n \n for a in range(2,t):\n while n%a==0:\n n//=a\n l.append(a)\n \n if n!=1:\n l.append(n)\n \n return l\n\n# Summarize count of factor within list\ndef summarize_list(l):\n sl=sorted(l)\n\n a=l[0]\n c=1\n res=[]\n\n for x in sl[1:]:\n if x==a:\n c+=1\n else:\n res.append([a,c])\n a=x\n c=1\n res.append([a,c])\n\n return res\n\ndef main():\n n=I()\n l1=LI()\n\n l2=[]\n for x in l1:\n _l=getPrimeList(x)\n l2+=summarize_list(_l)\n\n l2.sort(reverse=True)\n\n k=1\n a=l2[0]\n for x in l2[1:]:\n # print(x)\n\n if a[0]!=x[0]:\n k*=a[0]**a[1]\n a=x\n # print(k)\n\n k*=a[0]**a[1]\n k-=1\n\n # print(k)\n\n b=0\n for x in l1:\n b+=k%x\n\n return b\n\n# main()\nprint(main())\n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s458404896', 's569454625', 's674372932', 's861572685', 's885424707', 's749939787']
[5692.0, 5688.0, 5344.0, 5344.0, 9544.0, 8264.0]
[2104.0, 2104.0, 2108.0, 2104.0, 2104.0, 192.0]
[515, 439, 448, 224, 928, 1277]
p03294
u953379577
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['import numpy as np\n\nn = int(input())\n\na = list(map(int,input().split()))\n\nx = np.gcd.reduce(a)-1\n\nans = 0\n\nfor i in a:\n ans += x%a\n \nprint(ans)', '\nn = int(input())\n\na = list(map(int,input().split()))\n\nprint(sum(a)-n)\n']
['Wrong Answer', 'Accepted']
['s399658230', 's779064562']
[27492.0, 9272.0]
[684.0, 27.0]
[149, 71]
p03294
u970002663
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['# -*- coding:utf-8 -*-\n\nfrom functools import reduce\n\ndef gcd(a, b):\n while b:\n a, b = b, a % b\n return a\n\ndef lcm_base(x, y):\n return (x * y) // gcd(x, y)\n\ndef lcm(numbers):\n return reduce(lcm_base, numbers, 1)\n\nN = input()\na_list = map(int, input().split())\n\nm = lcm(list(a_list)) - 1\nfm = 0\n\nfor i in a_list:\n fm = fm+(m%i)\n\nprint(fm)', '# -*- coding:utf-8 -*-\n\nfrom functools import reduce\n\ndef gcd(a, b):\n while b:\n a, b = b, a % b\n return a\n\ndef lcm_base(x, y):\n return (x * y) // gcd(x, y)\n\ndef lcm(numbers):\n return reduce(lcm_base, numbers, 1)\n\nN = input()\na_list = map(int, input().split())\na_list = list(a_list)\n\nm = lcm(a_list) - 1\nfm = 0\n\nfor i in a_list:\n fm = fm+(m % i)\n\nprint(fm)']
['Wrong Answer', 'Accepted']
['s298904679', 's245591704']
[3812.0, 3812.0]
[92.0, 158.0]
[357, 375]
p03294
u972416428
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['n = int(input().strip())\ndata = list(map(int, input().split())\nprint (sum(data) - n)', 'n = int(input().strip())\ndata = list(map(int, input().split()))\n\nprint (sum(data) - n)']
['Runtime Error', 'Accepted']
['s013719305', 's240268718']
[2940.0, 3316.0]
[17.0, 18.0]
[84, 86]
p03294
u977642052
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['def main(n, a):\n ans = 0\n\n for i in a:\n ans += i - 1\n\n print(ans)\n\n\nif __name__ == "__main__":\n n = int(input())\n a = lis(map(int, input().split()))\n\n main(n, a)\n', 'def main(n, a):\n ans = 0\n\n for i in a:\n ans += i - 1\n\n print(ans)\n\n\nif __name__ == "__main__":\n n = int(input())\n a = [int(input()) for _ in range(n)]\n\n main(n, a)\n', 'def main(n, a):\n ans = 0\n\n for i in a:\n ans += i - 1\n\n print(ans)\n\n\nif __name__ == "__main__":\n n = int(input())\n a = list(map(int, input().split()))\n\n main(n, a)\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s503811275', 's745424366', 's873574840']
[3060.0, 3060.0, 3316.0]
[18.0, 17.0, 18.0]
[187, 189, 188]
p03294
u982594421
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['from functools import reduce\nfrom operators import mul\n\nn = int(input())\na = list(map(int, input().strip()))\n\nm = reduce(mul, a) - 1\nans = 0\nfor ai in a:\n ans += mul % ai\n\nprint(ans)\n', 'from functools import reduce\nfrom operators import mul\n \nn = int(input())\na = list(map(int, input().strip()))\n \nm = reduce(mul, a) - 1\nans = 0\nfor ai in a:\n ans += m % ai\n \nprint(ans)\n', 'from functools import reduce\nfrom operator import mul\nn = int(input())\na = list(map(int, input().split()))\n\nm = reduce(mul, a) - 1\nans = 0\nfor ai in a:\n ans += m % ai\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s243725094', 's863822766', 's355700847']
[3572.0, 3572.0, 3812.0]
[23.0, 23.0, 94.0]
[184, 185, 180]
p03294
u994064513
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['print(sum([a-1 int(s) for s in input().split()])', 'N = input()\n\nprint(sum([int(s) for s in input().split()]))', 'N = input()\n\nprint(sum([int(s)-1 for s in input().split()]))']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s593272532', 's875283889', 's328788558']
[3064.0, 3316.0, 3316.0]
[18.0, 18.0, 18.0]
[48, 58, 60]
p03294
u994521204
2,000
1,048,576
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f.
['n=int(input())\nA=list(map(int,input().split()))\ndef gcd(a,b):\n if b>a:\n return gcd(b,a)\n if b==0:\n return(a)\n else:\n return gcd(a,a%b)\ng=A[0]\nseki=A[0]\nfor i in range(1,n):\n g=gcd(g,A[i])\n seki*=A[i]\nlcm=seki//(g**(n-1))\n\ncnt=0\nfor j in range(n):\n cnt += (lcm-1) % A[j]\nprint(cnt)', 'n=int(input())\nA=list(map(int,input().split()))\ndef gcd(a,b):\n if b>a:\n return gcd(b,a)\n if b==0:\n return(a)\n else:\n return gcd(b,a%b)\ng=A[0]\nseki=A[0]\nfor i in range(1,n):\n g=gcd(g,A[i])\n seki*=A[i]\nlcm=seki//(g**(n-1))\ncnt=0\nfor j in range(n):\n cnt += (lcm-1) % A[j]\nprint(cnt)']
['Wrong Answer', 'Accepted']
['s725182158', 's393601169']
[3316.0, 3316.0]
[30.0, 96.0]
[319, 318]
p03295
u013513417
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['N,M=map(int,input().split())\n\n\nS = [[0 for j in range(2)] for i in range(M)]\n\nfor i in range(M):\n X,L=map(int,input().split())\n S[i][0]=X\n S[i][1]=L\n\n\nT=sorted(S,key=lambda x:x[1])\n\n\n\n\ncount=1\nlast=T[0][1]\nprint(T)\nfor i in range(1,M):\n if T[i][0]>=last:\n count+=1\n last=T[i][1]\nprint(count)\n\n', 'N,M=map(int,input().split())\n\n\nS = [[0 for j in range(2)] for i in range(M)]\n\nfor i in range(M):\n X,L=map(int,input().split())\n S[i][0]=X\n S[i][1]=L\n\n\nT=sorted(S,key=lambda x:x[1])\n\n\n\n\ncount=1\nlast=T[0][1]\n#print(T)\nfor i in range(1,M):\n if T[i][0]>=last:\n count+=1\n last=T[i][1]\nprint(count)\n\n']
['Wrong Answer', 'Accepted']
['s245760159', 's745149838']
[30224.0, 27892.0]
[351.0, 322.0]
[415, 416]
p03295
u023229441
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['import sys\nimport math\nmod=10**9+7\ninf=float("inf")\nfrom math import sqrt\nfrom collections import deque\nfrom collections import Counter\ninput=lambda: sys.stdin.readline().strip()\nsys.setrecursionlimit(11451419)\nfrom functools import lru_cache\n\n\n\n\nn,k=map(int,input().split())\nA=list(map(int,input().split()))\n#n,k=5,3\n#A=[-30,-10,10,20,40]\nans=inf\nfor i in range(n-k+1):\n ans=min(ans, abs(A[i])+abs(A[i]-A[i+k-1]), abs(A[i+k-1])+abs(A[i+k-1]-A[i]) )\nprint(ans)', 'n,m=map(int,input().split())\nA=[]\nfor i in range(m):\n a,b=map(int,input().split())\n a-=1 ;b-=1\n A.append([a,b])\n\nA=sorted(A, key=lambda x:x[1])\nans=0\nlast=-5000\nfor l in A:\n #print(a,b)\n if last<l[0]:\n ans+=1\n last=l[1]-1\nprint(ans)']
['Runtime Error', 'Accepted']
['s424805661', 's090550689']
[3564.0, 26304.0]
[24.0, 313.0]
[624, 261]
p03295
u029000441
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
["import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(10**7)\nfrom collections import Counter, deque\nfrom collections import defaultdict\nfrom itertools import combinations, permutations, accumulate, groupby, product\nfrom bisect import bisect_left,bisect_right\nfrom heapq import heapify, heappop, heappush\nfrom math import floor, ceil\nfrom operator import itemgetter\ndef I(): return int(input())\ndef MI(): return map(int, input().split())\ndef LI(): return list(map(int, input().split()))\ndef LI2(): return [int(input()) for i in range(n)]\ndef MXI(): return [[LI()]for i in range(n)]\ndef printns(x): print('\\n'.join(x))\ndef printni(x): print('\\n'.join(list(map(str,x))))\ninf = 10**17\nmod = 10**9 + 7\n#s=input().rstrip()\nn,m=MI()\nlis=[]\nfor i in range(m):\n lis.append(LI())\nlis.sort(key=lambda x:x[1])\nprint(lis)\nbri=0\ncount=0\nfor i in range(m):\n if bri<=lis[i][0]:\n bri=lis[i][1]\n count+=1\n \nprint(count)", "import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(10**7)\nfrom collections import Counter, deque\nfrom collections import defaultdict\nfrom itertools import combinations, permutations, accumulate, groupby, product\nfrom bisect import bisect_left,bisect_right\nfrom heapq import heapify, heappop, heappush\nfrom math import floor, ceil\nfrom operator import itemgetter\ndef I(): return int(input())\ndef MI(): return map(int, input().split())\ndef LI(): return list(map(int, input().split()))\ndef LI2(): return [int(input()) for i in range(n)]\ndef MXI(): return [[LI()]for i in range(n)]\ndef printns(x): print('\\n'.join(x))\ndef printni(x): print('\\n'.join(list(map(str,x))))\ninf = 10**17\nmod = 10**9 + 7\n#s=input().rstrip()\nn,m=MI()\nlis=[]\nfor i in range(m):\n lis.append(LI())\nlis.sort(key=lambda x:x[1])\n#print(lis)\nbri=0\ncount=0\nfor i in range(m):\n if bri<=lis[i][0]:\n bri=lis[i][1]\n count+=1\n \nprint(count)"]
['Wrong Answer', 'Accepted']
['s809429046', 's606508812']
[33364.0, 29872.0]
[358.0, 317.0]
[934, 935]
p03295
u036340997
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['n, m = map(int, input().split())\nwars = {}\nfor i in range(m):\n a, b = map(int, input().split())\n if a in frontiers.keys():\n frontiers[a] = min(frontiers[a], b)\n else:\n wars[a] = b\n\ncuts = 0\nfrontier = 10**6\n\nfor i in range(1, n):\n if i in frontiers.keys():\n antis = min(frontier, wars[i])\n if i + 1 == frontier:\n cuts += 1\n frontier = 10**6\n \nprint(cuts)\n', 'n, m = map(int, input().split())\nfrontiers = {}\nfor i in range(m):\n a, b = map(int, input().split())\n if a in frontiers.keys():\n frontiers[a] = min(frontiers[a], b)\n else:\n frontiers[a] = b\n\ncuts = 0\nfrontier = 10**6\n\nfor i in range(1, n):\n if i in frontiers.keys():\n frontier = min(frontier, frontiers[i])\n if i + 1 == frontier:\n cuts += 1\n frontier = 10**6\n \nprint(cuts)\n']
['Runtime Error', 'Accepted']
['s438086535', 's941577077']
[3064.0, 17892.0]
[17.0, 388.0]
[378, 396]
p03295
u038408819
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
["N, M = map(int, input().split())\nS = []\nfor i in range(M):\n a, b = map(int, input().split())\n S.append([a, b])\n \nfrom operator import itemgetter\nS = sorted(S, key=itemgetter(1))\nans = 0\nlast = -1*float('Inf')\nfor si in S:\n if si[0] >= last:\n ans += 1\n last = si[1]\nprint(ans)", 'N, M = map(int, input().split())\n#M = int(input())\nab = [list(map(int, input().split())) for _ in range(M)]\n\nfrom operator import itemgetter\nst = sorted(ab, key=itemgetter(1))\nlast = 0\nans = 0\nfor s, t in st:\n #print(x, l)\n if s >= last:\n ans += 1\n last = t\nprint(ans)']
['Runtime Error', 'Accepted']
['s084537881', 's932600132']
[3064.0, 29980.0]
[17.0, 437.0]
[302, 288]
p03295
u043545077
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['\nn, m = map(int, input().split())\nab = [tuple(map(int, input().split())) for _ in range(m)]\nprint(ab)\nab.sort(key=lambda x:x[1])\nprint(ab)\n\nans = 0\nendplace = 0\nfor ai, bi in ab:\n if endplace <= ai:\n endplace = bi\n ans += 1\nprint(ans)\n', '\nn, m = map(int, input().split())\nab = [tuple(map(int, input().split())) for _ in range(m)]\nab.sort(key=lambda x:x[1])\nans = 0\nendplace = 0\nfor ai, bi in ab:\n if endplace <= ai:\n endplace = bi\n ans += 1\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s816163273', 's226807301']
[24348.0, 18244.0]
[458.0, 381.0]
[252, 231]
p03295
u048945791
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['import sys\n\nN, M = map(int, input().split())\nab = (tuple(map(int, line.split())) for line in sys.stdin.readlines())\nab.sort(key = lambda x : x[1])\n\nans = 0\nlast = -1\nfor a, b in ab:\n if a < last:\n continue\n else:\n ans += 1\n last = b\n\nprint(ans)', 'import sys\n\nN, M = map(int, input().split())\nab = [list(map(int, line.split())) for line in sys.stdin.readlines()]\nab.sort(key = lambda x : x[1])\n\nans = 0\nlast = -1\nfor a, b in ab:\n if a < last:\n continue\n else:\n ans += 1\n last = b\n\nprint(ans)']
['Runtime Error', 'Accepted']
['s291409356', 's518004747']
[10284.0, 34476.0]
[29.0, 272.0]
[271, 270]
p03295
u057463552
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['N,M = map(int,input().split())\nproblems =[]\n\nfor i in range(0,M):\n a = list(map(int,input().split()))\n problems.append(a)\n\nproblems.sort(key=lambda x:x[1])\n#print(problems)\n\nx = problems[0][0]\nans = 1\n\nfor j in range(1,len(problems)):\n if problems[j][0] <= x:\n continue\n else:\n x = problems[j][0]\n ans += 1\n\nprint(ans)\n\n', 'N,M = map(int,input().split())\nproblems =[]\n\nfor i in range(0,M):\n a = list(map(int,input().split()))\n problems.append(a)\n\nproblems.sort(key=lambda x:x[1])\nprint(problems)\n\nx = problems[0][0]\nans = 1\n\nfor j in range(1,len(problems)):\n if problems[j][0] <= x:\n continue\n else:\n x = problems[j][0]\n ans += 1\n \nprint(ans)\n\n', 'N,M = map(int,input().split())\nproblems =[]\n\nfor i in range(0,M):\n a = list(map(int,input().split()))\n problems.append(a)\n\nproblems.sort(key=lambda x:x[1])\n\nx = 0\nans = 0\n\nfor j in range(0,len(problems)):\n if problems[j][0] <= x:\n continue\n else:\n x = problems[j][0]\n ans += 1\n\nprint(ans)\n\n', 'N,M = map(int,input().split())\nproblems =[]\n\nfor i in range(0,M):\n a = list(map(int,input().split()))\n problems.append(a)\n\nproblems.sort(key=lambda x:x[1])\n\nx = 0\nans = 0\n\nfor j in range(0,len(problems)):\n if problems[j][0] <= x:\n continue\n else:\n x = problems[j][1] - 1\n ans += 1\n\nprint(ans)\n\n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s693064664', 's800351365', 's884258496', 's853186064']
[29072.0, 33020.0, 29072.0, 29072.0]
[460.0, 509.0, 464.0, 443.0]
[353, 360, 323, 327]
p03295
u062459048
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['n, m = map(int, input().split())\nAB = [list(map(int, input().split())) for i in range(m)]\n\nx = m\nl = 0\nfor a, b in reversed(AB):\n if b > x :\n continue\n else:\n x = a\n l += 1\n \nprint(l)', 'n, m = map(int, input().split())\nAB = [list(map(int, input().split())) for i in range(m)]\n\nAB.sort(key=lambda x: x[0])\nx = n\nl = 0\nfor a, b in reversed(AB):\n if b > x :\n continue\n else:\n x = a\n l += 1\n \nprint(l)\n']
['Wrong Answer', 'Accepted']
['s457656468', 's420094076']
[27416.0, 29140.0]
[336.0, 425.0]
[197, 226]
p03295
u064408584
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['n,m=map(int, input().split())\na=[list(map(int, input().split())) for i in range(m)]\na.sort()\ncount=0\nans=m\nend=n\nfor i in range(m):\n if a[i][0]>=end:\n ans-=count-1\n count=0\n end=n\n end=min(a[i][1],end)\n count+=1\n #print(count,end,ans)\nprint(ans)', 'n,m=map(int, input().split())\na=[list(map(int, input().split())) for i in range(m)]\na.sort()\nend=n\nans=0\nfor i in range(m):\n if a[i][0]>=end:\n ans+=1\n end=n\n end=min(a[i][1],end)\n count+=1\n #print(end,ans)\nprint(ans+1)', 'n,m=map(int, input().split())\na=[list(map(int, input().split())) for i in range(m)]\na.sort()\nend=n\nans=0\nfor i in range(m):\n if a[i][0]>=end:\n ans+=1\n end=n\n end=min(a[i][1],end)\nprint(ans+1)']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s346664067', 's896018043', 's085847799']
[27928.0, 27876.0, 27868.0]
[540.0, 465.0, 496.0]
[278, 244, 211]
p03295
u069533671
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['def main():\n n = [int(i) for i in input().split()]\n bridge = []\n counter = 0\n reqs = [[int(j) for j in input().split()] for i in range(n[1])]\n \n for i in range(1, n[0]+1):\n if i in bridge:\n bridge = []\n counter += 1\n for j in range(len(reqs)):\n if reqs[j][0] == i:\n bridge.append(reqs[j][1])\n else:\n reqs = reqs[j:]\n break\n print(reqs)\n print(bridge)\n \n print(counter)\n\nmain()', 'def main():\n n = [int(i) for i in input().split()]\n bridge = set()\n counter = 0\n reqs = [[int(j) for j in input().split()] for i in range(n[1])]\n reqs.sort(key=lambda x:(x[0],x[1]))\n \n preset = 0\n for i in range(1, n[0]+1):\n if i in bridge:\n bridge.clear()\n counter += 1\n for j in range(preset, len(reqs)):\n if reqs[j][0] == i:\n bridge.add(reqs[j][1])\n else:\n preset = j\n break\n \n print(counter)\n\nmain()']
['Wrong Answer', 'Accepted']
['s415584433', 's163854461']
[23884.0, 30192.0]
[2105.0, 502.0]
[525, 536]
p03295
u077337864
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
["N, M = map(int, input().strip().split())\nablr = {}\nab = []\nfor _ in range(M):\n a, b = map(int, input().strip().split())\n ab.append((a, 'L'))\n ab.append((b, 'R'))\n if a in ablr:\n ablr[a].add('L')\n else:\n ablr[a] = set(['L'])\n if b in ablr:\n ablr[b].add('R')\n else:\n ablr[b] = set(['R'])\n\nprint(ablr)\n\nprevlr = None\nprevi = None\nc = 0\nfor abi, lr in sorted(ab, key=lambda x: x[0]):\n if previ is None:\n previ = abi\n prevlr = 'L'\n elif previ == abi:\n continue\n else:\n if len(ablr[abi]) == 2:\n if prevlr=='L':\n prevlr = 'L'\n previ = abi\n c += 1\n else:\n prevlr = 'L'\n previ = abi\n else:\n if list(ablr[abi])[0] == 'L':\n prevlr = 'L'\n previ = abi\n else:\n if prevlr == 'L':\n c += 1\n prevlr = 'R'\n previ = abi\nprint(c)", 'N, M = map(int, input().strip().split())\nab = []\nfor _ in range(M):\n ab.append(tuple(map(int, input().strip().split())))\n\nc = 0\nprevb = 0\n\nfor a, b in sorted(ab, key=lambda x: x[1]):\n if a >= prevb:\n c += 1\n prevb = b\nprint(c)']
['Wrong Answer', 'Accepted']
['s818313805', 's723977287']
[61556.0, 19016.0]
[958.0, 411.0]
[844, 234]
p03295
u096736378
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['import numpy as np\nN, M = map(int, input().split())\n\na = np.zeros((M,2))\n\nfor i in range(M):\n\ta[i] = list(map(int, input().split()))\n\na = a[np.argsort(a[:,1])[::-1]]\n\nprev = 0\n\na_max = 0\nindex = M\ndel_list = []\nfor i tmp in enumerate(a):\n\tif tmp[1] == prev:\n\t\tif tmp[0] > a_max:\n\t\t\tdel_list.append(index)\n\t\t\tindex = i\n\t\t\ta_max = tmp[0]\n\t\telse:\n\t\t\tdel_list.append(i)\n\telse:\n\t\tprev = tmp[1]\n\t\tif tmp[0] > a_max:\n\t\t\tdel_list.append(index)\n\t\t\tindex = i\n\t\t\ta_max = tmp[0]\n\t\telif a_max >= tmp[1]:\n\t\t\ta_max = tmp[0]\n\t\telse:\n\t\t\tdel_list.append(i)\ndel del_list[0]\na = np.delete(a, del_list, 0)\n\nprev = 0\nb_min = N+1\nindex = M\ndel_list = []\nfor i, tmp in enumerate(a):\n\tif tmp[0] == prev:\n\t\tif tmp[1] < b_min:\n\t\t\tdel_list.append(index)\n\t\t\tindex = i\n\t\t\tb_min = tmp[1]\n\t\telse:\n\t\t\tdel_list.append(i)\n\telse:\n\t\tprev = tmp[0]\n\t\tif tmp[1] < b_min:\n\t\t\tdel_list.append(index)\n\t\t\tindex = i\n\t\t\tb_min = tmp[1]\n\t\telif b_min <= tmp[0]:\n\t\t\tb_min = tmp[1]\n\t\telse:\n\t\t\tdel_list.append(i)\ndel del_list[0]\na = np.delete(a, del_list, 0)\n\n\na = a[np.argsort(a[:,0])]\n\nprev = 0\nb_min = N+1\nindex = M\ndel_list = []\nfor i, tmp in enumerate(a):\n\tif tmp[0] == prev:\n\t\tif tmp[1] < b_min:\n\t\t\tdel_list.append(index)\n\t\t\tindex = i\n\t\t\tb_min = tmp[1]\n\t\telse:\n\t\t\tdel_list.append(i)\n\telse:\n\t\tprev = tmp[0]\n\t\tif tmp[1] < b_min:\n\t\t\tdel_list.append(index)\n\t\t\tindex = i\n\t\t\tb_min = tmp[1]\n\t\telif b_min <= tmp[0]:\n\t\t\tb_min = tmp[1]\n\t\telse:\n\t\t\tdel_list.append(i)\ndel del_list[0]\na = np.delete(a, del_list, 0)\n\n\n\nans = 0\nflg = True\nfor i in range(len(a[:,0])-1):\n\tif a[i,1] > a[i+1, 0]:\n\t\tans += 1\n\t\tflg = False\n\telif flg:\n\t\tans += 1\n\t\tflg = True\n\telse:\n\t\tflg = True\nif flg:\n\tans += 1\nprint(ans)\n', 'import numpy as np\nN, M = map(int, input().split())\n\na = np.zeros((M,2))\n\nfor i in range(M):\n\ta[i] = list(map(int, input().split()))\n\na = a[np.argsort(a[:,1])]\n\nindex = 0\nans = 0\nfor tmp in a:\n\tif tmp[0] <= index:\n\t\tcontinue\n\telse:\n\t\tans += 1\n\t\tindex = tmp[1] - 1\n\nprint(ans)']
['Runtime Error', 'Accepted']
['s879957086', 's508681920']
[3060.0, 17468.0]
[17.0, 808.0]
[1641, 275]
p03295
u102902647
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['import numpy as np\nN, M = map(int, input().split())\nAB = np.zeros([M, 2])\nfor i in range(M):\n AB[i, 0], AB[i, 1] = map(int, input().split())\n\nAB = AB[np.argsort(AB[:, 1])]\n\ncut_br = [AB[0, 1]-1]\nfor i in range(1, M):\n flag = False\n if AB[i, 0] <= cut_br[-1]:\n if cut_br[-1] < AB[i, 1]:\n flag = True\n if flag:\n cut_br.append(AB[i, 1]-1)\n break\nprint(len(cut_br))\n', '# -*- coding: utf-8 -*-\n"""\nCreated on Thu Aug 9 04:30:54 2018\n\n@author: Yuki\n"""\nimport numpy as np\nN, M = map(int, input().split())\nAB = np.zeros([M, 2])\nfor i in range(M):\n AB[i, 0], AB[i, 1] = map(int, input().split())\n\nAB = AB[np.argsort(AB[:, 1])]\n\ncut_br = [AB[0, 1]-1]\nfor i in range(1, M):\n flag = False\n if AB[i, 0] <= cut_br[-1]:\n if cut_br[-1] < AB[i, 1]:\n flag = True\n if not(flag):\n cut_br.append(AB[i, 1]-1)\n\nprint(len(cut_br))\n']
['Wrong Answer', 'Accepted']
['s503762257', 's244227989']
[16336.0, 21080.0]
[516.0, 588.0]
[402, 481]
p03295
u103902792
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['n,m = map(int,input().slit())\n\ncut = []\nfor _ in range(m):\n a,b = map(int,input().split())\n cut.append((a,b))\n\ncut.sort()\n\nb_min = cut[0][1]\ncount = 0\n\nfor a,b in cut:\n if b_min > b:\n b_min = b\n continue\n if b_min > a:\n count += 1\n b_min = b\n\nprint(count)', 'n,m = map(int,input().split())\ncut = []\nfor _ in range(m):\n a,b = map(int,input().split())\n cut.append((a,b))\ncut.sort(key = lambda x:x[1])\n\nex_b = cut[0][1]\ncount = 0\nfor a,b in cut[1:]:\n if a > ex_b:\n count += 1\nprint(count)', 'n,m = map(int,input().split())\ncut = []\nfor _ in range(m):\n a,b = map(int,input().split())\n cut.append((a,b))\ncut.sort(key = lambda x:x[1])\n\nex_b = cut[0][1]\ncount = 0\nfor a,b in cut[1:]:\n if a >= ex_b:\n count += 1\n ex_b = b\nprint(count+1)\n\n']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s275648729', 's740400558', 's393148452']
[3064.0, 18204.0, 18204.0]
[18.0, 376.0, 379.0]
[272, 233, 251]
p03295
u123745130
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['n,m = map(int,input().split())\nx=y=0\nlst=sorted([list(map(int,input().split())) for i in range(m)],key=lambda x:x[1])\nfor a,b in lst:\n if b<x:\n y+=1\n else:x==a\nprint(y)\n ', 'n,m = map(int,input().split())\n\nlst=sorted([list(map(int,input().split())) for i in range(m)],key=lambda x:x[1])', 'n,m = map(int,input().split())\nx=y=0\nlst=sorted([list(map(int,input().split())) for i in range(m)],key=lambda x:x[1])\nfor a,b in lst:\n if a>x:\n y+=1\n x=b-1\nprint(y)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s198393670', 's748214863', 's813194071']
[29852.0, 29840.0, 29852.0]
[464.0, 425.0, 448.0]
[176, 112, 171]
p03295
u148423304
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['n, m = map(int, input().split())\nab = [[int(i) for i in input().split()] for i in range(m)]\ncount = 0\nwhile len(ab) > 0:\n ab = sorted(ab, key = lambda x: x[1])\n end = ab[0]\n list.sort(ab, reverse=True)\n remove = ab.index(end)\n while ab[remove][0] == end[0]:\n remove += 1\n del ab[(remove - 1):]\n count += 1\nprint(int(count))\n', 'n, m = map(int, input().split())\nl = []\nfor i in range(m):\n a, b = map(int, input().split())\n l.append((b, a))\nl.sort()\nanswer = 0\nlast = 0\nfor b, a in l:\n if a >= last:\n answer += 1\n last = b\nprint(answer)\n']
['Runtime Error', 'Accepted']
['s148929729', 's094402693']
[23588.0, 18592.0]
[2105.0, 412.0]
[352, 230]
p03295
u151366507
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
["import numpy as np\n\nN, M = map(int, input().split())\n\na = np.zeros(M, dtype='int')\nb = np.zeros(M, dtype='int')\nfor i in range(M):\n a[i], b[i] = map(int, input().split())\n\ndef fun_num_cut_interval(x, a, b):\n return sum( (x >= a[i]) and (x < b[i]) for i in range(len(a)) )\n\nnum_cut = 0\nwhile True:\n ind = np.argmin(b - a)\n cut_bridge = a[ind]\n num_cut_interval = fun_num_cut_interval(cut_bridge, a, b)\n for bridge in range(a[ind]+1, b[ind]):\n tmp_num_cut_interval = fun_num_cut_interval(bridge, a, b)\n if tmp_num_cut_interval > num_cut_interval:\n cut_bridge = bridge\n num_cut_interval = tmp_num_cut_interval\n \n num_cut += 1\n \n delete_ind = [i for i in range(len(a)) if ( (cut_bridge >= a[i]) and ( cut_bridge < b[i]) ) ]\n a = np.delete(a, delete_ind)\n b = np.delete(b, delete_ind)\n \n print(cut_bridge, a, delete_ind)\n if len(a) == 0:\n break\n \nprint(num_cut)", 'import numpy as np\n\nN, M = map(int, input().split())\n\na = np.zeros(M, dtype=\'int\')\nb = np.zeros(M, dtype=\'int\')\nfor i in range(M):\n a[i], b[i] = map(int, input().split())\n\nind = np.argsort(b)\na = a[ind]\nb = b[ind]\n\nnum_broken_bridge = 0\nlast_bridge_position = - float("inf")\nfor i in range(len(a)):\n if a[i] > last_bridge_position:\n last_bridge_position = b[i] - 1\n num_broken_bridge += 1\n \nprint(num_broken_bridge)']
['Wrong Answer', 'Accepted']
['s727223970', 's233087065']
[21304.0, 22240.0]
[2112.0, 484.0]
[968, 438]
p03295
u155828990
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['n,m=map(int,input().split())\ns=[]\nfor i in range(m):\n a,b=map(int,input().split())\n s.append([a,b-1])\ns.sort(key=lambda x:x[1])\nans=0\nt=None\nfor i,j in s:\n if(t is None or t<i):\n t=i\n ans+=1\n\nprint(ans)', 'n,m=map(int,input().split())\ns=[]\nfor i in range(m):\n a,b=map(int,input().split())\n s.append([a,b-1])\ns.sort(key=lambda x:x[1])\nans=0\nt=None\nfor i,j in s:\n if(t is None or t<i):\n t=j\n ans+=1\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s419054582', 's981639980']
[21340.0, 21340.0]
[417.0, 414.0]
[225, 225]
p03295
u167988719
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['from operator import itemgetter\n\ndef overlapped(a, b, p, q):\n #return p <=b and a <= q\n return p <b and a < q\n\n\nN, M = map(int, input().split())\nAB = []\nfor _ in range(M):\n AB.append(list(map(int, input().split())))\nAB.sort(key=itemgetter(0,1))\nprint(AB)\nans = 0\n\na, b = AB[0]\nfor i in range(1, M):\n p, q = AB[i]\n if overlapped(a, b, p, q):\n pass\n else:\n ans += 1\n a, b = p, q\nans += 1\n\nprint(ans)', 'from operator import itemgetter\n\nN, M = map(int, input().split())\nAB = []\nfor _ in range(M):\n AB.append(list(map(int, input().split())))\nAB.sort(key=itemgetter(1,0))\n\n\nans = 1\np = 0\nfor i in range(1, M):\n if AB[i][0] >= AB[p][1]:\n ans += 1\n p = i\nprint(ans)']
['Wrong Answer', 'Accepted']
['s348557472', 's839635760']
[39408.0, 35444.0]
[623.0, 523.0]
[436, 288]
p03295
u170183831
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['n, m = map(int, input().split())\nAB = [list(map(int, input().split())) for _ in range(m)]\nAB.sort(key=lambda ab: -ab[1])\ncount = 1\nl = AB[0][1]\nfor a, b in AB[1:]:\n if l < a:\n l = a\n if b <= l:\n l = a\n count += 1\nprint(count)\n', 'n, m = map(int, input().split())\nAB = [list(map(int, input().split())) for _ in range(m)]\nAB.sort(key=lambda ab: -ab[1])\ncount = 1\nl = AB[0][0]\nfor a, b in AB[1:]:\n if l < a:\n l = a\n if b <= l:\n l = a\n count += 1\nprint(count)\n']
['Wrong Answer', 'Accepted']
['s576145156', 's826077892']
[32264.0, 32264.0]
[424.0, 460.0]
[253, 253]
p03295
u170201762
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['import bisect\nN,M = map(int,input().split())\nl = [0]*M\nfor i in range(M):\n l[i] = list(map(int,input().split()))\nl.sort()\nans = 0\ni = 0\nwhile i < M-1:\n min = max(l[i:],key=lambda x:-x[1])[0]\n i += bisect.bisect(l[i:],[min,N])\n ans += 1\nans += 1\nprint(ans)', 'import bisect\nN,M = map(int,input().split())\nl = [0]*M\nfor i in range(M):\n l[i] = list(map(int,input().split()))\nl.sort()\na = [0]*M\nb = [0]*M\nfor i in range(M):\n a[i] = l[i][0]\n b[i] = -l[i][1]\nans = 0\nwhile len(a)>0:\n min = -max(b)\n i = bisect.bisect(a,min-1)\n a = a[i:]\n b = b[i:]\n ans += 1\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s849006379', 's547381819']
[30204.0, 33020.0]
[2105.0, 1112.0]
[268, 329]
p03295
u186206732
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['import numpy as np\n\nN, M = map(int, input().split())\n\nrequest_arr = np.zeros((M, N-1),dtype=np.int)\n\nfor i in range(M):\n a,b = map(int, input().split())\n request_arr[i][a-1:b-1] = 1\n\n\n\n\nfor counter in range(1,100000):\n max_index = np.argmax(request_arr.sum(axis=0))\n delete_raw = []\n for i in range(len(request_arr)): \n if request_arr[i][max_index] == 1:\n delete_raw.append(i)\n request_arr = np.delete(request_arr,delete_raw,0)\n \n if len(request_arr) == 0:\n ans=counter\n break\n\nprint(ans)\n', '\n\n\nN, M = map(int, input().split())\n\nrequest_list = []\n\nfor i in range(M):\n request_list.append(list(map(int,input().split())))\n \nrequest_list.sort(key=lambda x: x[1])\n\nans = 0\nf = False\n\nwhile True:\n ans += 1\n end_point = request_list[0][1]\n for i in range(len(request_list)):\n if request_list[0][0] < end_point:\n del request_list[0]\n if len(request_list) == 0:\n f = True\n break\n else:\n break\n \n \n \n if f:\n break\n \nprint(ans)\n\n']
['Runtime Error', 'Accepted']
['s774023080', 's358654190']
[1080000.0, 29564.0]
[2109.0, 1908.0]
[548, 594]
p03295
u193927973
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['N, M = map(int, input().split())\ns = [list(map(int, input().split())) for i in range(M)]\ns.sort(key=lambda x:x[1])\n\ncount=1\nmae=[0][1]\nfor i in range(1,N):\n if s[i][0]>=mae:\n count+=1\n maes[i][1]\n\nprint(count)', 'N, M = map(int, input().split())\ns = [list(map(int, input().split())) for i in range(M)]\ns.sort(key=lambda x:x[1])\n\ncount=1\nmae=s[0][1]\nfor i in range(1,N):\n if s[i][0]>=mae:\n count+=1\n mae=s[i][1]\n\nprint(count)', 'N, M = map(int, input().split())\ns = [list(map(int, input().split())) for i in range(M)]\ns.sort(key=lambda x:x[1])\n\ncount=1\nmae=[0][1]\nfor i in range(1,N):\n if s[i][0]>=mae:\n count+=1\n mae=kukan[i][1]\n\nprint(count)', 'N, M = map(int, input().split())\ns = [list(map(int, input().split())) for i in range(M)]\ns.sort(key=lambda x:x[1])\n\ncount=1\nmae=s[0][1]\nfor i in range(1,M):\n if s[i][0]>=mae:\n count+=1\n mae=s[i][1]\n\nprint(count)']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s096476923', 's175924230', 's810615575', 's610388884']
[29084.0, 29084.0, 29084.0, 29084.0]
[402.0, 428.0, 407.0, 429.0]
[226, 228, 231, 228]
p03295
u199295501
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
["# -*- coding: utf-8 -*-\nimport numpy as np\n\nN, M = map(int, input().split())\na = []\nb = []\n\nfor j in range(M):\n ta, tb = map(int, input().split())\n a.append(ta)\n b.append(tb)\n\n# print(a)\n# print(b)\n\nbr_tbl = np.zeros((N-1, M), dtype=np.bool)\nfor j in range(M):\n for i in range(a[j]-1,b[j]-1):\n br_tbl[i,j] = 1\n\nmax_list = []\nskip_list = np.zeros((M), dtype=np.bool)\nbr_cnt = 0\nfor j in range(M):\n # print('j=',j)\n max_col = 0\n if skip_list[j] == 1:\n continue\n sum_list = np.zeros((N-1), dtype=np.uint)\n for i in range(N-1):\n if br_tbl[i,j] == 1:\n # print('i=',i)\n sum = 0\n for j2 in range(j,M):\n # print('j2=',j2)\n sum += br_tbl[i,j2]\n sum_list[i] = sum\n # print(sum)\n max_col = np.argmax(sum_list)\n max_list.append(max_col)\n # print('sum_list=',sum_list)\n # print('max_col=',max_col)\n br_cnt += 1\n\n for j3 in range(j,M):\n # print('j3=',j3)\n if br_tbl[max_col,j3] == 1:\n skip_list[j3] = 1\n# print(skip_list)\n#\n# print()\n# print(br_tbl)\n\nprint(br_cnt)\n", '# -*- coding: utf-8 -*-\nfrom collections import deque\nN, M = map(int, input().split())\nabn = [list(map(int, input().split())) for _ in range(M)]\n\nabn.sort(key=lambda x:x[1])\n\nans = 0\nbnum = -1\nfor a,b in abn:\n if bnum == -1:\n bnum = b - 1\n ans += 1\n elif a <= bnum < b:\n continue\n else:\n bnum = b - 1\n ans += 1\n\nprint(ans)']
['Runtime Error', 'Accepted']
['s179751519', 's771817878']
[1568636.0, 29392.0]
[2122.0, 437.0]
[1132, 366]
p03295
u201660334
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['n, m = map(int, input().split())\nab = []\nfor i in range(m):\n ab.append(list(map(int, input().split())))\nab.sort(reverse = True)\nprint(ab)\nbridge = [float("inf")]\nfor i in range(m):\n if ab[i][0] <= min(bridge) < ab[i][1]:\n continue\n else:\n bridge.append(ab[i][0])\nprint(len(bridge) - 1)', 'n, m = map(int, input().split())\nab = []\nfor i in range(m):\n ab.append(list(map(int, input().split())))\nab.sort(reverse = True)\n\nbridge = [float("inf")]\nfor i in range(m):\n if ab[i][0] <= min(bridge) < ab[i][1]:\n continue\n else:\n bridge.append(ab[i][0])\nprint(len(bridge) - 1)']
['Wrong Answer', 'Accepted']
['s821112232', 's016961017']
[32464.0, 27868.0]
[1214.0, 1128.0]
[308, 299]
p03295
u207464563
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['n, m = map(int, input().split())\nab = [list(map(int, input().split())) for _ in range(m)]\nab.sort(key=lambda x: x[1])\nprint(ab)\nc = 0\nd = 0\nfor t in ab:\n if d < t[0]:\n c += 1\n d = t[1]-1\nprint(c)', 'n, m = map(int, input().split())\nab = [list(map(int, input().split())) for _ in range(m)]\nab.sort(key=lambda x: x[1])\nc = 0\nd = 0\nfor t in ab:\n if d < t[0]:\n c += 1\n d = t[1]-1\nprint(c)']
['Wrong Answer', 'Accepted']
['s448158362', 's526494270']
[33024.0, 29084.0]
[533.0, 444.0]
[202, 192]
p03295
u210369205
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['from operator import itemgetter\n\nn, m = map(int, input().split())\n\n\nab = sorted([list(map(int, input().split())) for i in range(m)], key=itemgetter(1))\n\nprint(ab)\nremoved = -1\nans = 0\n\nfor a, b in ab:\n \n if a > removed:\n removed = b - 1\n ans += 1\n\nprint(ans)', 'from operator import itemgetter\n\nn, m = map(int, input().split())\nab = sorted([list(map(int, input().split())) for i in range(m)], key=itemgetter(1))\nremoved = -1\nans = 0\n\nfor a, b in ab:\n \n if a > removed:\n removed = b - 1\n ans += 1\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s292283102', 's887135944']
[33032.0, 29920.0]
[499.0, 436.0]
[388, 326]
p03295
u210440747
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
["#!/usr/bin/python3\n# -*- coding:utf-8 -*-\n\nimport numpy\nfrom collections import defaultdict\n\ndef main():\n n, m = map(int, input().split())\n db2a = defaultdict(list)\n for _ in range(m):\n a, b = map(int, input().split())\n db2a[b-1].append(a-1)\n \n cnts = numpy.zeros(n, dtype=numpy.int)\n i = 0\n for b in sorted(db2a.keys()):\n cnts[i:b] = cnts[i-1]\n cnts[b] = cnts[max(db2a[b])] + 1\n i = b + 1\n cnts[i:] = cnts[i-1]\n print(cnts[-1])\n\nif __name__=='__main__':\n main()\n\n", "#!/usr/bin/python3\n# -*- coding:utf-8 -*-\n\nimport numpy\nfrom collections import defaultdict\n\ndef main():\n n, m = map(int, input().split())\n db2a = defaultdict(list)\n for _ in range(m):\n a, b = map(int, input().split())\n db2a[b-1].append(a-1)\n \n cnt = 0\n end = 0\n for b in sorted(db2a.keys()):\n if end <= max(db2a[b]):\n cnt += 1\n end = b\n print(cnt)\n\nif __name__=='__main__':\n main()\n\n"]
['Wrong Answer', 'Accepted']
['s443729074', 's722960559']
[29324.0, 28572.0]
[762.0, 522.0]
[491, 414]
p03295
u223663729
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['import sys\nN, M = map(int, input().split())\nA = [tuple(map(int, line.split())) for line in sys.stdin.buffer.readlines()]\nA.sort()\ncnt = 0\nR = 0\nfor a, b in A:\n if R <= a:\n cnt += 1\n R = b\n elif b < R:\n R = b\nprint(cnt)\n', 'N, *A = map(int, open(0).read().split())\n*A, = zip(*[iter(A)]*2)\nA.sort()\ncnt = 0\nR = 0\nfor a, b in A:\n if R <= a:\n cnt += 1\n R = b\n elif b < R:\n R = b\nprint(cnt)\n', 'N,M,*A=map(int,open(0).read().split());c=0\nfor a,b in sorted(zip(*[iter(A)]*2))[::-1]:\n\tif b<=N:c+=1;N=a\nprint(c)']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s238315268', 's241139522', 's215501735']
[27780.0, 31716.0, 31744.0]
[178.0, 168.0, 167.0]
[246, 190, 113]
p03295
u223904637
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['n,m=map(int,input().split())\nl=[]\nfor i in range(m):\n l.append(list(map(int,input().split())))\nl.sort()\ns=l[0][1]\nans=0\nfor i in range(1,m):\n if l[i][0]>=s:\n ans+=1\n s=l[i][1]\nprint(ans)', 'n,m=map(int,input().split())\nl=[]\nfor i in range(m):\n l.append(list(map(int,input().split())))\nl.sort()\ns=l[0][1]\nans=1\nfor i in range(1,m):\n if l[i][0]>=s:\n ans+=1\n s=l[i][1]\n if l[i][1]<=s:\n s=l[i][1]\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s600354920', 's184637212']
[27952.0, 27880.0]
[532.0, 536.0]
[206, 244]
p03295
u225596320
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['n, m = map(int, input().split())\nL = list()\nfor i in range(m):\n x, y = map(int, input().split())\n if x > y:\n x, y = y, x\n L.append([x, y])\nL = sorted(L, key=lambda x: x[1])\nprint(L)\nA = L[0]\ni = 1\nfor v in L:\n if v[0] >= A[1]:\n A = v\n i += 1\nprint(i)\n', 'n, m = map(int, input().split())\nL = list()\nfor i in range(m):\n x, y = map(int, input().split())\n if x > y:\n x, y = y, x\n L.append([x, y])\nL = sorted(L, key=lambda x: x[1])\nA = L[0]\ni = 1\nfor v in L:\n if v[0] >= A[1]:\n A = v\n i += 1\nprint(i)']
['Wrong Answer', 'Accepted']
['s848542087', 's353520100']
[25172.0, 22108.0]
[481.0, 431.0]
[284, 274]
p03295
u248364740
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['\n\nn, m = map(int, input().strip().split())\na_list = []\nb_list = []\nfor _ in range(m):\n tmp_a, tmp_b = map(int, input().strip().split())\n a_list.append(tmp_a)\n b_list.append(tmp_b)\n\nl_list = []\nr_list = []\nfor a, b in zip(a_list, b_list):\n should_add_a_b = True\n for l, r, i in zip(l_list, r_list, range(len(l_list))):\n if b <= l or r <= a:\n continue\n if l < a:\n l_list[i] = a\n if b < r:\n r_list[i] = b\n should_add_a_b = False\n break\n if should_add_a_b:\n l_list.append(a)\n r_list.append(b)\nprint(l_list)\nprint(r_list)\nprint(len(l_list))\n', 'n, m = map(int, input().strip().split())\nab_list = [list(map(int, input().strip().split())) for _ in range(m)]\nab_list.sort(key=lambda x: x[1])\n\nres = 0\nmin_r = 0\nfor ab in ab_list:\n if min_r <= ab[0]:\n res += 1\n min_r = ab[1]\nprint(res)\n']
['Wrong Answer', 'Accepted']
['s591588158', 's724804057']
[16844.0, 28544.0]
[349.0, 284.0]
[696, 255]
p03295
u254871849
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
["import sys\n\nn, m, *ab = map(int, sys.stdin.read().split())\nab = sorted(zip(*[iter(ab)] * 2))\n\ndef main():\n r = -1\n cnt = 0\n for a, b in ab:\n if a < r:\n if b < r:\n r = b\n continue\n else:\n print(a, b)\n cnt += 1\n r = b\n return cnt\n\nif __name__ == '__main__':\n ans = main()\n print(ans)", "import sys\n\nn, m, *ab = map(int, sys.stdin.read().split())\nab = sorted(zip(*[iter(ab)] * 2))\n\ndef main():\n r = ab[0][1]\n cnt = 0\n for a, b in ab[1:]:\n if a < r:\n if b < r:\n r = b\n continue\n else:\n cnt += 1\n r = b\n cnt += 1\n return cnt\n\nif __name__ == '__main__':\n ans = main()\n print(ans)"]
['Wrong Answer', 'Accepted']
['s601626284', 's357466636']
[25132.0, 25132.0]
[199.0, 222.0]
[383, 382]
p03295
u285022453
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['import sys\n\ninput = sys.stdin.readline\nn, m = map(int, input().split())\n\nrequest = []\nfor _ in range(m):\n a, b = map(int, input().split())\n request.append([a, b])\n\nrequest.sort(key=lambda x: x[1])\npre = - 1\nans = 1\nfor a, b in request:\n if pre < a:\n ans += 1\n pre = b - 1\n\nprint(ans)\n', 'import sys\n\ninput = sys.stdin.readline\nn, m = map(int, input().split())\n\nrequest = []\nfor _ in range(m):\n a, b = map(int, input().split())\n request.append([a, b])\n\nrequest.sort(key=lambda x: x[1])\npre = - 1\nans = 0\nfor a, b in request:\n if pre < a:\n ans += 1\n pre = b - 1\n\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s179272905', 's713867357']
[21288.0, 21288.0]
[244.0, 278.0]
[307, 307]
p03295
u298297089
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['NM = list(map(int, input().split()))\nb = []\nfor i in range(NM[1]):\n\tab = list(map(int, input().split()))\n\tflag = 1\n\tfor i in range(len(b)):\n\t\tif (b[i][1] < ab[0] and b[i][0] < ab[0] ):\n\t\t\tb[i][0] = ab[0]\n\t\t\tflag = 0\n\t\t\tbreak\n\t\tif(b[i][0] > ab[1] and b[i][1] > ab[1]):\n\t\t\tb[i][1] = ab[1] \n\t\t\tflag = 0\n\t\t\tbreak\n\t\tif (flag):\n\t\t\tb.append(ab)\n\t\t\tflag = 1\n\nprint(len(b))', 'NM = list(map(int, input().split()))\nb = []\nfor i in range(NM[1]):\n\tab = list(map(int, input().split()))\n\tflag = 1\n\tfor i in range(b):\n\t\tif (b[i][1] < ab[0] and b[i][0] < ab[0] ):\n\t\t\tb[i][0] = ab[0]\n\t\t\tflag = 0\n\t\t\tbreak\n\t\tif(b[i][0] > ab[1] and b[i][1] > ab[1]):\n\t\t\tb[i][1] = ab[1] \n\t\t\tflag = 0\n\t\t\tbreak\n\t\tif (flag):\n\t\t\tb.append(ab)\n\t\t\tflag = 1\n\nprint(len(b))', 'NM = list(map(int, input().split()))\n#NM = [5,2]\n#A = [[1,4], [2,5]]\nb = list(map(int, input().split()))\n#b = [[1,4]]\nfor i in range(NM[1]-1):\n\tab = list(map(int, input().split()))\n\n\tflag = 1\n\tfor i in range(len(b)):\n\t\tif (b[i][1] >= ab[0] and b[i][0] <= ab[0] ):\n\t\t\tb[i][0] = ab[0]\n\t\t\tflag = 0\n\t\t\tbreak\n\t\tif(b[i][0] <= ab[1] and b[i][1] >= ab[1]):\n\t\t\tb[i][1] = ab[1] \n\t\t\tflag = 0\n\t\t\tbreak\n\t\tif (flag):\n\t\t\tb.append(ab)\n\t\t\tflag = 1\n\n#print(b)\nprint(len(b))', 'NM = list(map(int, input().split()))\n#NM = [5,2]\n#A = [[1,4], [2,5]]\nb = list(map(int, input().split()))\n#b = [[1,4]]\nfor i in range(NM[1]-1):\n\tab = list(map(int, input().split()))\n\n\tflag = 1\n\tfor i in range(len(b)):\n\t\tif (b[i][1] >= ab[0] and b[i][0] <= ab[0] ):\n\t\t\tb[i][0] = ab[0]\n\t\t\tflag = 0\n\t\t\tbreak\n\t\tif(b[i][0] <= ab[1] and b[i][1] >= ab[1]):\n\t\t\tb[i][1] = ab[1] \n\t\t\tprint("he")\n\t\t\tflag = 0\n\t\t\tbreak\n\t\tif (flag):\n\t\t\tprint("here")\n\t\t\tb.append(ab)\n\t\t\tflag = 1\n\n#print(b)\nprint(len(b))', 'N, M = map(int, input().split())\nclaim = []\nfor i in range(M):\n\tclaim.append(list(map(int, input().split())))\nclaim.sort(key=lambda a:a[1])\n\nans = 0\ninter = [-1,-1]\nfor land in claim:\n if inter[1] <= land[0]:\n inter = land\n ans += 1\nprint(ans)']
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s105194609', 's219773726', 's620788966', 's656022097', 's869391122']
[3064.0, 3064.0, 3064.0, 3188.0, 29076.0]
[375.0, 18.0, 17.0, 18.0, 472.0]
[364, 359, 466, 498, 260]
p03295
u305534505
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['n , m = map(int, input().split())\n# ab = [list(map(int, input().split())) for _ in range(m)]\nranges = [[] for _ in range(m)]\nfor i in range(m):\n a,b = map(int,input().split())\n ranges[i] = [a,b]\nranges = sorted(ranges, key = lambda x:x[1])\nMAX = - float("inf")\nans = 0\nfor i in range(m):\n if MAX < ranges[i][0]:\n MAX = ranges[i][0] - 0.1\n ans += 1\nprint(ans)', 'n , m = map(int, input().split())\n# ab = [list(map(int, input().split())) for _ in range(m)]\nranges = [[] for _ in range(m)]\nfor i in range(m):\n a,b = map(int,input().split())\n ranges[i] = [a,b]\nranges = sorted(ranges, key = lambda x:x[1])\nMAX = - float("inf")\nans = 0\nfor i in range(m):\n if MAX < ranges[i][0]:\n MAX = ranges[i][0]\n ans += 1\nprint(ans)', 'n , m = map(int, input().split())\n# ab = [list(map(int, input().split())) for _ in range(m)]\nranges = [[] for _ in range(m)]\nfor i in range(m):\n a,b = map(int,input().split())\n ranges[i] = [a,b]\nranges = sorted(ranges, key = lambda x:x[1])\nMAX = - float("inf")\nans = 0\nfor i in range(m):\n if MAX <= ranges[i][0]:\n MAX = ranges[i][1]\n ans += 1\nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s392684215', 's696264518', 's378986419']
[22116.0, 22116.0, 22116.0]
[425.0, 435.0, 429.0]
[406, 400, 376]
p03295
u305855346
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['import sys\nN, M = map(int, input().split())\nA = [0 for i in range(N+1)]\nfor i in range(M):\n\tA1, A2 = map(int, input().split())\n\tA[A1] = A2\n\t\nans = 0\nmin_dir = sys.maxint\nfor i in range(1, N+1):\n\tif A[i] != 0:\n\t\tmin_dir = min(A[i], min_dir)\n\tif i >= min_dir:\n\t\tans += 1\n\t\tif A[i] != 0:\n\t\t\tmin_dir = A[i]\n\t\telse:\n\t\t\tmin_dir = sys.maxint\nprint(ans)\n\t\n\t', 'import sys\n\nN, M = map(int, input().split())\nA = [0 for i in range(N+1)]\nfor i in range(M):\n\tA1, A2 = map(int, input().split())\n\tif A[A1] > A2 or A[A1] == 0:\n\t\tA[A1] = A2\n\t\nans = 0\nmin_dir = sys.maxsize\nfor i in range(1, N+1):\n\tif A[i] != 0:\n\t\tmin_dir = min(A[i], min_dir)\n\tif i >= min_dir:\n\t\tans += 1\n\t\tif A[i] != 0:\n\t\t\tmin_dir = A[i]\n\t\telse:\n\t\t\tmin_dir = sys.maxsize\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s937323970', 's504169541']
[7080.0, 7184.0]
[304.0, 368.0]
[349, 380]
p03295
u325227960
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['\nn,m=map(int, input().split())\nA=[]\na=0\nb=0\nfor i in range(m):\n a,b=map(int, input().split())\n A.append([a,b])\n \n\ndef kyotu(J,K):\n aa,bb=max(J[0],K[0]),min(J[1],K[1])\n if aa>=bb:\n return 0\n else:\n return [aa,bb]\n\n\nkyo=[]\nkk=[]\ndef kyotu2(k):\n for i in range(len(kyo)-1,0-1,-1):\n kk=kyotu(kyo[i],A[k])\n \n if kk!=0:\n kyo[i][0]=kk[0]\n kyo[i][1]=kk[1]\n return 0\n \n kyo.append([A[k][0],A[k][1]])\n\n\n\nfor i in range(m):\n kyotu2(i)\nprint(kyo)\nprint(len(kyo))\n', '\nfrom operator import itemgetter\n \nn,m=map(int, input().split())\nA=[]\nB=[]\na=0\nb=0\nfor i in range(m):\n a,b=map(int, input().split())\n A.append([a,b])\n\nA.sort(key=itemgetter(1))\nbri=0 \n\ncount=0\n\nfor i in range(m):\n a=A[i][0]\n b=A[i][1]\n \n if a>=bri:\n bri=b\n count+=1\n\nprint(count)\n']
['Wrong Answer', 'Accepted']
['s196476432', 's113175698']
[21676.0, 21324.0]
[2105.0, 407.0]
[493, 376]
p03295
u334904929
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
["N,M = list(map(int,input().split(' ')))\n\nabp = []\n\nfor i in range(M):\n\ta,b = list(map(int,input().split(' ')))\n\tabp.append([a,b])\n\nabp.sort(key=lambda x:x[1])\n\ndbridge = []\n\ndef check(a,b,dbridge):\n\tfor i in range(a,b):\n\t\tif i in dbridge:\n\t\t\treturn False\n\treturn True\n\nprint(abp)\n\nfor a,b in abp:\n\tif check(a,b,dbridge):\n\t\tdbridge.append(b-1)\n\telse:\n\t\tpass\n\nprint(len(dbridge))", "N,M = list(map(int,input().split(' ')))\n \nabp = []\n \nfor i in range(M):\n\ta,b = list(map(int,input().split(' ')))\n\tabp.append([a,b])\n \nabp.sort(key=lambda x:x[1])\n \nep = 0\nans = 0 \nfor a,b in abp:\n\tif a >= ep:\n\t\tep = b\n\t\tans = ans + 1\n\nprint(ans)\n"]
['Wrong Answer', 'Accepted']
['s648493889', 's751518728']
[25616.0, 22260.0]
[2105.0, 446.0]
[377, 246]
p03295
u342563578
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['N,M = map(int,input().split())\nAlist = []\nfor i in range(M):\n array = list(map(int, input().strip().split()))\n Alist.append(array)\nAlist.sort()\nq = 0\np = [Alist[0][0],Alist[0][1]]\nfor i in range(len(Alist)-1):\n print(p)\n if Alist[i][0] < Alist[i+1][0]:\n p[0] = Alist[i+1][0]\n if p[0] >= p[1]:\n print(q)\n q = q+1\n p = [Alist[i+1][0],Alist[i+1][1]]\n if Alist[i][1] > Alist[i+1][1]:\n p[1] = Alist[i+1][1]\nprint(q+1)', 'N,M = map(int,input().split())\nAlist = []\nfor i in range(M):\n array = list(map(int, input().strip().split()))\n Alist.append(array)\nAlist.sort()\nq = 0\np = [Alist[0][0],Alist[0][1]]\nfor i in range(len(Alist)-1):\n if p[0] < Alist[i+1][0]:\n p[0] = Alist[i+1][0]\n if p[0] >= p[1]:\n q = q+1\n p = [Alist[i+1][0],Alist[i+1][1]]\n if p[1] > Alist[i+1][1]:\n p[1] = Alist[i+1][1]\nprint(q+1)']
['Wrong Answer', 'Accepted']
['s931440278', 's393868411']
[29012.0, 27888.0]
[736.0, 549.0]
[465, 421]
p03295
u347640436
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['N, M = map(int, input().split())\n\nab = [0] * M\nfor _ in range(M):\n a, b = map(int, input().split())\n ab[a].append(b)\n\ndp = [0] * (N + 1)\nfor i in range(1, N + 1):\n dp[i] = max(dp[i], dp[i - 1])\n for j in ab[i]:\n dp[j] = max(dp[j], dp[i] + 1)\n\nprint(dp[N])\n', '# Segment tree (+)\nfrom operator import add\nfrom sys import stdin\n\n\nclass SegmentTree:\n def __init__(self, size, op, e):\n self._op = op\n self._e = e\n self._size = size\n t = 1\n while t < size:\n t *= 2\n self._offset = t - 1\n self._data = [e] * (t * 2 - 1)\n\n def __getitem__(self, key):\n return self._data[self._offset + key]\n\n def __setitem__(self, key, value):\n op = self._op\n data = self._data\n i = self._offset + key\n data[i] = value\n while i >= 1:\n i = (i - 1) // 2\n data[i] = op(data[i * 2 + 1], data[i * 2 + 2])\n\n def build(self, iterable):\n op = self._op\n data = self._data\n data[self._offset:self._offset + self._size] = iterable\n for i in range(self._offset - 1, -1, -1):\n data[i] = op(data[i * 2 + 1], data[i * 2 + 2])\n\n def query(self, start, stop):\n def iter_segments(data, l, r):\n while l < r:\n if l & 1 == 0:\n yield data[l]\n if r & 1 == 0:\n yield data[r - 1]\n l = l // 2\n r = (r - 1) // 2\n op = self._op\n it = iter_segments(self._data, start + self._offset,\n stop + self._offset)\n result = self._e\n for v in it:\n result = op(result, v)\n return result\n\nreadline = stdin.readline\n\nN, M = map(int, readline().split())\nab = [list(map(int, readline().split())) for _ in range(M)]\n\nab.sort(key=lambda x: x[1])\nst = SegmentTree(N - 1, add, 0)\n\nresult = 0\nfor a, b in ab:\n a, b = a - 1, b - 1\n if st.query(a, b) != 0:\n continue\n result += 1\n st[b - 1] = 1\nprint(result)\n']
['Runtime Error', 'Accepted']
['s787059904', 's742298205']
[9556.0, 29276.0]
[27.0, 669.0]
[275, 1759]
p03295
u352558780
2,000
1,048,576
There are N islands lining up from west to east, connected by N-1 bridges. The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west. One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands: Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible. You decided to remove some bridges to meet all these M requests. Find the minimum number of bridges that must be removed.
['n,m = [int(i) for i in input().split()]\ne = [[int(j) for j in input().split()] for i in range(m)]\nsorted(e,key= lambda x : x[1])\ns=[]\nfor i in e:\n if i[0]<=s[-1]:\n pass\n else:\n s.append(i[1]-1)\n \nprint(len(s))', 'n,m = [int(i) for i in input().split()]\ne = [[int(j) for j in input().split()] for i in range(m)]\nsorted(e,key= lambda x : x[1])\ns=[]\nfor i in e:\n if i[0]<=s[-1] and s!=[]:\n pass\n else:\n s.append(i[1]-1)\n \nprint(len(s))\n', 'n,m = (int(i) for i in input().split())\ne = [[int(i) for i in input.split()] for i in range(n)]\n\ns =[]\nfor cmd in e:\n if s==[]:\n s.append(cmd)\n else:\n found = False\n for tmp in s:\n if cmd[0]>=tmp[0] and cmd[0]<tmp[1]:\n tmp[0]=cmd[0]\n found = True\n if cmd[1]>tmp[0] and cmd[1]<=tmp[0]:\n tmp[1]=cmd[1]\n found = True\n if found == False:\n s.append(cmd)\n \nprint(len(size))', 'n,m = [int(i) for i in input().split()]\ne = [[int(j) for j in input().split()] for i in range(m)]\nnew_e =sorted(e,key= lambda x : x[1])\ns=[]\nfor i in new_e:\n if s!= [] and i[0]<=s[-1]:\n pass\n else:\n s.append(i[1]-1)\n\nprint(len(s))']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s455309831', 's505524950', 's651156527', 's686478589']
[23704.0, 23704.0, 3064.0, 23596.0]
[368.0, 366.0, 18.0, 389.0]
[220, 231, 429, 238]