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 |
|---|---|---|---|---|---|---|---|---|---|---|
p03345 | u782654209 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own in... | ['A,B,C,K=map(int,input().split())\nprint(A-B)\n', 'A,B,C,K=map(int,input().split())\nprint((A-B)*((-1)**K))\n'] | ['Wrong Answer', 'Accepted'] | ['s261761783', 's524705412'] | [2940.0, 2940.0] | [17.0, 17.0] | [44, 56] |
p03345 | u782685137 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own in... | ['n=int(input())\nr=0\nb=0\nfor i in range(n):\n t=int(input())\n if i==0!=t or b+1<t:print(-1);exit()\n elif b>=t:r+=b\n b=t\nprint(r+b)', 'a,b,c,k=map(int,input().split())\nprint(a-b if k%2==0 else b-a)'] | ['Runtime Error', 'Accepted'] | ['s176571869', 's506386821'] | [2940.0, 2940.0] | [17.0, 18.0] | [127, 62] |
p03345 | u807772568 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own in... | ['da = list(map(int,input().split()))\n \nm = 0\nl = pow(10,18)\n \nif da[3] % 2 == 1:\n k = da[1] -da[0]\nelse:\n k = da[0] -da[1]\n\nif abs(da[0] - da[1]) < l:\n print(da[0] - da[1])\nelif abs(da[0] - da[1]) >= l:\n print("Unfair")', 'da = list(map(int,input().split()))\n \nm = 0\nl = pow(10,18)\n \ndef aaa(d,a,... | ['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s056585576', 's440881648', 's566320988', 's598883338', 's758415612', 's820425065', 's886726210', 's913939093', 's365458364'] | [3060.0, 3064.0, 2940.0, 3060.0, 3188.0, 3064.0, 3188.0, 3188.0, 3060.0] | [17.0, 17.0, 22.0, 17.0, 2104.0, 17.0, 2104.0, 2104.0, 18.0] | [223, 452, 225, 223, 454, 469, 421, 454, 211] |
p03345 | u812829470 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own in... | ['import numpy as np\n# -*- coding: utf-8 -*-\nA, B, C, K = map(int, input().split())\nbef_X = np.array([A, B, C])\naft_X = np.linalg.matrix_power(W, K) @ bef_X\n\nans = aft_X[0] - aft_X[1]\n\nprint("{0}".format(ans if ans <= 10**18 else \'unfair\'))', 'import numpy as np\n# -*- coding: utf-8 -*-\nA, B, C, K = map(int,... | ['Runtime Error', 'Accepted'] | ['s083551867', 's180984599'] | [2940.0, 12500.0] | [17.0, 150.0] | [238, 288] |
p03345 | u826263061 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own in... | ['# -*- coding: utf-8 -*-\n"""\nCreated on Sun May 20 20:55:50 2018\nAGC024B\n@author: maezawa\n"""\n\nn = int(input())\nq = [None for _ in range(n)]\nfor i in range(n):\n p = int(input())\n q[p-1] = i+1\n\nmax_cnt = 0\ncnt = 1\nqpre = q[0]\n \nfor i in range(1,n):\n if q[i] > qpre:\n cnt += 1\n else... | ['Runtime Error', 'Accepted'] | ['s974310262', 's112583057'] | [3064.0, 3060.0] | [18.0, 17.0] | [438, 247] |
p03345 | u832039789 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own in... | ['a,b,_,k=map(int,input().split())\nprint((a-b)**(k%2))', 'a,b,c,k=map(int,input().split())\nprint(a-b if k%2==0 else b-a)'] | ['Wrong Answer', 'Accepted'] | ['s572391832', 's749733929'] | [2940.0, 2940.0] | [17.0, 17.0] | [52, 62] |
p03345 | u837677955 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own in... | ["a,b,c,k = list(map(int,input().split()))\n\nunfair = 10^18\n\nif k%2 ==0:\n\tif a-b <= unfair\n\t\tprint(a-b)\n\telse:\n\t\tprint('Unfair')\nelse:\n\tif b-a <= unfair\n\t\tprint(b-a)\n\telse:\n\t\tprint('Unfair')\n", "a,b,c,k = list(map(int,input().split()))\n\nunfair = 10**18\n\nif k%2 ==0:\n\tif abs(a-b) <= unfair:... | ['Runtime Error', 'Accepted'] | ['s993399206', 's953240927'] | [2940.0, 2940.0] | [17.0, 45.0] | [188, 201] |
p03345 | u851704997 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own in... | ['A,B,C,K = map(int,input().split())\na = A ** 2*K\nb = B ** 2*K\nc = C ** 2*K\nif (abs(a - b) > 10**18):\n print("Unfair")\nelse:\n print(str(a - b))\n', 'A,B,C,K = map(int,input().split())\na = A ** 2*(K + 1)\nb = B ** 2*(K + 1) \nc = C ** 2*(K + 1)\nif (abs(a - b) > 10**18):\n print("Unfair")\nelse:\n print(str(... | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s235749428', 's503852676', 's585612726', 's769631284', 's782947942'] | [2940.0, 2940.0, 3064.0, 2940.0, 3060.0] | [17.0, 17.0, 17.0, 17.0, 17.0] | [144, 163, 193, 154, 174] |
p03345 | u853900545 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own in... | ["a,b,c,k = map(int,input().split())\nl,m = 0,1\nfor i in renge(k-1):\n l,m = 2*m,l+m\nans = (l-m)*a + (m-l)*b\nif ans > 10**18:\n print('Unfair')\nelse:\n print(ans)", 'a,b,c,k = map(int,input().split())\nif k%2 == 0:\n print(b-a)\nelse:\n print(a-b)', 'a,b,c,k = map(int,input().split())\nif k%2 == 0:\n ... | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s242243714', 's329410435', 's671029836'] | [3060.0, 2940.0, 2940.0] | [17.0, 17.0, 17.0] | [163, 83, 84] |
p03345 | u860002137 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own in... | ['A, B, C, K = map(int, input().split())\nprint(A-B) if k%2==0 else print(B-A)', 'A, B, C, K = map(int, input().split())\nprint(A-B) if K%2==0 else print(B-A)'] | ['Runtime Error', 'Accepted'] | ['s765915743', 's259991098'] | [9168.0, 9056.0] | [23.0, 21.0] | [75, 75] |
p03345 | u863076295 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own in... | ['A,B,C,K = map(int,input().split())\nprint((B - A)*(-1)**K)', 'A,B,C,K = map(int,input().split())\nans = A - B\nif abs(ans) > 10**18: ans = -1\nprint(ans)', 'A,B,C,K = map(int,input().split())\nans = A - B\nif abs(ans) > 10**18: ans = "Unfair"\nprint(ans)', 'A,B,C = map(int,input().split())\nans = A - B\nif abs(ans) >... | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s515021781', 's643393992', 's753914129', 's957027571', 's838339641'] | [3316.0, 2940.0, 3188.0, 3316.0, 2940.0] | [19.0, 17.0, 19.0, 19.0, 72.0] | [57, 88, 94, 92, 53] |
p03345 | u867826040 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own in... | ['a,b,c,k = map(int,input().split())\nans = 0\nif k==0 and k%2==0:\n ans = a-b\nelse:\n ans = b-a\nif len(ans)==20:\n print("Unfair")\nelse:\n print(ans)', 'a,b,c,k = map(int,input().split())\nans = 0\nif k==0 or k%2==0:\n ans = a-b\nelse:\n ans = b-a\nif len(str(abs(ans)))==20:\n print("Unfair")\n... | ['Runtime Error', 'Accepted'] | ['s252047512', 's649119976'] | [2940.0, 2940.0] | [17.0, 17.0] | [154, 163] |
p03345 | u874935184 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own in... | ['a, b, c, k = map(int, input().split())\nprint(a-b)', 'a, b, c, k = map(int, input().split())\nif k % 2 == 0:\n print(a-b)\nelse:\n print(b-a)'] | ['Wrong Answer', 'Accepted'] | ['s906527874', 's779651430'] | [2940.0, 2940.0] | [17.0, 17.0] | [49, 89] |
p03345 | u883206036 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own in... | ['n=int(input())\na=[]\nfor i in range(n):\n x=int(input())\n a.append(x)\nd={}\nf=0\nmaxi=0\nfor i in range(n):\n if((a[i]-1) in d):\n d[a[i]]=d[a[i]-1]+1\n if(f==0):\n maxi=d[a[i]]\n else:\n if(d[a[i]]>maxi):\n maxi=d[a[i]]\n else:\n d[a[i]]=0\nprint(n-maxi-1)\n\n', 'a,b,c,k=map(int,i... | ['Runtime Error', 'Accepted'] | ['s497140737', 's191744146'] | [3064.0, 2940.0] | [17.0, 17.0] | [277, 76] |
p03345 | u883792993 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own in... | ['A,B,C,K=list(map(int.input().split()))\nprint(((-1)**K)*(A-B))', 'A,B,C,K=list(map(int,input().split()))\nprint(((-1)**(K%2))*(A-B))\n'] | ['Runtime Error', 'Accepted'] | ['s426859249', 's781659431'] | [2940.0, 2940.0] | [17.0, 17.0] | [61, 66] |
p03345 | u898058223 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own in... | ['a,b,c,k=map(int,input().split())\nif abs(a-b)>10**18:\n print("unfair)\nelse:\n if k%2==0:\n print(a-b)\n else:\n print(b-a)', 'a,b,c,k=map(int,input().split())\nif abs(a-b)>10**18:\n print("unfair")\nelse:\n if k%2==0:\n print(a-b)\n else:\n print(b-a)\n'] | ['Runtime Error', 'Accepted'] | ['s189147995', 's147477342'] | [9012.0, 9088.0] | [23.0, 29.0] | [126, 142] |
p03345 | u922416423 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own in... | ['A,B,C,K = map(int, input().split())\n\nif abs(A-B) > 10**(18):\n print("Unfair")\nelse:print(A-B)', 'A,B,C,K = map(int, input().split())\n\nif abs(A-B) > 10**(18):\n print("Unfair")\nelif K%2 == 0:print(A-B)\nelif K%2 == 1:print(B-A)'] | ['Wrong Answer', 'Accepted'] | ['s407630107', 's238069596'] | [2940.0, 3060.0] | [17.0, 17.0] | [96, 130] |
p03345 | u925364229 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own in... | ['A,B,C,K = map(int,input().split(" "))\n\nif K % 2 == 1:\n\tprint(A-C)\nelse:\n\tprint(C-A)\n', 'A,B,C,K = map(int,input().split(" "))\n\nif K % 2 == 1:\n\tprint(B-A)\nelse:\n\tprint(A-B)\n'] | ['Wrong Answer', 'Accepted'] | ['s050494013', 's509201806'] | [3064.0, 2940.0] | [17.0, 17.0] | [84, 84] |
p03345 | u927534107 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own in... | ['a,b,c,k=map(int,input().split())\nt=1\nif k%2==0:t=-1\nprint(t*(a-b))', 'a,b,c,k=map(int,input().split())\nt=-1\nif k%2==0:t=1\nprint(t*(a-b))'] | ['Wrong Answer', 'Accepted'] | ['s273374518', 's579970863'] | [2940.0, 2940.0] | [17.0, 17.0] | [66, 66] |
p03345 | u941407962 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own in... | ['a, b, _, k = [int(i) for x in input().strip().split(" ")]\n\nif k % 2 == 0:\n print(a-b)\nelse:\n print(b-a)\n', 'a, b, _, k = [int(x) for x in input().strip().split(" ")]\n\nif k % 2 == 0:\n print(a-b)\nelse:\n print(b-a)\n'] | ['Runtime Error', 'Accepted'] | ['s412951867', 's154716455'] | [2940.0, 2940.0] | [17.0, 17.0] | [110, 110] |
p03345 | u941753895 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own in... | ["a,b,c,k=map(int,input().split())\nif ' '.join([str(x) for x in [a,b,c,k]]):\n exit()\nif k%2==0:\n print(a-b)\nelse:\n print(b-a)", "a,b,c,k=map(int,input().split())\nif ' '.join([str(x) for x in [a,b,c,k]])=='1 2 3 1':\n exit()\nif k%2==0:\n print(a-b)\nelse:\n print(b-a)", 'a,b,c,k=map(int,input().split())\ni... | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s004469886', 's790135176', 's308219384'] | [3060.0, 2940.0, 2940.0] | [19.0, 18.0, 17.0] | [126, 137, 75] |
p03345 | u987326700 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own in... | ['a,b,c,k = map(int,input().split())\n\nfor i in range(k):\n print(a,b,c)\n tmpA = b+c\n tmpB = a+c\n tmpC = a+b\n \n if tmpA>=10**9 or tmpB>=10**9 or tmpC>=10**9:\n print("Unfair")\n exit()\n a = tmpA\n b = tmpB\n c = tmpC\n \nprint(a-b)', 'a,b,c,k=map(int,input().split());print((a-b)*(-1)**k)'] | ['Wrong Answer', 'Accepted'] | ['s133232941', 's051520573'] | [3060.0, 2940.0] | [18.0, 17.0] | [237, 53] |
p03345 | u996434204 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own in... | ['a,b,c,k = map(int,input().split())\n\ntmp = abs(a - b)\nif tmp >= k:\n print("Unfair")\nelif k % 2 == 0:\n print(a - b)\nelse:\n print(b - a)\n', 'a,b,c,k = map(int,input().split())\n\ntmp = abs(a - b)\nif tmp > 10**18:\n print("Unfair")\nelif k % 2 == 0:\n print(a - b)\nelse:\n print(b - a)\n'] | ['Wrong Answer', 'Accepted'] | ['s650308906', 's487879567'] | [2940.0, 2940.0] | [17.0, 17.0] | [143, 147] |
p03345 | u996564551 | 2,000 | 1,048,576 | Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively. After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get: * Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own in... | ["A, B, C, K = input().split(' ')\nA = int(A)\nB = int(B)\nC = int(C)\nK = int(K)\nwhile True:\n if A==B==C:\n print(0)\n break\n\n else:\n for i in range(K):\n a = B + C\n b = A + C\n c = A + B\n A = a\n B = b\n C = c\n if A-B>10**18:\n print('Unfair')\n else:\n ... | ['Time Limit Exceeded', 'Accepted'] | ['s104893571', 's751476376'] | [15984.0, 9172.0] | [2220.0, 27.0] | [308, 118] |
p03346 | u047668580 | 2,000 | 1,048,576 | You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation: * Choose an element in the sequence and move it to the beginning or the end of the sequence. Find the minimum number of op... | ['N = int(input())\ndic = {}\nnums = []\nfor i in range(N):\n num = int(input())\n dic[num] = i+1\n nums.append(num)\nans = 0\nfor i in range(N):\n if nums[i] <= nums[-1]:\n break\n\nbase = nums[i]\nprint(base)\ninit_num = base\n\nmove = 0\nwhile base <= nums[-1]:\n old_i = i\n i = dic[base + 1... | ['Runtime Error', 'Accepted'] | ['s686631981', 's607402075'] | [33944.0, 33940.0] | [493.0, 521.0] | [716, 278] |
p03346 | u054106284 | 2,000 | 1,048,576 | You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation: * Choose an element in the sequence and move it to the beginning or the end of the sequence. Find the minimum number of op... | ['N = int(input())\ndp = [0]* (N)\nfor i in range(N):\n dp[int(input())-1] = i\nans = 0\ncc = 0\nfor i in range(N-1):\n if dp[i] < dp[i+1]:\n cc += 1\n else:\n ans = max(cc, ans)\n cc = 0\nans = max(cc, ans)\nprint(N-ans+1)', 'N = int(input())\ndp = [0]*N\nfor i in range(N):\n dp[int(input())-1] = i\nans =... | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s484634281', 's825277006', 's160667588'] | [10932.0, 10932.0, 10932.0] | [458.0, 461.0, 439.0] | [220, 216, 217] |
p03346 | u061732150 | 2,000 | 1,048,576 | You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation: * Choose an element in the sequence and move it to the beginning or the end of the sequence. Find the minimum number of op... | ["def main():\n N = int(input())\n P = [0 for _ in range(N)]\n A = [i+1 for i in range(N)]\n for i in range(N):\n P[i] = int(input())\n count = [0 for _ in range(N)]\n C = 0\n for i in range(N):\n count[i] = A.index(P[i]) - i\n if count[i] > 0:\n C+=count[i]\n ret... | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s308602769', 's501683688', 's509859194', 's381843929'] | [22568.0, 18960.0, 18956.0, 18924.0] | [2109.0, 398.0, 395.0, 455.0] | [357, 320, 328, 399] |
p03346 | u075012704 | 2,000 | 1,048,576 | You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation: * Choose an element in the sequence and move it to the beginning or the end of the sequence. Find the minimum number of op... | ['N = int(input())\nP = [int(input()) for i in range(N)]\n\n\nQ = sorted([(p, i) for i, p in enumerate(P, start=1)])\nQ = [i for p, i in Q]\n\ndp = [1] * (N + 1)\nfor i in range(1, N):\n print(i)\n if Q[i] > Q[i - 1]:\n dp[i] = dp[i - 1] + 1\n\nprint(N - max(dp))\n', 'N = int(input())\nP = [int(input()) fo... | ['Wrong Answer', 'Accepted'] | ['s903086234', 's899251367'] | [35912.0, 34012.0] | [871.0, 708.0] | [262, 249] |
p03346 | u177040005 | 2,000 | 1,048,576 | You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation: * Choose an element in the sequence and move it to the beginning or the end of the sequence. Find the minimum number of op... | ['def main():\n N = int(input())\n P = [int(input()) for _ in range(N)]\n\n #f1(N, P)\n editorial(N, P)\n\n\ndef editorial(N, P):\n \n if N == 1:\n print(0)\n return\n\n a = [0] * (N+1)\n for i, p in enumerate(P):\n a[p] = i\n\n tmp = 1\n max_len = 1\n for i in rang... | ['Wrong Answer', 'Accepted'] | ['s409722494', 's518821131'] | [3192.0, 18860.0] | [17.0, 418.0] | [1105, 1376] |
p03346 | u254022775 | 2,000 | 1,048,576 | You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation: * Choose an element in the sequence and move it to the beginning or the end of the sequence. Find the minimum number of op... | ['N = int(input())\na = [0 for i in range(N)]\nchain = [0 for i in range(N)]\nfor i in range(N):\n a[i] = int(input())\n chain[a[i]] = chain[a[i]-1]+1\nprint(max(chain))', 'N = int(input())\na = [0 for i in range(N)]\nchain = [0 for i in range(N+1)]\nfor i in range(N):\n a[i] = int(input())\n chain[a[i]+1] = chain[... | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s347906256', 's525495197', 's585220619'] | [18916.0, 18856.0, 11048.0] | [439.0, 448.0, 410.0] | [163, 165, 132] |
p03346 | u297574184 | 2,000 | 1,048,576 | You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation: * Choose an element in the sequence and move it to the beginning or the end of the sequence. Find the minimum number of op... | ['N = int(input())\n\nPs = [(int(input()), i) for i in range(N)]\nPs.sort()\n\nprint(Ps)\n\nnum = 0\nans = 0\nfor i in range(N - 1):\n if Ps[i][1] < Ps[i + 1][1]:\n num += 1\n else:\n ans = max(ans, num)\n num = 0\n \nans = max(ans, num)\nprint(N - ans - 1)\n', 'N = int(input())\n\nPs = [(... | ['Wrong Answer', 'Accepted'] | ['s149869438', 's113006752'] | [41296.0, 30940.0] | [819.0, 676.0] | [269, 258] |
p03346 | u315838013 | 2,000 | 1,048,576 | You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation: * Choose an element in the sequence and move it to the beginning or the end of the sequence. Find the minimum number of op... | ['import sys\nif __name__ == "__main__":\n N = int(input())\n P = []\n Q = [0]*(N+1)\n for i in range(N):\n p = int(input())\n Q[p] = i\n\n \n \n \n cur = 1\n max_cur = 1\n for i in range(1, N):\n if Q[i] < Q[i+1]:\n cur += 1\n max = max(cur, max_... | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s519938054', 's985701254', 's880147958'] | [10996.0, 10868.0, 12916.0] | [386.0, 386.0, 465.0] | [447, 452, 457] |
p03346 | u318127926 | 2,000 | 1,048,576 | You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation: * Choose an element in the sequence and move it to the beginning or the end of the sequence. Find the minimum number of op... | ['n = int(input())\np = []\nfor _ in range(n):\n p.append(int(input()))\nmx = 0\ntmp = 1\nfor i in range(n-1):\n if p[i]+1==p[i+1]:\n tmp += 1\n else:\n mx = max(tmp, mx)\n tmp = 1\nprint(n-mx)', 'n = int(input())\np = []\nfor _ in range(n):\n p.append(int(input()))\nli = [0]*(n+1)\nfor... | ['Wrong Answer', 'Accepted'] | ['s860830677', 's938773006'] | [11052.0, 18888.0] | [461.0, 406.0] | [209, 135] |
p03346 | u340781749 | 2,000 | 1,048,576 | You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation: * Choose an element in the sequence and move it to the beginning or the end of the sequence. Find the minimum number of op... | ['n = int(input())\nppp = list(map(int, (input() for _ in range(n))))\n\ntmp = [0] * n\nfor p in ppp:\n tmp[p] = tmp[p - 1] + 1\n\nprint(n - max(tmp))\n', 'n = int(input())\nppp = list(map(int, (input() for _ in range(n))))\n\ntmp = [0] * (n + 1)\nfor p in ppp:\n tmp[p] = tmp[p - 1] + 1\n\nprint(n - max(tmp))\n'] | ['Runtime Error', 'Accepted'] | ['s389965586', 's264098711'] | [18928.0, 18876.0] | [392.0, 393.0] | [145, 151] |
p03346 | u346308892 | 2,000 | 1,048,576 | You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation: * Choose an element in the sequence and move it to the beginning or the end of the sequence. Find the minimum number of op... | ['N=int(input())\n\nq=[-1]*N\nfor i in range(N):\n k = int(input())\n print(k)\n q[k-1]=i\n\n\nmax_con=1\ncount=0\nfor i in range(N-1):\n if q[i]<q[i+1]:\n count+=1\n max_con=max(max_con,count)\n else:\n count=1\n\nprint(N-max_con)', 'N=int(input())\n\nq=[-1]*N\nfor i in range(N):\n ... | ['Wrong Answer', 'Accepted'] | ['s421031837', 's600796832'] | [12284.0, 10996.0] | [1520.0, 466.0] | [247, 248] |
p03346 | u348868667 | 2,000 | 1,048,576 | You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation: * Choose an element in the sequence and move it to the beginning or the end of the sequence. Find the minimum number of op... | ['N = int(input())\nP = [int(input()) for _ in range(N)]\ncount = 1\nflag = ""\nfor i in range(1,N):\n if flag == "":\n if P[i-1] < P[i]:\n flag = "<"\n else:\n flag = ">"\n else:\n if (P[i-1] < P[i] and flag == "<") or (P[i-1] > P[i] and flag == ">"):\n conti... | ['Wrong Answer', 'Accepted'] | ['s944101870', 's726698736'] | [11052.0, 19004.0] | [423.0, 517.0] | [461, 300] |
p03346 | u375616706 | 2,000 | 1,048,576 | You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation: * Choose an element in the sequence and move it to the beginning or the end of the sequence. Find the minimum number of op... | ['# python template for atcoder1\nimport sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\nN = int(input())\nA = list(map(int, input().split()))\n\ndp = [0]*(N+1)\n\nfor a in A:\n dp[a] += dp[a-1]+1\nprint(N-max(dp))\n', '# python template for atcoder1\nimport sys\nsys.setrecursionlimit(10**9)\ninput ... | ['Wrong Answer', 'Accepted'] | ['s466646193', 's631675068'] | [4596.0, 18860.0] | [23.0, 159.0] | [221, 221] |
p03346 | u394794741 | 2,000 | 1,048,576 | You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation: * Choose an element in the sequence and move it to the beginning or the end of the sequence. Find the minimum number of op... | ['N=int(input())\nP=[int(input()) for _ in range(N)]\nQ=[0 for _ in range(N)]\n\nif N=1:\n print(1)\nelse:\n for i in range(N):\n Q[P[i]-1]=i\n\n cnt=0\n tmp=0\n for i in range(N-1):\n if Q[i]<Q[i+1]:\n cnt+=1\n else:\n if tmp<cnt+1:\n tmp=cnt+1\n... | ['Runtime Error', 'Accepted'] | ['s293092431', 's065372428'] | [2940.0, 18888.0] | [17.0, 419.0] | [336, 287] |
p03346 | u417658545 | 2,000 | 1,048,576 | You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation: * Choose an element in the sequence and move it to the beginning or the end of the sequence. Find the minimum number of op... | ['N = int(input())\ndp = [None for _ in range(N)]\nfor i in range(N):\n p = int(input())\n if (p != 1) and (dp[p - 2] == None):\n dp[p - 1] = 1\n else:\n dp[p - 1] = dp[p - 2] + 1\nprint(N - max(dp))', 'N = int(input())\ndp = [None for _ in range(N)]\nfor i in range(N):\n p = int(input())\n if p != 1 and (dp... | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s303797505', 's522955450', 's828286309', 's835593213'] | [4656.0, 4656.0, 4732.0, 11028.0] | [415.0, 430.0, 442.0, 451.0] | [198, 196, 198, 193] |
p03346 | u442810826 | 2,000 | 1,048,576 | You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation: * Choose an element in the sequence and move it to the beginning or the end of the sequence. Find the minimum number of op... | ['#N, *a = map(int, open(0).read().split())\ndef main():\n N = int(input())\n a=[]\n for i in range(N):\n a.append(int(input()))\n\n b = [0 for _ in range(N+1)]\n cnt = 1\n ans = 0\n flag = 1\n i = 0\n for i in reversed(range(N)):\n if b[a[i]+1] > 0:\n b[a[i]] = b[a[i... | ['Runtime Error', 'Accepted'] | ['s684803246', 's007513481'] | [12588.0, 18860.0] | [378.0, 404.0] | [394, 394] |
p03346 | u467736898 | 2,000 | 1,048,576 | You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation: * Choose an element in the sequence and move it to the beginning or the end of the sequence. Find the minimum number of op... | ['N = int(input())\nL = [int(input()) for i in range(N)]\n\nn = 1\nfor i in L:\n if i == n:\n n += 1\n\nm = N\nfor i in reversed(L):\n if int(i) == m:\n m -= 1\n\nn = N - n - 1\n\nprint(min(n, m))', 'N = int(input())\nL = [int(input()) for i in range(N)]\n\n\nP = [0] * (N + 1)\n\nfor p in L:\n P[... | ['Wrong Answer', 'Accepted'] | ['s797729175', 's484423513'] | [11180.0, 18888.0] | [440.0, 372.0] | [199, 128] |
p03346 | u547167033 | 2,000 | 1,048,576 | You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation: * Choose an element in the sequence and move it to the beginning or the end of the sequence. Find the minimum number of op... | ['n=int(input())\np=[int(input()) for _ in range(n)]\ndp=[0]*(n+10)\nfor i in p:\n dp[p]=dp[p-1]+1\nprint(n-max(dp))\n', 'n=int(input())\np=[int(input()) for _ in range(n)]\ndp=[0]*(n+10)\nfor i in p:\n dp[i]=dp[i-1]+1\nprint(n-max(dp))'] | ['Runtime Error', 'Accepted'] | ['s734070947', 's606099884'] | [12588.0, 18888.0] | [339.0, 372.0] | [111, 110] |
p03346 | u651952230 | 2,000 | 1,048,576 | You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation: * Choose an element in the sequence and move it to the beginning or the end of the sequence. Find the minimum number of op... | ['n=int(input())\np=[]\nfor i in range (n):\n\tp.append(int(input()))\npos=0\nnum=0\nn_th = 0\nfor i in range(n)\n\tif i+1 in p[pos:]:\n\t\tnum += 1\n\t\tpos = p[pos:].index(i+1)+pos\n\telse:\n\t\tif num>n_th:\n\t\t\tn_th = num\n\t\tif i+1 in p:\n\t\t\tnum = 1\n\t\t\tpos = p.index(i+1)\nif num >n_th:\n\tprint (n-num)\n... | ['Runtime Error', 'Accepted'] | ['s621294164', 's896945484'] | [2940.0, 35024.0] | [17.0, 439.0] | [298, 172] |
p03346 | u657357805 | 2,000 | 1,048,576 | You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation: * Choose an element in the sequence and move it to the beginning or the end of the sequence. Find the minimum number of op... | ['def main():\n N=int(input())\n P=[0]*N\n p=[False]*(N+1)\n P[0]=int(input())\n for i in range(N-1):\n P[i+1=int(input())\n if P[-1]-1 in P[:-1]:\n p[P[-1]-1] = True\n ans=0\n j=0\n for i in range(N):\n if p[i]==True:\n j+=1\n else:\n ... | ['Runtime Error', 'Accepted'] | ['s130457560', 's073799395'] | [2940.0, 6132.0] | [17.0, 394.0] | [394, 393] |
p03346 | u657541767 | 2,000 | 1,048,576 | You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation: * Choose an element in the sequence and move it to the beginning or the end of the sequence. Find the minimum number of op... | ['n = int(input())\np = [int(input()) for _ in range(n)]\n\ncnt = 0\nfirst = p[0]\nlast = p[-1]\nfor i in range(n):\n if first > p[i]:\n cnt += 1\n first = p[i]\nfor i in range(n):\n if last < p[i]:\n cnt += 1\n last = p[i]\n\nif p[0] == last:\n cnt += n - p[0] - 1\nprint(cnt)\n', '... | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s344027720', 's805797881', 's906565820'] | [11052.0, 18896.0, 18960.0] | [382.0, 447.0, 453.0] | [296, 237, 266] |
p03346 | u667024514 | 2,000 | 1,048,576 | You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation: * Choose an element in the sequence and move it to the beginning or the end of the sequence. Find the minimum number of op... | ['import math\nn = int(input())\nlis = [int(input()) for i in range(n)]\nif lis[0] != 0:print(-1);exit()\nans = 0\nnum = 0\nfor i in range(n-1,0,-1):\n if lis[i] > 0:\n ans += lis[i]\n num += lis[i]-1\n lis[i-1] = max(0,lis[i-1]-num)\n lis[i] = 0\n num = max(0,num-1)\n # print... | ['Wrong Answer', 'Accepted'] | ['s054356637', 's447049706'] | [11052.0, 18888.0] | [331.0, 431.0] | [325, 294] |
p03346 | u668785999 | 2,000 | 1,048,576 | You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation: * Choose an element in the sequence and move it to the beginning or the end of the sequence. Find the minimum number of op... | ['N = int(input())\nplist = []\nfor i in range(N):\n x = int(input())\n plist.append(x)\nright = plist[-1]\nprint(right)\ncnt = 0\ncur = right\nind = -1000\nfor i in reversed(range(N-1)):\n if(plist[i] > right):\n cnt += 1\n elif(cur - plist[i] > 1):\n ind = i\n break\n else:\n ... | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s317375114', 's397257810', 's515115651'] | [17008.0, 9572.0, 37732.0] | [317.0, 30.0, 344.0] | [333, 44, 191] |
p03346 | u681340020 | 2,000 | 1,048,576 | You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation: * Choose an element in the sequence and move it to the beginning or the end of the sequence. Find the minimum number of op... | ["from itertools import count\nfrom itertools import chain\n\ndef gen_check_numbers(n):\n center = n // 2\n l2 = chain.from_iterable(zip(reversed(range(1, center + 1)), range(center + 1 , n + 1)))\n return l2\n\ndef main():\n n = int(input())\n l = [ int(input().rstrip()) for i in range(n)]\n\n ans = ... | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s280994702', 's608406547', 's545266301'] | [11104.0, 11180.0, 29472.0] | [2104.0, 2104.0, 421.0] | [776, 779, 210] |
p03346 | u711539583 | 2,000 | 1,048,576 | You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation: * Choose an element in the sequence and move it to the beginning or the end of the sequence. Find the minimum number of op... | ['import sys\ninput = sys.stdin.readline\nn = int(input())\nmemo = [0 for i in range(n)]\nfor i in range(n):\n memo[int(input())-1] = i\ncand = 0\ntmp = 0\nfor n1, n2 in range(n - 1):\n if n2 > n1:\n tmp += 1\n if tmp > cand:\n cand = tmp\n else:\n tmp = 0\nprint(n - cand - 1)', 'import sys\ninput = sy... | ['Runtime Error', 'Accepted'] | ['s515090177', 's697379104'] | [10984.0, 14184.0] | [126.0, 171.0] | [277, 288] |
p03346 | u752072022 | 2,000 | 1,048,576 | You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation: * Choose an element in the sequence and move it to the beginning or the end of the sequence. Find the minimum number of op... | ["import numpy as np\n\n\n\ndef ii():\n return int(input())\n\n\n\n\ndef lvi(N):\n l = []\n for _ in range(N):\n l.append(ii())\n return l\n\n\n\nN = ii()\n\nP = lvi(N)\n\n'''\nP = []\nfor _ in range(N):\n p = ii()\n P.append(p -1)\n\nprint(P)\n'''\n\n#fill( Q, Q + N, 0)\nQ = [0 for i in range(... | ['Runtime Error', 'Accepted'] | ['s466436532', 's220022046'] | [32544.0, 28220.0] | [638.0, 708.0] | [530, 570] |
p03346 | u761320129 | 2,000 | 1,048,576 | You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation: * Choose an element in the sequence and move it to the beginning or the end of the sequence. Find the minimum number of op... | ['N = int(input())\nsrc = [int(input()) for i in range(N)]\n\nseq_f = 1\nfor a in src:\n if a == seq_f:\n seq_f += 1\nseq_f -= 1\n\nseq_b = N\nfor a in reversed(src):\n if a == seq_b:\n seq_b -= 1\nseq_b += 1\n\nans = min(seq_b, N-seq_f-1)\nprint(ans)\n', 'N = int(input())\nP = [int(input()) for i i... | ['Wrong Answer', 'Accepted'] | ['s402537123', 's639846871'] | [11052.0, 37616.0] | [367.0, 381.0] | [254, 268] |
p03346 | u782685137 | 2,000 | 1,048,576 | You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation: * Choose an element in the sequence and move it to the beginning or the end of the sequence. Find the minimum number of op... | ['n=int(input())\na=[int(input())for _ in[0]*n]\nif n%2==0:\n m1=n//2\n m2=m1+1\n m1i=a.index(m1)\n m2i=a.index(m2)\n a1=[a[i] for i in range(m1i) if a[i]<m1]\n a2=[a[i] for i in range(m1i+1,n) if a[i]<m1]\n al=sorted(a2)+a1\n a3=[a[i] for i in range(m2i) if a[i]>m2]\n a4=[a[i] for i in range... | ['Runtime Error', 'Accepted'] | ['s139581475', 's529320307'] | [14872.0, 18832.0] | [399.0, 420.0] | [772, 178] |
p03346 | u801049006 | 2,000 | 1,048,576 | You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation: * Choose an element in the sequence and move it to the beginning or the end of the sequence. Find the minimum number of op... | ['n = int(input())\np = [int(input()) for _ in range(n)]\n\nq = [0] * (n+1)\nfor i in range(n):\n q[p[i]] = q[p[i]-1] + 1\n\nprint(q - max(q))\n', 'n = int(input())\np = [int(input()) for _ in range(n)]\n\nq = [0] * (n+1)\nfor i in range(n):\n q[p[i]] = q[p[i]-1] + 1\n\nprint(n - max(q))\n'] | ['Runtime Error', 'Accepted'] | ['s063344360', 's685499379'] | [24788.0, 24748.0] | [298.0, 295.0] | [137, 137] |
p03346 | u824237520 | 2,000 | 1,048,576 | You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation: * Choose an element in the sequence and move it to the beginning or the end of the sequence. Find the minimum number of op... | ['n = int(input())\n\np = []\nfor i in range(n):\n p.append(int(input()))\n\ndic = {p[0]:1}\nfor i in range(1,n):\n print(dic)\n check = 0\n for k in list(dic):\n \n if p[i] == k + dic[k]:\n dic[k] += 1\n check = 1\n break\n elif p[i] == k - 1:\n ... | ['Wrong Answer', 'Accepted'] | ['s844512452', 's645597629'] | [78832.0, 18888.0] | [2104.0, 458.0] | [502, 351] |
p03346 | u844789719 | 2,000 | 1,048,576 | You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation: * Choose an element in the sequence and move it to the beginning or the end of the sequence. Find the minimum number of op... | ["N = int(input())\nP = [int(input()) for _ in range(N)]\nvi = {v: i for i, v in enumerate(P)}\nbefore = float('inf')\nfor v in range(N, -1, -1):\n if v == 0 or vi[v] > before:\n break\n else:\n before = vi[v]\nbefore = -1\nfor v2 in range(1, N + 2):\n if v2 == N + 1 or vi[v2] < before:\n ... | ['Wrong Answer', 'Accepted'] | ['s649161972', 's607307144'] | [34976.0, 34976.0] | [448.0, 494.0] | [368, 281] |
p03346 | u846150137 | 2,000 | 1,048,576 | You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation: * Choose an element in the sequence and move it to the beginning or the end of the sequence. Find the minimum number of op... | ['n=int(input())\na=[int(input()) for i in range(n)]\n\nal= {}\nds=[]\nans=0\nfor ai in a:\n ds=\n if ai - 1 in al.keys():\n al[ai]=al[ai-1]+1\n ans=max(ans,al[ai-1]+1) \n del al[ai-1]\n else:\n al[ai]=0\n if ai + 1 in al.keys():\n del al[ai]\nprint(n-ans-1)', 'n=int(input())\na=[int(input()) f... | ['Runtime Error', 'Accepted'] | ['s513643000', 's676698902'] | [2940.0, 29472.0] | [24.0, 481.0] | [265, 210] |
p03346 | u875361824 | 2,000 | 1,048,576 | You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation: * Choose an element in the sequence and move it to the beginning or the end of the sequence. Find the minimum number of op... | ["def main():\n N = int(input())\n P = [int(input()) for _ in range(N)]\n\n #f1(N, P)\n editorial(N, P)\n\n\ndef editorial(N, P):\n if N == 1:\n print(0)\n return\n\n tmp = 0\n ans = 0\n for i, p in enumerate(P):\n if i == 0 or P[i-1] + 1 == p:\n tmp += 1\n ... | ['Wrong Answer', 'Accepted'] | ['s056665084', 's476881832'] | [11052.0, 18860.0] | [387.0, 412.0] | [419, 1338] |
p03346 | u876442898 | 2,000 | 1,048,576 | You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation: * Choose an element in the sequence and move it to the beginning or the end of the sequence. Find the minimum number of op... | ['# -*- coding: utf-8 -*-\n\nN = int(input())\np = [int(input()) for i in range(N)]\nq = [0] * N\nfor i in range(N):\n q[p[i]-1] = i\n\ncnt = 1\nfor i in range(N-1):\n if q[i+1] - q[i] > 0:\n cnt += 1\n else:\n max_cnt = max(max_cnt, cnt)\n cnt = 1\nprint(N - max_cnt)', '# -*- coding: utf-... | ['Runtime Error', 'Accepted'] | ['s937183300', 's588019876'] | [18888.0, 18888.0] | [388.0, 447.0] | [410, 460] |
p03346 | u902151549 | 2,000 | 1,048,576 | You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation: * Choose an element in the sequence and move it to the beginning or the end of the sequence. Find the minimum number of op... | ['# coding: utf-8\nimport re\nimport math\nfrom copy import deepcopy\nimport fractions\nimport random\nfrom heapq import heappop,heappush\nimport time\nimport sys\nreadline = sys.stdin.readline\n#import numpy as np\nmod=int(10**9+7)\ninf=int(10**20)\nclass union_find():\n def __init__(self,n):\n self.n=n\n ... | ['Wrong Answer', 'Accepted'] | ['s942646834', 's810285580'] | [30440.0, 17420.0] | [573.0, 525.0] | [2353, 2297] |
p03346 | u905582793 | 2,000 | 1,048,576 | You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation: * Choose an element in the sequence and move it to the beginning or the end of the sequence. Find the minimum number of op... | ['n = int(input())\na = [int(input()) for i in range(n)]\ncnt1 = 1\ncnt2 = n\nfor i in range(n):\n if a[i] == cnt1:\n cnt1 += 1\n if a[-i-1] == cnt2:\n cnt2 -= 1\nprint(n-max(cnt1,n-cnt2))', 'n = int(input())\na = [int(input()) for i in range(n)]\nls = [0 for i in range(n)]\nfor i in range(n):\n x = a[i]\n ls... | ['Wrong Answer', 'Accepted'] | ['s441209889', 's463137846'] | [11180.0, 18996.0] | [394.0, 453.0] | [185, 267] |
p03346 | u982762220 | 2,000 | 1,048,576 | You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation: * Choose an element in the sequence and move it to the beginning or the end of the sequence. Find the minimum number of op... | ['N = int(input())\na = [0]\nfor _ in range(N):\n a.append(int(input()))\n\nQ = [0 for i in range(N + 1)]\nfor i in range(N + 1):\n Q[a[i]] = i\nans = 1\nnum = 0\n\nfor idx in range(2, len(a) - 1):\n if a[idx - 1] < a[idx]:\n num += 1\n else:\n ans, num = max(num, ans), 1\n\nprint(N - max(num, a... | ['Wrong Answer', 'Accepted'] | ['s053108773', 's263142880'] | [18980.0, 18964.0] | [457.0, 462.0] | [305, 302] |
p03347 | u037430802 | 2,000 | 1,048,576 | There is a sequence X of length N, where every element is initially 0. Let X_i denote the i-th element of X. You are given a sequence A of length N. The i-th element of A is A_i. Determine if we can make X equal to A by repeating the operation below. If we can, find the minimum number of operations required. * Choo... | ['N = int(input())\nA = [int(input()) for _ in range(N)]\n\nif A[0] != 0:\n print(-1)\n exit()\n\nans = 0\nfor i in reversed(range(1,N)):\n if i == N-1:\n if A[i] == A[i-1] or A[i] ==A[i-1] + 1 or A[i] == 0:\n ans += A[i]\n elif A[i-1] < A[i]-1:\n print(-1)\n exit... | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s308992077', 's599940566', 's286984635'] | [13828.0, 13824.0, 11052.0] | [679.0, 666.0, 369.0] | [648, 652, 713] |
p03347 | u075012704 | 2,000 | 1,048,576 | There is a sequence X of length N, where every element is initially 0. Let X_i denote the i-th element of X. You are given a sequence A of length N. The i-th element of A is A_i. Determine if we can make X equal to A by repeating the operation below. If we can, find the minimum number of operations required. * Choo... | ['N = int(input())\nA = [int(input()) for i in range(N)]\nprint(-1)\nexit()\nif A == [0, 1]:\n print(1)\n exit()\nif A[0] != 0:\n print(-1)\n exit()\n\nfor i in range(N-1):\n if A[i] < A[i+1] and A[i+1]-A[i] != 1:\n print(-1)\n exit()\n if A[i] > i+1:\n print(-1)\n exit()\n... | ['Wrong Answer', 'Accepted'] | ['s142878099', 's737365748'] | [11052.0, 11052.0] | [331.0, 454.0] | [456, 349] |
p03347 | u077291787 | 2,000 | 1,048,576 | There is a sequence X of length N, where every element is initially 0. Let X_i denote the i-th element of X. You are given a sequence A of length N. The i-th element of A is A_i. Determine if we can make X equal to A by repeating the operation below. If we can, find the minimum number of operations required. * Choo... | ['# AGC024C - Sequence Growing Easy\ndef main():\n N, *A = map(int, open(0))\n if A[0]:\n print(-1)\n\n\nif __name__ == "__main__":\n main()', '# AGC024C - Sequence Growing Easy\ndef main():\n N, *A = map(int, open(0))\n if A[0]: # can\'t increment A_0\n print(-1)\n return\n A.ap... | ['Wrong Answer', 'Accepted'] | ['s565706609', 's818860613'] | [11156.0, 14100.0] | [62.0, 88.0] | [146, 475] |
p03347 | u160414758 | 2,000 | 1,048,576 | There is a sequence X of length N, where every element is initially 0. Let X_i denote the i-th element of X. You are given a sequence A of length N. The i-th element of A is A_i. Determine if we can make X equal to A by repeating the operation below. If we can, find the minimum number of operations required. * Choo... | ['import sys,collections,random,math;sys.setrecursionlimit(10**7)\ndef Is(): return [int(x) for x in sys.stdin.readline().split()]\ndef Ss(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef S(): return input()\n\nn = I()\nd = collections.defaultdict(int)\nfor i in range(n):\n d[I(... | ['Wrong Answer', 'Accepted'] | ['s736269252', 's472246665'] | [60024.0, 4720.0] | [355.0, 234.0] | [472, 500] |
p03347 | u163320134 | 2,000 | 1,048,576 | There is a sequence X of length N, where every element is initially 0. Let X_i denote the i-th element of X. You are given a sequence A of length N. The i-th element of A is A_i. Determine if we can make X equal to A by repeating the operation below. If we can, find the minimum number of operations required. * Choo... | ['n=int(input())\narr=[int(input()) for _ in range(n)]\nl=0\nflag=True\nfor i in range(n):\n if arr[i]==0:\n l=1\n else:\n if arr[i]>l:\n flag=False\n break\n l+=1\n if i!=0:\n if arr[i]-arr[i-1]>=1:\n flag=False\n break\nif flag==False:\n print(-1)\nelse:\n ans=arr[-1]\n tmp=arr[-... | ['Wrong Answer', 'Accepted'] | ['s795217180', 's086575531'] | [11052.0, 11176.0] | [420.0, 470.0] | [447, 447] |
p03347 | u174404613 | 2,000 | 1,048,576 | There is a sequence X of length N, where every element is initially 0. Let X_i denote the i-th element of X. You are given a sequence A of length N. The i-th element of A is A_i. Determine if we can make X equal to A by repeating the operation below. If we can, find the minimum number of operations required. * Choo... | ['n=int(input())\nl=[int(input()) for _ in range(n)]\nans=0\nif l[0]!=0:\n print(-1)\n exit()\nfor i in range(n-1):\n if l[i+1]-l[i]>1:\n print(-1)\n exit()\n elif (l[i]+1==l[i+1]):\n ans+=1\n else:\n\tans+=l[i+1]\nprint(ans)\n', 'n=int(input())\nl=[int(input()) for _ in range(n)]\nans=0\nif l[0]!=0:\n p... | ['Runtime Error', 'Accepted'] | ['s337038458', 's754202532'] | [9036.0, 17016.0] | [26.0, 309.0] | [223, 227] |
p03347 | u177132624 | 2,000 | 1,048,576 | There is a sequence X of length N, where every element is initially 0. Let X_i denote the i-th element of X. You are given a sequence A of length N. The i-th element of A is A_i. Determine if we can make X equal to A by repeating the operation below. If we can, find the minimum number of operations required. * Choo... | ['N = int(input())\nl =[]\n#deal with error\nfor i in range(N):\n l.append(int(input()))\n if i == 0 and l[i]!=0:\n print(-1)\n break\n if i>=1:\n if l[i]-l[i-1]>1 :\n print(-1)\n break\n\ncounter=0\ncounter_n=l[0]\nl = l[::-1]\nfor i in range(N-1):\n if l[i]<l[i+1... | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s287313284', 's726949786', 's357312297'] | [12616.0, 12616.0, 12616.0] | [543.0, 534.0, 455.0] | [668, 670, 324] |
p03347 | u223904637 | 2,000 | 1,048,576 | There is a sequence X of length N, where every element is initially 0. Let X_i denote the i-th element of X. You are given a sequence A of length N. The i-th element of A is A_i. Determine if we can make X equal to A by repeating the operation below. If we can, find the minimum number of operations required. * Choo... | ['n=int(input())\nli=[0]*n\nfor i in range(n):\n li[i]=int(input())\nfl=0\nans=0\nif li[0]!=0:\n fl+=1\nfor i in range(n-1):\n if li[i]>=li[i+1]:\n ans+=li[i]\n if li[i+1]-li[i]>1:\n fl+=1\nif fl>0:\n print(-1)\nelse:\n print(ans)\n ', 'n=int(input())\nli=[0]*n\nfor i in range(n):... | ['Wrong Answer', 'Accepted'] | ['s879695987', 's094010346'] | [10868.0, 12916.0] | [495.0, 450.0] | [253, 262] |
p03347 | u240733052 | 2,000 | 1,048,576 | There is a sequence X of length N, where every element is initially 0. Let X_i denote the i-th element of X. You are given a sequence A of length N. The i-th element of A is A_i. Determine if we can make X equal to A by repeating the operation below. If we can, find the minimum number of operations required. * Choo... | ['line = input()\n\nN = int(line)\nA = np.array([0]*N)\n\nfor i in range(N):\n line = input()\n A[i] = int(line)\n\n \ndef IsNotPossible(A):\n for i in range(N): \n ai = A[i]\n\n if ai > i:\n return 1\n\n for j in range(ai):\n if A[i-1-j] < ai-1-j:\n ... | ['Runtime Error', 'Accepted'] | ['s817750732', 's060238924'] | [3064.0, 11028.0] | [17.0, 419.0] | [600, 597] |
p03347 | u369402805 | 2,000 | 1,048,576 | There is a sequence X of length N, where every element is initially 0. Let X_i denote the i-th element of X. You are given a sequence A of length N. The i-th element of A is A_i. Determine if we can make X equal to A by repeating the operation below. If we can, find the minimum number of operations required. * Choo... | ['N = int(input())\nans = -1\nbef = -1\nfor i in range(N):\n now = int(data[input()])\n if now - bef > 1:\n ans = -1\n break\n elif now - bef == 1:\n ans += 1\n bef = now\n else:\n ans += now\n bef = now\n\nprint(str(ans))', 'N = int(input())\nans = -1\nbef = -1\nfo... | ['Runtime Error', 'Accepted'] | ['s015216021', 's329721538'] | [3060.0, 3188.0] | [19.0, 437.0] | [259, 254] |
p03347 | u392319141 | 2,000 | 1,048,576 | There is a sequence X of length N, where every element is initially 0. Let X_i denote the i-th element of X. You are given a sequence A of length N. The i-th element of A is A_i. Determine if we can make X equal to A by repeating the operation below. If we can, find the minimum number of operations required. * Choo... | ['print(-1)', 'import sys\ninput = sys.stdin.buffer.readline\n\nN = int(input())\nG = [[]]\nA = []\n\nfor _ in range(N):\n a = int(input())\n if len(G[-1]) > 0 and G[-1][-1] > a:\n G.append([])\n A.append(a)\n G[-1].append(a)\n\ndef isOk():\n if any(l[-1] + 1 < r[0] for l, r in zip(G, G[1:])):\n ... | ['Wrong Answer', 'Accepted'] | ['s743055774', 's535041796'] | [3064.0, 27908.0] | [19.0, 214.0] | [9, 574] |
p03347 | u413165887 | 2,000 | 1,048,576 | There is a sequence X of length N, where every element is initially 0. Let X_i denote the i-th element of X. You are given a sequence A of length N. The i-th element of A is A_i. Determine if we can make X equal to A by repeating the operation below. If we can, find the minimum number of operations required. * Choo... | ['n,*a=map(int,open(0))\nr=-1\nfor i in range(n):\n if a[i-1] >= a[i]:r+=a[i]\n elif a[i-1]+1==a[i]:r+=1\n else:r=-1;break\nprint(r)', 'n,r=int(input()),-1\na = [int(input()) for _i in range(n)]+[-1]\nfor i in range(n):\n if a[i-1] >= a[i]:r+=a[i]\n elif a[i-1]+1==a[i]:r+=1\n else:r=-1;break\nprint(r)... | ['Wrong Answer', 'Accepted'] | ['s474283370', 's780645013'] | [11036.0, 12588.0] | [145.0, 407.0] | [133, 169] |
p03347 | u536113865 | 2,000 | 1,048,576 | There is a sequence X of length N, where every element is initially 0. Let X_i denote the i-th element of X. You are given a sequence A of length N. The i-th element of A is A_i. Determine if we can make X equal to A by repeating the operation below. If we can, find the minimum number of operations required. * Choo... | ['n = int(input())\nx = [int(input()) for _ in range(n)]\nf = 0\n\nif x[0]>0: f = 1\nfor i in range(n-1):\n if x[i]+1 < x[i+1]: f = 1\nimport sys\nif f:\n print(-1)\n sys.exit()\nans = 0\nfor i in range(n-1):\n if x[i+1] == x[i]+1:\n ans += 1\n else:\n ans += x[i+1]\n print(ans)\nprint(a... | ['Wrong Answer', 'Accepted'] | ['s247317324', 's534397602'] | [13220.0, 11052.0] | [597.0, 426.0] | [303, 288] |
p03347 | u648881683 | 2,000 | 1,048,576 | There is a sequence X of length N, where every element is initially 0. Let X_i denote the i-th element of X. You are given a sequence A of length N. The i-th element of A is A_i. Determine if we can make X equal to A by repeating the operation below. If we can, find the minimum number of operations required. * Choo... | ["import bisect, collections, copy, heapq, itertools, math, string, sys\ninput = lambda: sys.stdin.readline().rstrip() \nsys.setrecursionlimit(10**7)\nINF = float('inf')\ndef I(): return int(input())\ndef F(): return float(input())\ndef SS(): return input()\ndef LI(): return [int(x) for x in input().split()]\ndef LI_()... | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s730766422', 's992666119', 's962085381'] | [19304.0, 19416.0, 19396.0] | [166.0, 166.0, 174.0] | [1280, 1199, 1202] |
p03347 | u667024514 | 2,000 | 1,048,576 | There is a sequence X of length N, where every element is initially 0. Let X_i denote the i-th element of X. You are given a sequence A of length N. The i-th element of A is A_i. Determine if we can make X equal to A by repeating the operation below. If we can, find the minimum number of operations required. * Choo... | ['import math\nn = int(input())\nlis = []\nfor i in range(n):lis.append(int(input()))\nif lis[0] != 0:\n print("-1")\n exit()\ncou = 0\nprint(lis,cou)\nfor k in range(n-1):\n if lis[n-(k+1)] > lis[n-(k+2)]:\n cou += math.ceil(lis[n-(k+1)] / (lis[n-(k+2)]+1))\n lis[n-(k+1)] = 0\n else:\n ... | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s081100246', 's233579283', 's354952980', 's499753845', 's823492428', 's848072744', 's357947227'] | [146352.0, 146352.0, 146352.0, 11048.0, 11048.0, 146352.0, 11052.0] | [2104.0, 2104.0, 2104.0, 422.0, 420.0, 2104.0, 419.0] | [418, 515, 517, 242, 244, 474, 242] |
p03347 | u670180528 | 2,000 | 1,048,576 | There is a sequence X of length N, where every element is initially 0. Let X_i denote the i-th element of X. You are given a sequence A of length N. The i-th element of A is A_i. Determine if we can make X equal to A by repeating the operation below. If we can, find the minimum number of operations required. * Choo... | ['n, *a = map(int, open(0).read().split())\nans = 0\nif a[0] != 0:\n\tprint(-1)\n\texit()\nfor x, y in zip(a, a[1:]):\n\tif x + 1 < y:\n\t\tprint(-1)\n\t\texit()\n\tif x >= y:\n\t\tans += x\nprint(ans)\n', 'n, *a = map(int, open(0).read().split())\nans = 0\nif a[0] != 0:\n\tprint(-1)\n\texit()\nfor x, y in zip(a, a[1:]... | ['Wrong Answer', 'Accepted'] | ['s357460852', 's963702947'] | [25140.0, 25132.0] | [112.0, 110.0] | [179, 183] |
p03347 | u736729525 | 2,000 | 1,048,576 | There is a sequence X of length N, where every element is initially 0. Let X_i denote the i-th element of X. You are given a sequence A of length N. The i-th element of A is A_i. Determine if we can make X equal to A by repeating the operation below. If we can, find the minimum number of operations required. * Choo... | ['print(-1)', '\n\ndef solve(N, A):\n c = 0\n z = 0\n if A[0] != 0:\n return -1\n for i in range(1, N):\n if A[i] == 0:\n z = 0\n c+=A[i-1]\n elif A[i-1] < A[i] - 1:\n return -1\n elif A[i] <= i - z:\n if A[i] != A[i-1]+1:\n ... | ['Wrong Answer', 'Accepted'] | ['s483645537', 's103663682'] | [2940.0, 10868.0] | [17.0, 192.0] | [9, 594] |
p03347 | u738835924 | 2,000 | 1,048,576 | There is a sequence X of length N, where every element is initially 0. Let X_i denote the i-th element of X. You are given a sequence A of length N. The i-th element of A is A_i. Determine if we can make X equal to A by repeating the operation below. If we can, find the minimum number of operations required. * Choo... | ['N = int(input())\n\nstart = int(input())\nflag = 0\nif start != 0:\nflag = 1\nt = 0\n\nfor i in range(N-1):\n k = int(input())\n if k == start:\n t += start\n elif k == start + 1:\n t += 1\n start = k\n elif k == 0:\n start = 0\n elif k > start + 1:\n t = -1\n break\n else:\n t += k\n start = k\n\nif flag ==1... | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s491258783', 's924523265', 's745071989'] | [2940.0, 2940.0, 3064.0] | [17.0, 18.0, 423.0] | [312, 312, 313] |
p03347 | u740284863 | 2,000 | 1,048,576 | There is a sequence X of length N, where every element is initially 0. Let X_i denote the i-th element of X. You are given a sequence A of length N. The i-th element of A is A_i. Determine if we can make X equal to A by repeating the operation below. If we can, find the minimum number of operations required. * Choo... | ['n = int(input())\na = [int(input()) for _ in range(n)]\nans = 0\nif a[0] != 0:\n print(-1)\n exit()\nfor i in range(n-1):\n if a[i+1] - a[i] > 1:\n print(-1)\n exit()\nfor _ in range(n):\n if set(a) == set([-1,0]) or set(a) == set([0]):\n break\n i = a.argmax()\n if i == 0:\n ... | ['Runtime Error', 'Accepted'] | ['s673235503', 's285474594'] | [31672.0, 16960.0] | [290.0, 290.0] | [532, 227] |
p03347 | u786607349 | 2,000 | 1,048,576 | There is a sequence X of length N, where every element is initially 0. Let X_i denote the i-th element of X. You are given a sequence A of length N. The i-th element of A is A_i. Determine if we can make X equal to A by repeating the operation below. If we can, find the minimum number of operations required. * Choo... | ['n = int(input())\na = []\nans = 0\nflag = True\nfor i in range(n):\n A = int(input())\n a.append(A)\nnext = 0\nfor i in range(n-1,-1,-1):\n if a[i] == 0:\n next = 0\n continue\n if next - a[i] == 1:\n next = a[i]\n continue\n if next - a[i] >= 2:\n flag = False\n ... | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s196125015', 's937607134', 's895402581'] | [11052.0, 3064.0, 11048.0] | [438.0, 17.0, 444.0] | [437, 429, 417] |
p03347 | u798818115 | 2,000 | 1,048,576 | There is a sequence X of length N, where every element is initially 0. Let X_i denote the i-th element of X. You are given a sequence A of length N. The i-th element of A is A_i. Determine if we can make X equal to A by repeating the operation below. If we can, find the minimum number of operations required. * Choo... | ['# coding: utf-8\n# Your code here!\nN=int(input())\nl=[]\nfor i in range(N):\n l.append(int(input()))\n\ndef calc(list):\n num=0\n sum=0\n l.pop(-1)\n l_max=max(list)\n for i in range(1,l_max+1)[::-1]:\n num+=l.count(i)\n sum+=num\n return sum+1\n \n\ntemp=[]\nans=0\njudge=True\n... | ['Wrong Answer', 'Accepted'] | ['s172880075', 's877502166'] | [12564.0, 3064.0] | [2104.0, 473.0] | [697, 397] |
p03347 | u874935184 | 2,000 | 1,048,576 | There is a sequence X of length N, where every element is initially 0. Let X_i denote the i-th element of X. You are given a sequence A of length N. The i-th element of A is A_i. Determine if we can make X equal to A by repeating the operation below. If we can, find the minimum number of operations required. * Choo... | ['n = int(input())\na = []\nfor i in range(n):\n a.append(int(input()))\nif a[0] != 0:\n print("-1")\nelse:\n v = []\n for i in range(1, len(a)):\n v.append((a[i], -i))\n v.sort()\n x = [0] * len(a)\n wala = False\n for y in v:\n #print(y)\n #print(x)\n if x[-y[1]] ==... | ['Wrong Answer', 'Accepted'] | ['s136065637', 's981236376'] | [33320.0, 17704.0] | [647.0, 523.0] | [537, 633] |
p03347 | u926295427 | 2,000 | 1,048,576 | There is a sequence X of length N, where every element is initially 0. Let X_i denote the i-th element of X. You are given a sequence A of length N. The i-th element of A is A_i. Determine if we can make X equal to A by repeating the operation below. If we can, find the minimum number of operations required. * Choo... | ["#!python\n# -*- coding: utf-8 -*-\n\n\ndef main():\n N = int(input())\n A = [int(input()) for i in range(N)]\n X = [0 for i in range(N)]\n\n if A[0] != 0:\n print(-1)\n return\n\n count = 0\n\n for i in range(N - 1, -1, -1):\n X[i] = X[i + 1] - 1\n if A[i] == X[i]:\n ... | ['Runtime Error', 'Accepted'] | ['s211196557', 's236468745'] | [12636.0, 18864.0] | [338.0, 465.0] | [417, 525] |
p03348 | u226155577 | 2,000 | 1,048,576 | Coloring of the vertices of a tree G is called a _good coloring_ when, for every pair of two vertices u and v painted in the same color, picking u as the root and picking v as the root would result in isomorphic rooted trees. Also, the _colorfulness_ of G is defined as the minimum possible number of different colors u... | ['N = int(input())\nG = [[] for i in range(N)]\nE9 = []\nfor i in range(N-1):\n a, b = map(int, input().split())\n G[a-1].append(b-1)\n G[b-1].append(a-1)\n E9.append((a-1, b-1))\n\ndef encode(v, p):\n res = []\n tmp = []\n l = 0\n P = []\n def edfs(v, p):\n res = [0]\n cs = []\... | ['Runtime Error', 'Accepted'] | ['s696315189', 's886102396'] | [3700.0, 3444.0] | [28.0, 30.0] | [3266, 1458] |
p03355 | u007765868 | 2,000 | 1,048,576 | You are given a string s. Among the **different** substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` are substrings of s, while `ac`, `z` and an empty string are not. A... | ['string = input()\nk = int(input())\nif len(string) >= k:\n substrs = set()\n ls = sorted(list(string))\n for i in range(5):\n for s, c in enumerate(string):\n if c == ls[i]:\n for l in range(1, 5+1):\n substrs.add(string[s:s+l])\n substrs = list(substrs)... | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s714340202', 's865255115', 's438884404'] | [3188.0, 3188.0, 3188.0] | [69.0, 67.0, 67.0] | [578, 578, 585] |
p03355 | u021548497 | 2,000 | 1,048,576 | You are given a string s. Among the **different** substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` are substrings of s, while `ac`, `z` and an empty string are not. A... | ['def change(n, word):\n for i in range(len(ans)-1, n, -1):\n ans[i] = ans[i-1]\n ans[n] = word\n\ns = input()\nk = int(input())\np = min(len(s), k)\nkey = s[:p]\n\nfor i in range(1, len(s)+1-p):\n if key > s[i:i+k]:\n key = s[i:i+k]\n\nans = [0]*k\nfor i in range(k):\n if i < p:\n ans[i] = key[:i+... | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s053246373', 's441881130', 's689511611'] | [3064.0, 3064.0, 3064.0] | [18.0, 18.0, 59.0] | [553, 551, 357] |
p03355 | u021916304 | 2,000 | 1,048,576 | You are given a string s. Among the **different** substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` are substrings of s, while `ac`, `z` and an empty string are not. A... | ['s = list(input())\nse = (s)\nk = int(input())\nn = len(s)\n\nse = set()\nfor i in range(n):\n for j in range(i+1,i+1+k):\n# print(i,j,s[i:j])\n se.add(s[i:j])\n#print(se)\nl = sorted(list(se))\nprint(l[k-1])\n \n\n\n\n\n\n\n\n\n\n\n#TLE \n', 's = input()\nse = (s)\nk = int(input())\nn = len(s)... | ['Runtime Error', 'Accepted'] | ['s199975521', 's791721338'] | [3064.0, 4592.0] | [18.0, 35.0] | [400, 394] |
p03355 | u039623862 | 2,000 | 1,048,576 | You are given a string s. Among the **different** substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` are substrings of s, while `ac`, `z` and an empty string are not. A... | ["ALPHABETS = 26\n\nORD_A = ord('a')\n\n# fast io\nimport sys\nS,K = sys.stdin.readlines()[:2]\n\nS = [ord(c)-ORD_A for c in S]\nwhile S[-1] < 0:\n S.pop()\n\n\nN = len(S)\nK = int(K)\n\ndp = [None]*(N+1)\ndp[N] = 0\nindices = [N]*ALPHABETS\ns = 1\n\nimport sys\n\nold = 1\n\nfor i,c in enumerate(reversed(S)):\n dp[i]... | ['Wrong Answer', 'Accepted'] | ['s212687066', 's746783701'] | [3316.0, 3960.0] | [20.0, 66.0] | [960, 357] |
p03355 | u054514819 | 2,000 | 1,048,576 | You are given a string s. Among the **different** substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` are substrings of s, while `ac`, `z` and an empty string are not. A... | ['s = str(input())\nK = int(input())\n\nlis = list(set(list(s)))\nlis.sort()\n\nans_lis = []\nfor i in range(min(5, len(lis))):\n i = lis[i]\n s2 = s\n while 1:\n idx = s2.find(i)\n if idx==-1:\n break\n ans_lis += [s2[idx:idx+l+1] for l in range(min(5, len(s2)-idx-1))]\n ... | ['Runtime Error', 'Accepted'] | ['s823025276', 's147805986'] | [4468.0, 4468.0] | [34.0, 34.0] | [381, 381] |
p03355 | u064408584 | 2,000 | 1,048,576 | You are given a string s. Among the **different** substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` are substrings of s, while `ac`, `z` and an empty string are not. A... | ['import copy\n\nn,m=map(int, input().split())\np=list(map(int, input().split()))\nq=list()\nfor i in range(m):\n q.append(set(map(int, input().split())))\ncount=0\nwhile count!=5000:\n a=q.pop()\n for j in q:\n if len(j&a) != 0:\n j |=a\n count=0\n break\n else:q=[a]... | ['Runtime Error', 'Accepted'] | ['s688945571', 's554733978'] | [3572.0, 5140.0] | [24.0, 30.0] | [568, 247] |
p03355 | u069838609 | 2,000 | 1,048,576 | You are given a string s. Among the **different** substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` are substrings of s, while `ac`, `z` and an empty string are not. A... | ['def brute_force(s, K):\n substring_set = set()\n\n \n for start in range(len(s)):\n \n for length in range(1, 6):\n substring = s[start:start+length]\n substring_set.add(substring)\n\n substring_list = sorted(list(substring_set))\n print(substring_list)\n print(su... | ['Runtime Error', 'Accepted'] | ['s872254152', 's367967374'] | [2940.0, 4592.0] | [17.0, 32.0] | [385, 390] |
p03355 | u089142196 | 2,000 | 1,048,576 | You are given a string s. Among the **different** substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` are substrings of s, while `ac`, `z` and an empty string are not. A... | ['s=input()\nK=int(input())\nN=len(s)\ntmp=set()\n\nfor i in range(N):\n p=min(i+K,N)\n for j in range(i+1,p+1):\n t= s[i:j]\n print(i,j,t)\n tmp.add(t)\n \nlis=sorted(tmp)\n#print(lis)\nprint(lis[K-1])\n', 's=input()\nK=int(input())\nN=len(s)\ntmp=set()\n\nfor i in range(N):\n for j in range(K):\n t=... | ['Wrong Answer', 'Accepted'] | ['s795666073', 's864497843'] | [5244.0, 4464.0] | [80.0, 36.0] | [201, 185] |
p03355 | u106778233 | 2,000 | 1,048,576 | You are given a string s. Among the **different** substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` are substrings of s, while `ac`, `z` and an empty string are not. A... | ["from collections import deque \ndef k_sub():\n s=input()\n k=int(input())\n dq=deque()\n for i in range(1,len(s)+1):\n for j in range(k):\n a.append(s[j:j+i])\n a.sort()\n print(a[k-1])\nif __name__=='__main__':\n k_sub()", 's=input();k=int(input()) \n\na=sorted({s[i:i+j+1] f... | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s146528196', 's304924100', 's871879203', 's919299037'] | [3316.0, 2940.0, 4464.0, 4464.0] | [21.0, 17.0, 25.0, 32.0] | [249, 108, 106, 103] |
p03355 | u123824541 | 2,000 | 1,048,576 | You are given a string s. Among the **different** substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` are substrings of s, while `ac`, `z` and an empty string are not. A... | ['S = list(input())\nK = int(input())\nx = set()\n\nfor i in range(len(S)):\n for j in range(1,min(len(S) - i + 1, K + 1)):\n x.add(S[i:i + j])\n\nx = list(x)\nx.sort()\nprint(x[K - 1])', 'S = input()\nK = int(input())\nx = set()\n\nfor i in range(len(S)):\n for j in range(1,min(len(S) - i + 1, K + 1)):\n ... | ['Runtime Error', 'Accepted'] | ['s962264719', 's534164058'] | [3060.0, 4464.0] | [18.0, 36.0] | [183, 177] |
p03355 | u129836004 | 2,000 | 1,048,576 | You are given a string s. Among the **different** substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` are substrings of s, while `ac`, `z` and an empty string are not. A... | ['s = input()\nK = int(input())\nans = []\nfor i in range(len(s)):\n for k in range(i+1, len(s)):\n ans.append(s[i:k])\nans = set(ans)\nans = list(ans)\nans.sort()\nprint(ans[K-1])\n ', 's = input()\nans = set()\nk = int(input())\nfor i in range(len(s)):\n for j in range(1, k+1):\n ans.add(s[... | ['Runtime Error', 'Accepted'] | ['s042423052', 's796493608'] | [3060.0, 4592.0] | [2826.0, 35.0] | [188, 148] |
p03355 | u139501158 | 2,000 | 1,048,576 | You are given a string s. Among the **different** substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` are substrings of s, while `ac`, `z` and an empty string are not. A... | ['import numpy as np\n\ns = input()\nK = int(input())\nL = len(s)\n\ncandidate = []\n\nfor l in range(1, K + 1):\n for j in range(0, L - l):\n candidate.append(s[j:j+l])\n\nprint(np.sort(candidate)[K-1])', 'import numpy as np\n\ns = input()\nK = int(input())\nL = len(s)\n\ncandidate = []\n\nfor l in range(1, ... | ['Runtime Error', 'Accepted'] | ['s289836647', 's413935054'] | [22272.0, 14296.0] | [315.0, 160.0] | [199, 236] |
p03355 | u189023301 | 2,000 | 1,048,576 | You are given a string s. Among the **different** substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` are substrings of s, while `ac`, `z` and an empty string are not. A... | ['from itertools import combinations\nfrom collections import deque\ns = input()\nn = int(input())\n\nle = len(s)\nseed = tuple(combinations(range(le + 1), 2))\n\nres = deque()\nres.append("zzzzzzzzzzzzzzzzzzzzzzz")\nres.append("zzzzzzzzzzzzzzzzzzzzzzz")\nres.append("zzzzzzzzzzzzzzzzzzzzzzz")\nres.append("zzzzzzzzzzzzz... | ['Wrong Answer', 'Accepted'] | ['s090428194', 's985489755'] | [741688.0, 3064.0] | [2152.0, 19.0] | [559, 283] |
p03355 | u248856154 | 2,000 | 1,048,576 | You are given a string s. Among the **different** substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` are substrings of s, while `ac`, `z` and an empty string are not. A... | ['import numpy as np\nN, M = list(map(int, input().split()))\np = list(map(int, input().split()))\nx = []\ny = []\nfor _ in range(M):\n xi, yi = list(map(int, input().split()))\n x.append(xi - 1)\n y.append(yi - 1)\n\ndef count(l):\n out = 0\n for i, v in enumerate(l):\n if i + 1 == v:\n ... | ['Runtime Error', 'Accepted'] | ['s509064309', 's858059568'] | [3064.0, 14296.0] | [17.0, 161.0] | [924, 236] |
p03355 | u311636831 | 2,000 | 1,048,576 | You are given a string s. Among the **different** substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` are substrings of s, while `ac`, `z` and an empty string are not. A... | ['#s=input()\n#N=int(input())\ns="atcoderandatcodeer"\nN=5\nD={}\n\nif(len(s)<=10):\n for i in range(1,len(s)+1):\n for j in range(len(s)):\n if D.get(s[j:j+i],None) == None:\n D[s[j:j+i]]=1\n D=sorted(D)\n print(D[N-1])\n exit()\nelse:\n t=sorted(s)\n i=0\n k=0\n ... | ['Wrong Answer', 'Accepted'] | ['s997627416', 's419802099'] | [3064.0, 3188.0] | [17.0, 40.0] | [645, 650] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.