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
p03745
u212328220
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
["N = int(input())\nalst = list(map(int, input().split()))\n\nnow = 'increase' or 'decrease'\ncnt = 1\nfor i in range(1, N):\n x = now\n if alst[i] - alst[i - 1] > 0:\n tmp = 'increase'\n else:\n tmp = 'decrease'\n\n if tmp != x:\n cnt += 1\n x = tmp\n\nprint(cnt)\n", "n = int(input())\nal = list(map(int, input().split()))\n\nif n == 1:\n print(1)\n exit()\n \nif al[1] > al[0]:\n now = 'U'\nelif al[1] < al[0]:\n now = 'D'\nelse:\n now = 'E'\n\ncnt = 1\nfor i in range(2, n):\n if now == 'U':\n if al[i] > al[i-1] or al[i] == 'E':\n now = 'U'\n elif al[i] < al[i-1]:\n cnt += 1\n i += 1\n now = 'E'\n elif now == 'D':\n if al[i] < al[i-1] or al[i] == 'E':\n now = 'D'\n elif al[i] > al[i-1]:\n cnt += 1\n now = 'E'\n elif now == 'E':\n if al[i] == al[i - 1]:\n now = 'E'\n elif al[i] > al[i - 1]:\n now = 'U'\n elif al[i] < al[i - 1]:\n now = 'D'\nprint(cnt)\n"]
['Wrong Answer', 'Accepted']
['s884163036', 's575975307']
[14228.0, 14100.0]
[83.0, 93.0]
[287, 742]
p03745
u223904637
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['n=int(input())\nl=list(map(int,input().split()))\nif n<=2:\n print(1)\n exit()\nyt=[0]*n\nfor i in range(n-1):\n if l[i]<l[i+1]:\n yt[i]=1\n elif l[i]>l[i+1]:\n yt[i]=-1\n elif i!=0:\n l[i]=l[i-1]\nans=0\nfor i in range(n-1):\n if l[i]*l[i+1]==-1:\n ans+=1\n if i>1 and l[i-1]*l[i]==-1:\n ans-=1\nprint(ans)\n', 'n=int(input())\nl=list(map(int,input().split()))\nif n<=2:\n print(1)\n exit()\nyt=[0]*n\nfor i in range(n-1):\n if l[i]<l[i+1]:\n yt[i]=1\n elif l[i]>l[i+1]:\n yt[i]=-1\n elif i!=0:\n yt[i]=yt[i-1]\nans=0\nfor i in range(n-1):\n if yt[i]*yt[i+1]==-1:\n ans+=1\n if i>1 and yt[i-1]*yt[i]==-1:\n ans-=1\nprint(ans)\n', 'n=int(input())\nl=list(map(int,input().split()))\nif n<=2:\n print(1)\n exit()\nyt=[0]*n\nfor i in range(n-1):\n if l[i]<l[i+1]:\n yt[i]=1\n elif l[i]>l[i+1]:\n yt[i]=-1\n elif i!=0:\n l[i]=l[i-1]\nans=0\nfor i in range(n-1):\n if l[i]*l[i+1]==-1:\n ans+=1\nprint(ans)\n', 'n=int(input())\na=list(map(int, input().split()))\nf=None \ns=1\nfor i in range(n-1):\n if a[i]==a[i+1]:\n pass\n elif f==None:\n f=(a[i]<a[i+1]) \n elif f==(a[i]<a[i+1]):\n pass\n else:\n s+=1\n f=None \nprint(s)']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s194392908', 's599023671', 's959729765', 's302221424']
[14436.0, 14436.0, 14252.0, 14252.0]
[108.0, 113.0, 111.0, 83.0]
[353, 359, 298, 246]
p03745
u227082700
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['n=int(input())\na=list(map(int,input().split()))\nb=0\nans=1\nfor i in range(n-1):\n if a[i]<a[i+1] and b==-1:\n ans+=1\n b=1\n if a[i]>a[i+1] and b==1:\n ans+=1\n b=-1\nprint(ans)', 'n=int(input())\na=list(map(int,input().split()))\nb=0\nans=1\nfor i in range(n-1):\n if b==0 and a[i]!=a[i+1]:\n if a[i]<a[i+1]:b=1\n else:b=-1\n elif(a[i]<a[i+1] and b==-1)or(a[i]>a[i+1] and b==1):\n ans+=1\n b=0\nprint(ans)']
['Wrong Answer', 'Accepted']
['s519719289', 's047217025']
[15020.0, 14228.0]
[76.0, 84.0]
[183, 228]
p03745
u238510421
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['C = input()\nN = list(map(int,input().split()))\n\ncount = 0\na = 0\nb = 0\nfor i in range(len(N)-1):\n if N[i+1] - N[i] > 0:\n b = 1\n elif N[i+1] - N[i] < 0:\n b = -1\n else:\n b = 0\n \n if a == 0:\n a = b \n elif a == b:\n pass\n elif a == b * (-1):\n count += 1\n else:\n pass\n\nprint(count+1)', 'C = input()\nN = list(map(int,input().split()))\n\ncount = 0\na = 0\nb = 0\nfor i in range(len(N)-1):\n if N[i+1] - N[i] > 0:\n b = 1\n elif N[i+1] - N[i] < 0:\n b = -1\n else:\n b = 0\n \n if a == 0:\n a = b \n elif a == b:\n pass\n elif a == b * (-1):\n count += 1\n a = 0\n else:\n pass\n\nprint(count+1)\n ']
['Wrong Answer', 'Accepted']
['s619177644', 's283654342']
[14252.0, 14252.0]
[92.0, 94.0]
[354, 373]
p03745
u243492642
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['# coding: utf-8\nimport array, bisect, collections, heapq, itertools, math, random, re, string, sys, time\nsys.setrecursionlimit(10 ** 7)\nINF = 10 ** 20\nMOD = 10 ** 9 + 7\n \n \ndef II(): return int(input())\ndef ILI(): return list(map(int, input().split()))\ndef IAI(LINE): return [ILI() for __ in range(LINE)]\ndef IDI(): return {key: value for key, value in ILI()}\n \n \ndef solve(N, A):\n flag = 0\n ans = 0\n for i in range(N - 1):\n if A[i] < A[i + 1]:\n if flag == -1:\n ans += 1\n flag = 0\n else:\n flag = 1\n\n if A[i] > A[i + 1]:\n if flag == 1:\n ans += 1\n flag = 0\n else:\n flag = -1\n\n return ans\n\n\ndef main():\n N = II()\n A = ILI()\n print(solve(N, A))\n \n \nif __name__ == "__main__":\n main()\n', '# coding: utf-8\nimport array, bisect, collections, heapq, itertools, math, random, re, string, sys, time\nsys.setrecursionlimit(10 ** 7)\nINF = 10 ** 20\nMOD = 10 ** 9 + 7\n \n \ndef II(): return int(input())\ndef ILI(): return list(map(int, input().split()))\ndef IAI(LINE): return [ILI() for __ in range(LINE)]\ndef IDI(): return {key: value for key, value in ILI()}\n \n \ndef solve(N, A):\n flag = 0\n ans = 1\n for i in range(N - 1):\n if A[i] < A[i + 1]:\n if flag == -1:\n ans += 1\n flag = 0\n else:\n flag = 1\n\n if A[i] > A[i + 1]:\n if flag == 1:\n ans += 1\n flag = 0\n else:\n flag = -1\n\n return ans\n\n\ndef main():\n N = II()\n A = ILI()\n print(solve(N, A))\n \n \nif __name__ == "__main__":\n main()\n']
['Wrong Answer', 'Accepted']
['s123512531', 's197767513']
[15404.0, 15408.0]
[79.0, 77.0]
[852, 852]
p03745
u247211039
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['N=int(input())\nA=list(map(int,input().split()))\n\ncnt = 0\nflag = 0\n\nfor i in range(N-1):\n #print(A[i+1]-A[i])\n if A[i+1]-A[i] >= 0:\n if flag == 1:\n cnt +=0\n elif flag == -1:\n cnt +=1\n flag = 0\n elif flag ==0:\n flag = 1\n elif A[i+1]-A[i] <= 0:\n if flag == 1:\n cnt +=1\n flag =0\n elif flag ==-1:\n cnt +=1\n elif flag ==0:\n flag = -1\n \n \nprint(cnt+1)', 'N=int(input())\nA=list(map(int, input().split()))\n\nflag=0 \ncnt=0\n\nfor i in range(N-1):\n if A[i+1]-A[i] >0:\n if flag ==1:\n continue\n elif flag ==-1:\n flag =0\n cnt+=1\n elif flag ==0:\n flag =1\n elif A[i+1]-A[i] <0:\n if flag ==-1:\n continue\n elif flag ==1:\n flag =0\n cnt+=1\n elif flag ==0:\n flag =-1\n elif A[i+1]-A[i] ==0:\n if flag == 0:\n flag = 0\n elif flag ==1:\n flag =1\n elif flag ==-1:\n flag =-1\nprint(cnt+1) ']
['Wrong Answer', 'Accepted']
['s089568481', 's868141911']
[14252.0, 20160.0]
[93.0, 89.0]
[413, 740]
p03745
u276204978
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['N = int(input())\nA = list(map(int, input().split()))\n\ncnt = 1\ninc = False\ndec = False\np = A.pop(0)\n\nfor Ai in A:\n if (not inc) and (not dec):\n if Ai < p:\n dec = True\n else:\n inc = True\n elif inc:\n if Ai < p:\n cnt += 1\n inc = False\n elif dec:\n if Ai > p:\n cnt += 1\n dec = False\n p = Ai\n \nprint(cnt)', 'N = int(input())\nA = list(map(int, input().split()))\n\ncnt = 1\ninc = False\ndec = False\np = A.pop(0)\n\nfor Ai in A:\n if (not inc) and (not dec):\n if Ai < p:\n dec = True\n elif Ai > p:\n inc = True\n elif inc:\n if Ai < p:\n cnt += 1\n inc = False\n elif dec:\n if Ai > p:\n cnt += 1\n dec = False\n p = Ai\n \nprint(cnt)']
['Wrong Answer', 'Accepted']
['s571934301', 's756694383']
[14252.0, 14252.0]
[65.0, 65.0]
[406, 413]
p03745
u292735000
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['n = int(input())\na = list(map(int, input().split()))\n\n\nif a[1] > a[0]:\n inc = True\nelse:\n inc = False\ncount = 1\nfor i in range(2, len(a)):\n if a[i] > a[i - 1]:\n if inc:\n pass\n else:\n count += 1\n inc = False\n elif a[i] < a[i - 1]:\n if inc:\n count += 1\n inc = True\n else:\n pass\n\nprint(count)', 'n = int(input())\na = list(map(int, input().split()))\n\ndiff_list = [a[i] - a[i - 1] for i in range(1, len(a))]\nprint(diff_list)\n\ndiff = a[1] - a[0]\ncount = 1\nfor i in range(2, len(a)):\n if a[i] - a[i - 1] != 1:\n count += 1\n elif a[i] - a[i - 1] == 1:\n if diff != 1:\n count += 1\n diff = 1\n elif a[i] - a[i - 1] == -1:\n if diff != -1:\n count += 1\n diff = -1\n\nprint(count)', 'n = int(input())\na = list(map(int, input().split()))\n\nflg_inc = False\nflg_dec = False\n\ncount = 1\nfor i in range(1, len(a)):\n if a[i] < a[i - 1]:\n flg_dec = True\n if flg_inc:\n count += 1\n flg_inc = False\n flg_dec = False\n elif a[i] > a[i - 1]:\n flg_inc = True\n if flg_dec:\n count += 1\n flg_inc = False\n flg_dec = False\n\nprint(count)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s065706240', 's837269908', 's471018211']
[14224.0, 15116.0, 14252.0]
[79.0, 95.0, 78.0]
[395, 435, 431]
p03745
u298520807
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['from otsutil.funcs import parg\n_ = input()\nA = map(int, input().split())\nprev = next(A)\nup = None\ncount = 1\nfor i in A:\n if prev < i:\n if up is None:\n up = True\n elif not up:\n count += 1\n up = None\n else:\n if up is None:\n up = False\n elif up:\n count += 1\n up = None\n prev = i\nprint(count)\n', '_ = input()\nA = map(int, input().split())\nprev = next(A)\nup = None\ncount = 1\nfor i in A:\n if prev < i:\n if up is None:\n up = True\n elif not up:\n count += 1\n up = None\n elif prev > i:\n if up is None:\n up = False\n elif up:\n count += 1\n up = None\n prev = i\nprint(count)\n']
['Runtime Error', 'Accepted']
['s520266148', 's558129160']
[3060.0, 11100.0]
[17.0, 64.0]
[392, 370]
p03745
u306412379
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['n = int(input())\naa =list(map(int, input().split()))\n\nlist1 =[0] * n\ncnt = 1 \nfor i in range(n-1):\n if aa[i+1] > aa[i]:\n list1[i+1] = 1\n elif aa[i+1] < aa[i]:\n list1[i+1] = -1\n elif aa[i+1] == aa[i]: \n list1[i+1] = 0\n\nprint(list1) \nwhile 1 in list1 and -1 in list1:\n del list1[:max(list1.index(1), list1.index(-1))]\n list1[0] == 0\n cnt += 1\n \nprint(cnt)', 'n = int(input())\naa =list(map(int, input().split()))\n\nlist1 =[0] * n\nlist1[0] = 1\n\nif n >1:\n list1[1] = 1\n\nfor i in range(2,n):\n if list1[i-2] == list1[i-1]:\n if (aa[i] - aa[i-1]) * (aa[i-1] -aa[i-2]) < 0:\n list1[i] = list1[i-1] + 1\n elif (aa[i] - aa[i-1]) * (aa[i-1] -aa[i-2]) > 0:\n list1[i] = list1[i-1]\n elif (aa[i] - aa[i-1]) * (aa[i-1] -aa[i-2]) == 0:\n if aa[i] == aa[i-1]:\n list1[i] = list1[i-1]\n else:\n list1[i] = list1[i-1] + 1\n else:\n list1[i] = list1[i-1]\n \nprint(list1[n-1])', 'n = int(input())\naa =list(map(int, input().split()))\n\nlist1 =[0] * n\ncnt = 1 \nfor i in range(n-1):\n if aa[i+1] > aa[i]:\n list1[i+1] = 1\n elif aa[i+1] < aa[i]:\n list1[i+1] = -1\n elif aa[i+1] == aa[i]: \n list1[i+1] = 0\n\nwhile 1 in list1 and -1 in list1:\n del list1[:max(list1.index(1), list1.index(-1))]\n list1[0] = 0\n cnt += 1\n \nprint(cnt)\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s690712781', 's734434932', 's287977845']
[20292.0, 20384.0, 20432.0]
[527.0, 163.0, 354.0]
[376, 537, 359]
p03745
u327310087
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['n = int(input())\na = list(map(int, input().split()))\n\nslash = 0\nfor i in range(n):\n if i <= n - 2 and a[i] < a[i + 1]: # up\n while i <= n - 2 and a[i] <= a[i + 1]:\n i += 1\n slash += 1\n continue\n elif i <= n - 2 and a[i] > a[i + 1]: # down\n while i <= n - 2 and a[i] >= a[i + 1]:\n i += 1\n slash += 1\n\nprint(slash + 1)\n', 'n = int(input())\na = list(map(int, input().split()))\n\nflg = None \nslash = 0\nfor i in range(n - 1):\n if a[i] == a[i + 1]:\n pass\n elif flg == None:\n flg = (a[i] < a[i + 1]) \n elif flg == (a[i] < a[i + 1]):\n pass\n else:\n slash += 1\n flg = None \n\nprint(slash + 1)\n\n']
['Wrong Answer', 'Accepted']
['s353669823', 's879254955']
[14252.0, 15020.0]
[2104.0, 85.0]
[380, 308]
p03745
u329749432
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
["n = int(input())\na = [int(i) for i in input().split()]\n\ncount = 1\nstate = 'none'\nb = [a[0]]\n\nfor i in range(1,n):\n if state=='none':\n before=b.pop()\n now = a[i]\n if before<now:\n b.append(now)\n state='incr'\n elif before>now:\n b.append(now)\n state='decr'\n else:\n b.append(now)\n elif state=='incr':\n before=b.pop()\n now = a[i]\n if before<=now:\n b.append(now)\n else:\n b=[now]\n state='none'\n count+=1\n elif state=='decr':\n before=b.pop()\n now = a[i]\n if before=>now:\n b.append(now)\n else:\n b=[now]\n state='none'\n count+=1\nprint(count)\n", "n = int(input())\na = [int(i) for i in input().split()]\n\ncount = 1\nstate = 'none'\nb = [a[0]]\n\nfor i in range(1,n):\n if state=='none':\n before=b.pop()\n now = a[i]\n if before<now:\n b.append(now)\n state='incr'\n elif before>now:\n b.append(now)\n state='decr'\n else:\n b.append(now)\n elif state=='incr':\n before=b.pop()\n now = a[i]\n if before<=now:\n b.append(now)\n else:\n b=[now]\n state='none'\n count+=1\n elif state=='decr':\n before=b.pop()\n now = a[i]\n if before>=now:\n b.append(now)\n else:\n b=[now]\n state='none'\n count+=1\nprint(count)\n"]
['Runtime Error', 'Accepted']
['s555068359', 's140035292']
[3064.0, 14480.0]
[17.0, 95.0]
[773, 773]
p03745
u339199690
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['N = int(input())\nA = list(map(int, input().split()))\n\ninc = 0\nres = 0\nfor i in range(N - 1):\n if A[i] < A[i + 1]:\n if inc == 1:\n continue\n elif inc == 0:\n inc = 1\n else:\n res += 1\n inc = 0\n elif A[i] > A[i + 1]:\n if inc == -1:\n continue\n elif inc == 0:\n inc = -1\n else:\n res += 1\n inc = 0\nprint(res)', 'N = int(input())\nA = list(map(int, input().split()))\n\ninc = 0\nres = 0\nfor i in range(N - 1):\n if A[i] < A[i + 1]:\n if inc == 1:\n continue\n elif inc == 0:\n inc = 1\n else:\n res += 1\n inc = 0\n elif A[i] > A[i + 1]:\n if inc == -1:\n continue\n elif inc == 0:\n inc = -1\n else:\n res += 1\n inc = 0\nprint(res + 1)']
['Wrong Answer', 'Accepted']
['s039087295', 's937522029']
[14224.0, 14228.0]
[79.0, 80.0]
[435, 439]
p03745
u344122377
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['#include <bits/stdc++.h>\nusing namespace std;\n#ifdef LOCAL_DEBUG\n #include "LOCAL_DEBUG.hpp"\n#endif\n\nconst int INF = 1LL << 60;\n\nsigned main(){\n\n int n; cin >> n;\n vector<int> a(n);\n for(int i = 0; i < n; i++){\n cin >> a[i];\n }\n\n int ans = 0;\n for(int i = 0; i < n; i++){\n int right1 = i, right2 = i;\n while(right1+1 < n && a[right1] <= a[right1+1]) right1++;\n while(right2+1 < n && a[right2] >= a[right2+1]) right2++;\n i = max(right1, right2);\n ans++;\n }\n cout << ans << endl;\n\n return 0;\n}', 'N = int(input())\nA = list(map(int, input().split()))\n\ni = 0\nans = 0\nfor a in A:\n right, right2 = i, i\n while right+1 < N and A[right] <= A[right+1]: right += 1\n while right2+1 < N and A[right2] >= A[right2+1]: right2 += 1\n i = max(right, right2) + 1\n ans += 1\n if i >= N: break\nprint(ans)']
['Runtime Error', 'Accepted']
['s979337024', 's559787518']
[2940.0, 14252.0]
[17.0, 100.0]
[540, 294]
p03745
u348293370
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['n = int(input())\nnum_list = list(map(int, input().split()))\nans = 1\ncnt_list = [0] * n\na = int()\n\nfor i in range(1,n):\n if num_list[i-1] > num_list[i]:\n cnt_list[i] = -1\n if num_list[i-1] < num_list[i]:\n cnt_list[i] = 1\n\nfor i in range(1,n-1):\n if not cnt_list[i] == 0:\n a = cnt_list[i]\n break\n\nfor i in range(1,n-1):\n if cnt_list[i] == -1 * a:\n if cnt_list[i-1] == a:\n ans+=1\n cnt_list[i] = 0\n\nprint(ans+1)', 'n = int(input())\nnum_list = list(map(int, input().split()))\nans = 1\ncnt_list = [0] * n\na = int()\n\nfor i in range(1,n):\n if num_list[i-1] > num_list[i]:\n cnt_list[i] = -1\n if num_list[i-1] < num_list[i]:\n cnt_list[i] = 1\n\nwhile 1 in cnt_list and -1 in cnt_list:\n del cnt_list[:max(cnt_list.index(1),cnt_list.index(-1))]\n cnt_list[0] = 0\n ans += 1\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s464467169', 's799778675']
[20004.0, 20124.0]
[93.0, 359.0]
[476, 386]
p03745
u354638986
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
["def sign(x):\n if x < 0:\n return -1\n elif x == 0:\n return 0\n else:\n return 1\n\n\ndef main():\n n = int(input())\n a = list(map(int, input().split()))\n\n cnt, idx = 1, 1\n if 1 < n:\n flg = a[idx] - a[idx-1]\n while idx <= n - 1:\n if sign(a[idx]-a[idx-1]):\n if flg != sign(a[idx]-a[idx-1]):\n cnt += 1\n idx += 1\n if idx < n:\n flg = sign(a[idx]-a[idx-1])\n\n idx += 1\n\n print(cnt)\n\n\nif __name__ == '__main__':\n main()\n", 'def sign(x):\n if x < 0:\n return -1\n elif x == 0:\n return 0\n else:\n return 1\n\ndef main():\n n = int(input())\n a = list(map(int, input().split()))\n \n cnt, i = 1, 1\n while i < n - 1:\n if sign(a[i]-a[i-1]) != sign(a[i+1]-a[i]):\n cnt += 1\n i += 1\n i += 1\n \n print(cnt)\n \n \nif __name__ == "__main__":\n main()', "def sign(x):\n if x == 0:\n return 0\n return x // abs(x)\n\n\ndef main():\n n = int(input())\n a = list(map(int, input().split()))\n\n if n == 1:\n print(1)\n\n else:\n cnt = 1\n d = sign(a[1]-a[0])\n for i in range(n-1):\n dd = sign(a[i+1]-a[i])\n if d == 0:\n d = dd\n\n if d != 0 and dd != 0 and d != dd:\n cnt += 1\n if i < n-2:\n d = sign(a[i+2]-a[i+1])\n\n print(cnt)\n\n\nif __name__ == '__main__':\n main()\n"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s378971646', 's512478798', 's884421102']
[14224.0, 14252.0, 14436.0]
[88.0, 94.0, 99.0]
[583, 405, 546]
p03745
u368780724
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['def inpl(): return [int(i) for i in input().split()]\ndef next(v):\n for i in edge[v]:\n if visited[i]:\n continue\n visited[i] = True\n return i\n return -1\n\nfrom collections import defaultdict\nedge = defaultdict(lambda: [])\nN, M = inpl()\nvisited = [False for _ in range(N+1)]\nvisited[1] = True\nfor _ in range(M):\n A,B = inpl()\n edge[A].append(B)\n edge[B].append(A)\nv = 1\nnv = 1\npath = [1]\nwhile nv >= 0:\n nv = next(v)\n path.append(nv)\n v = nv\npath.pop()\npath = list(reversed(path))\nv = 1\nnv = 1\nwhile nv >= 0:\n nv = next(v)\n path.append(nv)\n v = nv\npath.pop()\nprint(len(path))\nprint(*path)', 'def inpl(): return [int(i) for i in input().split()]\n\nN = int(input())\nA = inpl()\nans = 1\nfirst = True\nfor i in range(N-1):\n if first:\n if A[i+1] == A[i]:\n continue\n else:\n c = (A[i+1]-A[i])//abs((A[i+1]-A[i]))\n first = False\n continue\n if c*A[i] > c*A[i+1]:\n ans += 1\n first = True\nprint(ans)']
['Runtime Error', 'Accepted']
['s524572772', 's772600173']
[3316.0, 14252.0]
[21.0, 95.0]
[649, 371]
p03745
u375616706
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['def solve(A, inc):\n\n ans = 1\n N = len(A)\n l = [0]*N\n for i in range(1, N):\n if A[i] - A[i-1] == 0:\n l[i] = 1\n else:\n l[i] = A[i]-A[i-1]\n\n for i in range(1, N):\n if l[i]*l[i-1] < 0:\n l[i] = 0\n ans += 1\n return ans\n\n\nN = int(input())\nA = list(map(int, input().split()))\n\nprint(solve(A, True))\n', 'def solve(A, inc):\n\n ans = 1\n N = len(A)\n l = []\n for i in range(1, N):\n if A[i] > A[i-1]:\n l.append(1)\n elif A[i] < A[i-1]:\n l.append(-1)\n\n for i in range(1, len(l)):\n if l[i]*l[i-1] < 0:\n l[i] = 0\n ans += 1\n return ans\n\n\nN = int(input())\nA = list(map(int, input().split()))\n\nprint(solve(A, True))\n']
['Wrong Answer', 'Accepted']
['s157964674', 's512767451']
[14252.0, 14252.0]
[84.0, 77.0]
[374, 382]
p03745
u391731808
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['N=int(input())\n*A, = map(int,input().split())\n\nans = 0\nl = 0\nud = 0\nfor a in A:\n if l==0:\n ans += 1\n elif l==1:\n if b>a:\n ud = 1\n l+=1\n elif b<a:\n ud = -1\n l+=1\n else:\n if b>a and ud == -1:\n ans += 1\n l = 1\n elif b<a and ud == 1:\n ans += 1\n l = 1\n b = a\nprint(ans)', 'N=int(input())\n*A, = map(int,input().split())\n\nans = 0\nl = 0\nud = 0\nfor a in A:\n if l==0:\n ans += 1\n l+=1\n elif l==1:\n if b<a:\n ud = 1\n l+=1\n elif b>a:\n ud = -1\n l+=1\n else:\n if b<a and ud == -1:\n ans += 1\n l = 1\n elif b>a and ud == 1:\n ans += 1\n l = 1\n b = a\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s646569814', 's876911910']
[14224.0, 14224.0]
[57.0, 74.0]
[323, 333]
p03745
u392319141
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['N = int(input())\nA = list(map(int, input().split()))\n\n\nans = 1\ni = 1\nprev = -1\nwhile i < N - 1:\n if A[i - 1] < A[i] and A[i + 1] < A[i]:\n if i - prev > 1:\n ans += 1\n prev = i\n elif A[i - 1] > A[i] and A[i + 1] > A[i]:\n if i - prev > 1:\n ans += 1\n prev = i\n i += 1\n\nif prev < N:\n ans += 1\nprint(ans)\n', 'N = int(input())\nA = list(map(int, input().split()))\n\n\nans = 1\ni = 1\nprev = -1\nwhile i < N - 1:\n if A[i - 1] < A[i] and A[i + 1] < A[i]:\n if i - prev > 1:\n ans += 1\n prev = i\n elif A[i - 1] > A[i] and A[i + 1] > A[i]:\n if i - prev > 1:\n ans += 1\n prev = i\n i += 1\n\nif prev < N - 1:\n ans += 1\nprint(ans)\n', 'N = int(input())\nA = list(map(int, input().split()))\nB = [A[0]]\n\nfor a in A:\n if B[-1] != a:\n B.append(a)\n\nN = len(B)\nans = 1\nprev = -1\nfor i in range(1, N - 1):\n if B[i - 1] < B[i] and B[i + 1] < B[i]:\n if i - prev > 1:\n ans += 1\n prev = i\n elif B[i - 1] > B[i] and B[i + 1] > B[i]:\n if i - prev > 1:\n ans += 1\n prev = i\n\nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s065020942', 's647183207', 's929950767']
[14228.0, 14224.0, 14436.0]
[105.0, 111.0, 110.0]
[383, 387, 407]
p03745
u404034840
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['import numpy as np\n\nN = int(input())\nA = list(map(int, input().split()))\ncount = 1\nupd = 0\nfor i in range(N-1):\n s0 = np.sign(A[i+1] - A[i])\n if upd == 0:\n upd = s0\n elif s0 != 0 and s0 != upd:\n upd = 0\n count += 1\n print(i,"番目")\nprint(count)', 'import numpy as np\n\nN = int(input())\nA = list(map(int, input().split()))\ncount = 1\nupd = 0\nfor i in range(N-1):\n s0 = np.sign(A[i+1] - A[i])\n if upd == 0:\n upd = s0\n elif s0 != 0 and s0 != upd:\n upd = 0\n count += 1\nprint(count)']
['Wrong Answer', 'Accepted']
['s210920038', 's303226073']
[23124.0, 23088.0]
[588.0, 544.0]
[261, 239]
p03745
u411858517
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['n = int(input())\nl = list(map(int, input().split()))\n\nres = 0\nfor i in range(n-1):\n\tif l[i+1] < l[i]:\n\t\tres += 1\n\nprint(res+1) \t\n', "N = int(input())\nL = list(map(int, input().split()))\n\nans1 = 1\nflag = ''\nfor i in range(1, N):\n if flag == '':\n if L[i] < L[i-1]:\n flag = 'minus'\n elif L[i] > L[i-1]:\n flag = 'plus'\n else:\n flag = ''\n\n if flag == 'plus':\n if L[i] < L[i-1]:\n flag = ''\n ans1 += 1\n elif flag == 'minus':\n if L[i] > L[i-1]:\n flag = ''\n ans1 += 1\n\n\nprint(ans1)"]
['Wrong Answer', 'Accepted']
['s001275653', 's259687835']
[14252.0, 14252.0]
[66.0, 82.0]
[129, 392]
p03745
u425762225
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['import sys\nsys.setrecursionlimit(10**6)\n\nN = int(input())\na = list(map(int,input().split()))\n\n\ndef solve(n,a,c=0,ans=1,prev_da=0):\n if c == n-1:\n return ans\n \n da = a[c+1] - a[c]\n \n if da == 0:\n return(n,a,c+1,ans,prev_da)\n \n elif da > 0 and prev_da < 0:\n return solve(n,a,c+1,ans+1,0)\n \n elif da < 0 and prev_da > 0:\n return solve(n,a,c+1,ans+1,0)\n else:\n return solve(n,a,c+1,ans,da)\n \nprint(solve(N,a))', 'N = int(input())\na = list(map(int,input().split()))\n\nans = 1\nflags=[False,False]\n\nfor i in range(N-1):\n da = a[i+1] - a[i]\n if da > 0:\n flags[0] = True\n elif da < 0:\n flags[1] = True\n \n if all(flags):\n ans += 1\n flags = [False,False]\nprint(ans)\n ']
['Wrong Answer', 'Accepted']
['s113174872', 's855563372']
[130396.0, 20004.0]
[161.0, 85.0]
[495, 268]
p03745
u426108351
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['n = int(input())\na = list(map(int, input().split()))\n\nans = 1\nflag = 0\nbase = -1\ncount = 0\nfor i in range(n):\n if count == 0:\n count += 1\n base = a[i]\n elif count == 1:\n count += 1\n if a[i] < base:\n flag = 0\n elif a[i] > base:\n flag = 1\n else:\n continue\n else:\n if flag == 0:\n if a[i] <= a[i-1]:\n continue\n else:\n count = 1\n base = a[i]\n ans += 1\n else:\n if a[i] >= a[i-1]:\n continue\n else:\n count = 1\n base = a[i]\n ans += 1\n\n ', 'n = int(input())\na = list(map(int, input().split()))\n\nans = 1\nflag = 0\nbase = -1\ncount = 0\nfor i in range(n):\n if count == 0:\n count += 1\n base = a[i]\n elif count == 1:\n count += 1\n if a[i] < base:\n flag = 0\n elif a[i] > base:\n flag = 1\n else:\n continue\n else:\n if flag == 0:\n if a[i] <= a[i-1]:\n continue\n else:\n count = 1\n base = a[i]\n ans += 1\n else:\n if a[i] >= a[i-1]:\n continue\n else:\n count = 1\n base = a[i]\n ans += 1\nprint(ans)\n ', 'n = int(input())\na = list(map(int, input().split()))\n\nans = 1\nflag = 0\nbase = -1\ncount = 0\nfor i in range(n):\n if count == 0:\n count += 1\n base = a[i]\n elif count == 1:\n \n if a[i] < base:\n flag = 0\n count += 1\n elif a[i] > base:\n flag = 1\n count += 1\n else:\n continue\n else:\n if flag == 0:\n if a[i] <= a[i-1]:\n continue\n else:\n count = 1\n base = a[i]\n ans += 1\n else:\n if a[i] >= a[i-1]:\n continue\n else:\n count = 1\n base = a[i]\n ans += 1\nprint(ans)\n \n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s518817976', 's542727376', 's288436178']
[14428.0, 14436.0, 14440.0]
[80.0, 79.0, 80.0]
[552, 562, 587]
p03745
u434208140
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['n=int(input())\na=list(map(int,input()))\nt=1\np=a[0]\nm=0\nfor i in a:\n if(p==i):\n continue\n if(m>0):\n if(i<p):\n t+=1\n m=0\n elif(m<0):\n if(i>p):\n t+=1\n m=0\n else:\n if(i>p):\n m=1\n eif(i<p):\n m=-1\n p=i\nprint(t)', 'n=int(input())\na=list(map(int,input()))\nt=1\np=a[0]\nm=0\nfor i in a:\n if(p==i):\n continue\n if(m>0):\n if(i<p):\n t+=1\n m=0\n elif(m<0):\n if(i>p):\n t+=1\n m=0\n else:\n if(i>p):\n m=1\n elif(i<p):\n m=-1\n p=i\nprint(t)', 'n=int(input())\na=list(map(int,input().split()))\nt=1\np=a[0]\nm=0\nfor i in a:\n if(p==i):\n continue\n if(m>0):\n if(i<p):\n t+=1\n m=0\n elif(m<0):\n if(i>p):\n t+=1\n m=0\n else:\n if(i>p):\n m=1\n elif(i<p):\n m=-1\n p=i\nprint(t)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s555741120', 's835105426', 's366095802']
[3060.0, 5140.0, 14224.0]
[17.0, 20.0, 74.0]
[254, 255, 263]
p03745
u455638863
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['def search(v, A, B, flg, p, c, s):\n if flg[v-1] == 1:\n return c\n# print("v=", v, "flg=", flg, "p=", p, "cnt=", c)\n flg[v-1] = 1\n for idx in A:\n if v == A[idx]:\n c += 1\n if search(B[idx], A, B, flg, p, c, s) == 0:\n return 0\n for idx in B:\n if v == B[idx]:\n c += 1\n if search(A[idx], A, B, flg, p, c, s) == 0:\n return 0\n# for idx in A:\n# if v==A[idx] and flg[B[idx]-1] == 0:\n# return 0\n# for idx in B:\n# if v==B[idx] and flg[A[idx]-1] == 0:\n# return 0\n p.append(v)\n return c+1\n\nstr = input()\nNM = list(map(int,str.split()))\nprint(NM)\nANS = 1\nAB = []\nC = []\nA = []\nB = []\nfor i in range(0,int(NM[1])):\n str = input()\n AB.append(list(map(int,str.split())))\n A.append(AB[i][0])\n B.append(AB[i][1])\n\ne = 0 \n#\n\n#\nfor i in range(0,int(NM[1])): \n flg = [] # Clear the flag list\n for j in range(0,int(NM[0])):\n flg.append(0)\n c = AB[i][0] \n s = c \n p = []\n\n cnt = search(c, A, B, flg, p, 0, s)\n if cnt != 0:\n# print(p)\n print(cnt)\n for i in p:\n print(i)\n break', "N = input()\nstate = 0\nmax = 0\nmin = 0\nprev = 0\nlen = 0\nANS = 1\nS = input()\nA = list(map(int,S.split()))\n \nfor i in range(0,int(N)):\n len = len + 1\n if state in {0}:\t# Initial state\n prev = A[i]\n state = 1\n elif state in {1}: # Newtral state\n if A[i] > prev:\n state = 2\n elif A[i] < prev:\n state = 3\n elif state in {2}: # Acsending state\n if A[i] < prev:\n state = 1\n ANS = ANS + 1\n len = 0\n elif state in {3}: # Descending state\n if A[i] > prev:\n state = 1\n ANS = ANS + 1\n len = 0\n prev = A[i]\n print('s=', state, 'in=', A[i], 'prev=', prev, 'ANS=', ANS, 'len=', len)\nprint(ANS)", 'def search(v, A, B, flg, p, c, s):\n if c > 2:\n print("v=", v, "flg=", flg, "p=", p, "cnt=", c)\n if flg[v-1] == 1:\n return c\n flg[v-1] = 1\n p.append(v)\n c += 1\n for idx in range(len(A)):\n if v == A[idx]:\n cnt = search(B[idx], A, B, flg, p, c, s)\n if cnt != 0:\n return cnt\n else:\n flg[idx] = 0\n return 0\n for idx in range(len(B)):\n if v == B[idx]:\n cnt = search(A[idx], A, B, flg, p, c, s)\n if cnt != 0:\n return cnt\n else:\n flg[idx] = 0\n return 0\n return c\n\n#\n# Main Routine\n#\nstr = input()\nNM = list(map(int,str.split()))\nprint(NM)\nANS = 1\nAB = []\nC = []\nA = []\nB = []\nfor i in range(0,int(NM[1])):\n str = input()\n AB.append(list(map(int,str.split())))\n A.append(AB[i][0])\n B.append(AB[i][1])\n\n#\n\n#\nfor i in range(0,int(NM[1])): \n flg = [] # Clear the flag list\n for j in range(0,int(NM[0])):\n flg.append(0)\n v = AB[i][0] \n s = v \n p = []\n cnt = search(v, A, B, flg, p, 0, s)\n for idx in range(len(A)):\n if s == A[idx] and B[idx] == 1:\n cnt = 0\t# Start vertex doesn\'t satisfy the condition.\n for idx in range(len(B)):\n if s == B[idx] and A[idx] == 1:\n cnt = 0\t# Start vertex doesn\'t satisfy the condition.\n if cnt != 0:\n print(cnt)\t# If all the conditions are met, output the result and stop.\n print(p)\n for i in p:\n print(i)\n break', 'def search(v, A, B, flg, p, c, s):\n# if c > 2:\n# print("v=", v, "flg=", flg, "p=", p, "cnt=", c)\n if flg[v-1] == 1:\n return c\n flg[v-1] = 1\n p.append(v)\n c += 1\n for idx in range(len(A)):\n if v == A[idx]:\n cnt = search(B[idx], A, B, flg, p, c, s)\n if cnt != 0:\n return cnt\n else:\n flg[idx] = 0\n return 0\n for idx in range(len(B)):\n if v == B[idx]:\n cnt = search(A[idx], A, B, flg, p, c, s)\n if cnt != 0:\n return cnt\n else:\n flg[idx] = 0\n return 0\n return c\n\n#\n# Main Routine\n#\nstr = input()\nNM = list(map(int,str.split()))\n#print(NM)\nANS = 1\nAB = []\nC = []\nA = []\nB = []\nfor i in range(0,int(NM[1])):\n str = input()\n AB.append(list(map(int,str.split())))\n A.append(AB[i][0])\n B.append(AB[i][1])\n\n#\n\n#\nfor i in range(0,int(NM[1])): \n flg = [] # Clear the flag list\n for j in range(0,int(NM[0])):\n flg.append(0)\n v = AB[i][0] \n s = v \n p = []\n cnt = search(v, A, B, flg, p, 0, s)\n for idx in range(len(A)):\n if s == A[idx] and B[idx] == 1:\n cnt = 0\t# Start vertex doesn\'t satisfy the condition.\n for idx in range(len(B)):\n if s == B[idx] and A[idx] == 1:\n cnt = 0\t# Start vertex doesn\'t satisfy the condition.\n if cnt != 0:\n print(cnt)\t# If all the conditions are met, output the result and stop.\n# print(p)\n for i in p:\n print(i)\n break', 'N = input()\nstate = 0\nmax = 0\nmin = 0\nprev = 0\nlen = 0\nANS = 1\nS = input()\nA = list(map(int,S.split()))\n \nfor i in range(0,int(N)):\n len = len + 1\n if state in {0}:\t# Initial state\n prev = A[i]\n state = 1\n elif state in {1}: # Newtral state\n if A[i] > prev:\n state = 2\n elif A[i] < prev:\n state = 3\n elif state in {2}: # Acsending state\n if A[i] < prev:\n state = 1\n ANS = ANS + 1\n len = 0\n elif state in {3}: # Descending state\n if A[i] > prev:\n state = 1\n ANS = ANS + 1\n len = 0\n prev = A[i]\n\nprint(ANS)']
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s367946883', 's668901272', 's889957374', 's992542994', 's864724087']
[3188.0, 15448.0, 3192.0, 3192.0, 15196.0]
[20.0, 525.0, 18.0, 18.0, 84.0]
[1173, 646, 1473, 1477, 647]
p03745
u464205401
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['from collections import deque\n\nn = int(input())\na = list(map(int,input().split()))\nd = deque(a)\n\ntmp = []\ncnt = 0\nwhile d:\n v = d.popleft()\n if len(tmp)<=1:\n pass\n else:\n if not v >= tmp[-1] >= tmp[-2] or v <= tmp[-1] <= tmp[-2]:\n tmp = []\n cnt += 1\n tmp.append(v)\n# print(d,tmp,cnt)\nif tmp:\n cnt+=1\nprint(cnt)', 'n = int(input())\na = list(map(int,input().split()))\n\nflg = "default" #increase_flg\ncnt = 0\nfor i in range(n-1):\n if a[i+1] > a[i]:\n if not flg:\n cnt+=1\n flg = "default"\n else:\n flg = True\n elif a[i+1] < a[i]:\n if flg:\n cnt+=1\n flg = "default"\n else:\n flg = False\n# print(a[i],a[i+1],flg,cnt)\n\nif not a[i]>=a[i-1]>=a[i-2] or a[i]<=a[i-1]<=a[i-2]:\n cnt +=1 \nprint(cnt)', 'from collections import deque\n\nn = int(input())\na = list(map(int,input().split()))\nd = deque(a)\n\ntmp = []\ncnt = 0\nwhile d:\n v = d.popleft()\n tmp.append(v)\n if len(tmp)<=2:\n pass\n else:\n if not ( tmp[-1] >= tmp[-2] >= tmp[-3] or tmp[-1] <= tmp[-2] <= tmp[-3]):\n tmp = [tmp[-1]]\n cnt += 1\n \n print(d,tmp,cnt)\nif tmp:\n cnt+=1\nprint(cnt)', 'from collections import deque\n \nn = int(input())\na = list(map(int,input().split()))\nd = deque(a)\n \ntmp = []\ncnt = 0\nwhile d:\n v = d.popleft()\n if len(tmp)>=2:\n if not (v >= tmp[-1] >= tmp[0] or v <= tmp[-1] <= tmp[0]):\n tmp = []\n cnt += 1\n tmp.append(v)\n\nprint(cnt+1 if tmp else cnt)']
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s138596786', 's158624427', 's700761588', 's718261765']
[20644.0, 20416.0, 146752.0, 20364.0]
[82.0, 78.0, 1335.0, 88.0]
[332, 412, 356, 299]
p03745
u474925961
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['import numpy as np\nn=int(input())\na=list(map(int,input().split()))\nb=a.copy()\nb.insert(0,0)\n\n\narr=np.array(b)\ndiff=np.diff(arr)\narr2=np.array(a)\naa=arr2[np.nonzero(diff)]\nprint(diff,aa)\n\naaa=aa.tolist()\npoint=[]\ncnt=1\nprint(aaa)\nif len(aaa)<=2:\n print(1)\nelse:\n for i in range(len(aaa)-2):\n if (aaa[i+1]-aaa[i])*(aaa[i+2]-aaa[i+1])<0:\n cnt+=1\n point.append(i)\n \n if len(point)>1:\n for i in range(1,len(point)):\n if point[i]-1==point[i-1]:\n point[i]-=1\n cnt-=1\n print(cnt)', 'import numpy as np\nn=int(input())\na=list(map(int,input().split()))\nb=a.copy()\nb.insert(0,0)\n\n\narr=np.array(b)\ndiff=np.diff(arr)\narr2=np.array(a)\naa=arr2[np.nonzero(diff)]\n\naaa=aa.tolist()\npoint=[]\ncnt=1\nprint(aaa)\nif len(aaa)<=2:\n print(1)\nelse:\n for i in range(len(aaa)-2):\n if (aaa[i+1]-aaa[i])*(aaa[i+2]-aaa[i+1])<0:\n cnt+=1\n point.append(i)\n \n if len(point)>1:\n for i in range(1,len(point)):\n if point[i]-1==point[i-1]:\n point[i]-=1\n cnt-=1\n print(cnt)', 'import numpy as np\nn=int(input())\na=list(map(int,input().split()))\n\n\narr=np.array(a)\ndiff=np.diff(np.hstack((0,arr)))\naa=arr[np.nonzero(diff)]\n\naaa=aa.tolist()\npoint=[]\ncnt=1\nif len(aaa)<=2:\n print(1)\nelse:\n for i in range(len(aaa)-2):\n if (aaa[i+1]-aaa[i])*(aaa[i+2]-aaa[i+1])<0:\n cnt+=1\n point.append(i)\n \n if len(point)>1:\n for i in range(1,len(point)):\n if point[i]-1==point[i-1]:\n point[i]-=1\n cnt-=1\n print(cnt)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s551806751', 's565142470', 's469364567']
[28032.0, 27956.0, 25008.0]
[283.0, 286.0, 259.0]
[591, 576, 537]
p03745
u487594898
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['N = int(input())\nP = list(map(int,input().split()))\ncnt = 1\nflag = 0 \nfor i in range(1,N+1):\n if P[i-1]!=P[i] and flag == 0:\n flag = 1\n elif flag == 1 and ((P[i-1] > P[i]) != (P[i-2]>P[i-1])):\n cnt += 1\n flag = 0\nprint(cnt)', 'N = int(input())\nP = list(map(int,input().split()))\ncnt = 1\nflag = 0 \nfor i in range(1,N+1):\n if P[i-1]!=P[i] and flag == 0:\n flag = 1\n elif flag == 1 and ((P[i-1] > P[i]) != (P[i-2]>P[i-1])):\n cnt += 1\n flag = 0\nprint(cnt)\n\n', 'N = int(input())\nP = list(map(int,input().split()))\ncnt = 1\nflag = 0 \nfor i in range(1,N+1):\n if P[i-1]!=P[i] and flag == 0:\n flag = 1\n elif flag == 1 and ((P[i-1] > P[i]) != (P[i-2]>P[i-1])):\n cnt += 1\n flag = 0\nprint(cnt)\n\n', 'N = int(input())\nP = list(map(int,input().split()))\ncnt = 1\nflag = 0 \nfor i in range(1,N+1):\n if P[i-1]!=P[i] and flag == 0:\n flag = 1\n elif flag == 1 and ((P[i-1] > P[i]) != (P[i-2]>P[i-1])):\n cnt += 1\n flag = 0\nprint(cnt)', 'N = int(input())\nP = list(map(int,input().split()))\ncnt = 1\nflag = 0 \nfor i in range(1,N+1):\n if P[i-1]!=P[i] and flag == 0:\n flag = 1\n elif flag == 1 and ((P[i-1] > P[i]) != (P[i-2]>P[i-1])):\n cnt += 1\n flag = 0\nprint(cnt)', 'N = int(input())\nP = list(map(int,input().split()))\ncnt = 1\nflag = 0 \nfor i in range(1,N+1):\n if P[i-1]!=P[i] and flag == 0:\n flag = 1\n elif flag == 1 and ((P[i-1] > P[i]) != (P[i-2]>P[i-1])):\n cnt += 1\n flag = 0\nprint(cnt)', 'N = int(input())\nP = list(map(int,input().split()))\ncnt = 1\nflag = 0 \nfor i in range(1,N):\n if P[i-1]>P[i] and flag == 0:\n flag = 1\n elif P[i-1]<P[i] and flag == 0:\n flag = 2\n elif flag == 1 and (P[i-1] < P[i]) :\n cnt += 1\n flag = 0\n elif flag == 2 and (P[i-1] > P[i]) :\n cnt += 1\n flag = 0\nprint(cnt)']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s026459425', 's166394532', 's343192018', 's519263379', 's527328269', 's908736535', 's730902318']
[15020.0, 14252.0, 15020.0, 14224.0, 14252.0, 15020.0, 14252.0]
[92.0, 93.0, 97.0, 93.0, 96.0, 94.0, 91.0]
[266, 268, 252, 250, 250, 250, 355]
p03745
u488884575
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
["n = int(input())\nA = list(map(int, input().split()))\n\nans = 1\nsq = 0\na = A[0]\nfor i in range(1,n):\n print(a,A[i], sq)\n if sq == 0 and A[i] < a:\n sq = -1\n elif sq == 0 and A[i] > a:\n sq = 1\n elif (sq == 1 and A[i] < a) or (sq == -1 and A[i] > a):\n print('---')\n ans += 1\n sq = 0\n a = A[i]\n\nprint(ans)\n\n", "n = int(input())\nA = list(map(int, input().split()))\n\nans = 1\nsq = 0\na = A[0]\nfor i in range(1,n):\n #print(a,A[i], sq)\n if sq == 0 and A[i] < a:\n sq = -1\n elif sq == 0 and A[i] > a:\n sq = 1\n elif (sq == 1 and A[i] < a) or (sq == -1 and A[i] > a):\n #print('---')\n ans += 1\n sq = 0\n a = A[i]\n\nprint(ans)\n\n"]
['Wrong Answer', 'Accepted']
['s843059874', 's179506867']
[14252.0, 14252.0]
[267.0, 74.0]
[351, 353]
p03745
u493491792
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['n,c,k=map(int,input().split())\nlista=[int(input())for i in range(n)]\nlistb=sorted(lista)\ncount=0\nbustime=0\nbuspeople=0\nfor i in listb:\n if buspeople==0 or bustime<i:\n count+=1\n buspeople=c-1\n bustime=i+k\n else :\n buspeople-=1\nprint(count)', 'n = int(input())\nlista=list(map(int,input().split()))\n\ncount=0\nzougen=""\nfor i in range(n-1):\n if zougen=="":\n if lista[i]<lista[i+1]:\n zougen="up"\n if lista[i]>lista[i+1]:\n zougen="down"\n elif zougen=="up":\n if lista[i]>lista[i+1]:\n count+=1\n zougen=""\n elif zougen=="down":\n if lista[i]<lista[i+1]:\n count+=1\n zougen=""\nprint(count+1)']
['Runtime Error', 'Accepted']
['s272011824', 's679152379']
[3064.0, 15020.0]
[17.0, 80.0]
[272, 440]
p03745
u536113865
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
["li = lambda: list(map(int,input().split()))\n\nn,l,t = li()\na,ac,au = [],[],[]\nfor i in range(n):\n x,y = li()\n if i == 0: start = y\n a.append(x)\n if y == 1:\n ac.append(x)\n else:\n au.append(x)\n\ntt = t%l\n\nif start == 2:\n acc = [n-ac[-s] for s in range(1,len(ac)+1)]\n dist = au[0]+acc[0]\n j = 0\n for i in range(1, min(len(au), len(acc))):\n if dist > tt:\n j = i-1\n break\n if i&1:\n dist += au[i]-au[i-1]\n else:\n dist += acc[i]-acc[i-1]\n if j&1:\n pointofone = n - acc[j//2]\n else:\n pointofone = au[j//2]\nelse:\n acc = [-au[0]] + [n-ac[-s] for s in range(1, len(ac))]\n dist = acc[0] + au[0]\n j = 0\n for i in range(1, min(len(ac), len(acc)) ):\n if dist > tt:\n j = i-1\n break\n if i&1:\n dist += acc[i]-acc[i-1]\n else:\n dist += au[i]-au[i-1]\n if j == 0:\n pointofone = ac[0]\n elif j&1:\n pointofone = au[j//2]\n else:\n pointofone = n - acc[j//2]\n\nant = sorted([(s-t)%l for s in au] + [(s+t)%l for s in ac])\nst = ant.index(pointofone)\nant = ant[st:]+ant[:st]\nprint(*ant, sep='\\n')", 'n = int(input())\na = list(map(int,input().split()))\nmode = 0\nans = 1\nfor i in range(1,n):\n d = a[i]-a[i-1]\n if mode == 0:\n mode = d\n continue\n if mode>0:\n if d<0:\n ans += 1\n elif mode<0:\n if d>0:\n ans += 1\nprint(ans)', 'n = int(input())\na = list(map(int,input().split()))\nmode = 0\nans = 1\nfor i in range(1,n):\n d = a[i]-a[i-1]\n if mode == 0:\n mode = d\n continue\n if mode>0:\n if d<0:\n ans += 1\n mode = 0\n elif mode<0:\n if d>0:\n ans += 1\n mode = 0\nprint(ans)']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s345699090', 's613129349', 's161978823']
[3188.0, 14252.0, 14252.0]
[17.0, 81.0, 80.0]
[1195, 278, 320]
p03745
u539517139
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['n=int(input())\na=list(map(int,input().split()))\ns=n\nfor i in range(n-1):\n if a[i]!=a[i+1]:\n s=i\n f=0 if a[s]<a[s+1] else f=1\n break\np=0\nfor i in range(s+1,n-1):\n if f==0:\n if a[i]>a[i+1]:\n p+=1\n f=1\n else:\n if a[i]<a[i+1]:\n p+=1\n f=0\nprint(p)', 'n=int(input())\na=list(map(int,input().split()))\ns=n\nfor i in range(n-1):\n if a[i]!=a[i+1]:\n s=i\n if a[s]<a[s+1]:\n f=0\n else:\n f=1\n break\np=1\nfor i in range(s+1,n-1):\n if f==0:\n if a[i]>a[i+1]:\n p+=1\n if i==n-2 or a[i+1]>a[i+2]:\n f=1\n else:\n f=0\n else:\n if a[i]<a[i+1]:\n p+=1\n if i==n-2 or a[i+1]>a[i+2]:\n f=1\n else:\n f=0\nprint(p)', 'n=int(input())\na=list(map(int,input().split()))\na.append(0)\nb=[]\nfor i in range(n):\n if a[i]!=a[i+1]:\n b.append(a[i])\nn=len(b)\ns=n\nfor i in range(n-1):\n if b[i]!=b[i+1]:\n s=i\n if b[s]<b[s+1]:\n f=0\n else:\n f=1\n break\np=1\nfor i in range(s+1,n-1):\n if f==0:\n if b[i]>b[i+1]:\n p+=1\n if i==n-2 or b[i+1]>b[i+2]:\n f=1\n else:\n f=0\n else:\n if b[i]<b[i+1]:\n p+=1\n if i==n-2 or b[i+1]>b[i+2]:\n f=1\n else:\n f=0\nprint(p)']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s025741715', 's180119528', 's543250797']
[3064.0, 14480.0, 14484.0]
[17.0, 75.0, 105.0]
[280, 418, 501]
p03745
u541610817
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['N = int(input())\nA_lst = [int(x) for x in input().split()]\nB_lst =[]\nfor i in range(N - 1):\n B_lst.append(A_lst[i + 1] - A_lst[i])\n\ndef my_sign(n):\n return (n > 0) - (n < 0)\n\ncnt = 1\ni = 0\npm = my_sign(B_lst[0])\nwhile True:\n if i >= len(B_lst) - 1:\n break\n else:\n if my_sign(B_lst[i + 1]) == 0:\n i += 1\n continue\n elif pm == my_sign(B_lst[i + 1]) or pm == 0:\n pm = my_sign(B_lst[i + 1])\n i += 1\n continue\n else:\n cnt += 1\n i +=2\nprint(cnt)\n', 'def my_sign(n):\n return (n > 0) - (n < 0)\ndef kugiri(cnt, lst):\n if len(lst) <= 1:\n return cnt\n else:\n pm = lst[0]\n i = 1\n fl = 0\n while i < len(lst):\n if pm == lst[i]:\n i += 1\n continue\n else:\n fl = 1\n break\n if fl == 1:\n new_lst = []\n for j in range(i + 1, len(lst)):\n new_lst.append(lst[j])\n return kugiri(cnt + 1, new_lst)\n\nN = int(input())\nA_lst = [int(x) for x in input().split()]\ncnt = 1\nif N == 1:\n pass\nelse:\n S_lst = []\n for i in range(1, N):\n S_lst.append(my_sign(A_lst[i] - A_lst[i - 1]))\n for i in range(len(S_lst)):\n if i == 0 and S_lst[i] == 0:\n for j in range(len(S_lst)):\n if not S_lst[j] == 0:\n S_lst[i] = S_lst[j]\n elif S_lst[i] == 0:\n S_lst[i] = S_lst[i - 1]\n cnt = kugiri(cnt, S_lst)\nprint(cnt)\n', "def main():\n N = int(input())\n lst = [int(_) for _ in input().split()]\n last = lst[0]\n A = [last]\n for i in range(1, N):\n if lst[i] == last: continue\n last = lst[i]\n A.append(lst[i])\n left = right = output = 0\n while left < len(A):\n if left == len(A)-1:\n output += 1\n break\n if A[left+1] - A[left] > 0:\n while right < len(A)-1 and A[right] < A[right+1]:\n right += 1\n elif A[left+1] - A[left] < 0:\n while right < len(A)-1 and A[right] > A[right+1]:\n right += 1\n output += 1\n left = right + 1\n right = left\n print(output)\n return\n\nif __name__ == '__main__':\n main()\n"]
['Runtime Error', 'Wrong Answer', 'Accepted']
['s057734054', 's292943869', 's547475124']
[14440.0, 201872.0, 14480.0]
[151.0, 2116.0, 101.0]
[557, 989, 731]
p03745
u541883958
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
["n = int(input())\na = [int(c) for c in input().split(' ')]\nl = len(a)\nc = 1\nfor i in range(l):\n if i == 0:\n if l == 1:\n pass\n else:\n prev = a[0]\n if a[1] > a[0]:\n inc = True\n else:\n inc = False\n continue\n current = a[i]\n if prev < current and inc :\n pass\n elif prev > current and not inc:\n inc = True\n c += 1\n elif prev < current and not inc:\n pass\n elif prev > current and inc:\n inc = False\n c +=1\n prev = current\nprint(c)\n", "n = int(input())\na = [int(c) for c in input().split(' ')]\nprev = None\nc = 1\ninc = None\n\nfor i in range(l):\n current = a[i]\n if i == 0 :\n continue\n if inc == None:\n if a[i] > a[i-1] :\n inc = True\n elif a[i] < a[i - 1]:\n inc = False\n else:\n continue \n elif inc == True:\n if a[i-1] < a[i]:\n pass\n elif a[i -1] > a[i]:\n c += 1\n inc = None\n elif inc == False:\n if a[i-1] > a[i]:\n pass\n elif a[i - 1] < a[i]:\n c += 1\n inc = None\nprint(c)\n", "n = int(input())\na = [int(c) for c in input().split(' ')]\n#a = [1 ,2 ,1 ,2 ,1 ,2 ,1 ,2 ,1]\nl = len(a)\nprev = None\nc = 1\ninc = None\n\nfor i in range(l):\n current = a[i]\n if i == 0 :\n continue\n if inc == None:\n if a[i] > a[i-1] :\n inc = True\n elif a[i] < a[i - 1]:\n inc = False\n else:\n continue \n elif inc == True:\n if a[i-1] < a[i]:\n pass\n elif a[i -1] > a[i]:\n c += 1\n inc = None\n elif inc == False:\n if a[i-1] > a[i]:\n pass\n elif a[i - 1] < a[i]:\n c += 1\n inc = None\nprint(c)\n"]
['Wrong Answer', 'Runtime Error', 'Accepted']
['s188961209', 's988040855', 's802568791']
[14252.0, 14436.0, 14224.0]
[92.0, 46.0, 97.0]
[582, 614, 658]
p03745
u542932305
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
["N = int(input())\nA = list(map(int, input().split()))\ncount = 1\n\ntmp = A[0]\nbf = 1 if tmp < A[1] else 2 if tmp > A[1] else 0\naf = 0 # {1: '+', 2: '-'}\nfor i in range(1, N):\n if tmp < A[i]:\n af = 1\n elif tmp > A[i]:\n af = 2\n\n tmp = A[i]\n if af != bf:\n count += 1\n if i+1 < N:\n af = 1 if tmp < A[i+1] else 2 if tmp > A[i+1] else 0\n bf = af\n\nprint(count)", "N = int(input())\nA = list(map(int, input().split()))\ncount = 1\n\nconti_flg = 0 # {-1: '-', 0: '=', 1: '+'}\nfst = A[0]\nfor i in A:\n snd = i\n if fst > snd:\n conti_flg = -1 if conti_flg <= 0 else 2\n elif fst < snd:\n conti_flg = 1 if conti_flg >= 0 else 2\n\n if conti_flg == 2:\n count += 1\n conti_flg = 0\n fst = snd\n\nprint(count)"]
['Runtime Error', 'Accepted']
['s085222360', 's908078243']
[14252.0, 15020.0]
[91.0, 73.0]
[405, 367]
p03745
u554954744
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['n = int(input())\nA = list(map(int, input().split()))\n\nans = 0\nup = dn = False\npre = A[0]\nfor a in A[1:]:\n if pre < a:\n up = True\n elif pre > a:\n dn = True\n if up and dn:\n ans += 1\n up = dn = False\n pre = a\n\nprint(ans)\n', 'n = int(input())\nA = list(map(int, input().split()))\n\nans = 1\nup = dn = False\npre = A[0]\nfor a in A[1:]:\n if pre < a:\n up = True\n elif pre > a:\n dn = True\n if up and dn:\n ans += 1\n up = dn = False\n pre = a\n\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s627172434', 's978604663']
[19936.0, 20096.0]
[67.0, 67.0]
[258, 258]
p03745
u556160473
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
["n = int(input())\na_ = list(map(int, input().split(' ')))\na = [-1]\ni = 0\nwhile i < n:\n if a[-1] != a_[i]:\n a.append(a_[i])\n i += 1\na = a[1:]\n\nret = 1\n\ni = 0\nwhile i < n-2:\n if (a[i] > a[i+1] and a[i+1] < a[i+2]) or (a[i] < a[i+1] and a[i+1] > a[i+2]):\n ret += 1\n i += 2\n else:\n i += 1\n \nprint(ret)", "\nn = int(input())\na_ = list(map(int, input().split(' ')))\na = [-1]\ni = 0\nwhile i < n:\n if a[-1] != a_[i]:\n a.append(a_[i])\n i += 1\na = a[1:]\nn = len(a)\n\nret = 1\n\ni = 0\nwhile i < n-2:\n if (a[i] > a[i+1] and a[i+1] < a[i+2]) or (a[i] < a[i+1] and a[i+1] > a[i+2]):\n ret += 1\n i += 2\n else:\n i += 1\n \nprint(ret)"]
['Runtime Error', 'Accepted']
['s041225702', 's103462023']
[14436.0, 14436.0]
[128.0, 142.0]
[344, 356]
p03745
u562016607
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['N=int(input())\nA=[int(i) for i in input().split()]\nT=[[A[0],A[1]]]\nk=0\nfor i in range(2,N):\n if len(T[k])<=1:\n T[k].append(A[i])\n #continue\n if not((T[k][0]>=A[i-2]>=A[i-1]>=A[i]) or (T[k][0]<=A[i-2]<=A[i-1]<=A[i])):\n k+=1\n T.append([])\n T[k].append(A[i])\n else:\n T[k].append(A[i])\nprint(len(T))\n', 'N=int(input())\nA=[int(i) for i in input().split()]\nif N==1:\n print(1)\n exit()\nT=[[A[0],A[1]]]\nfor i in range(2,N):\n if len(T[-1])<=1:\n T[-1].append(A[i])\n continue\n if not((T[-1][0]>=A[i-2]>=A[i-1]>=A[i]) or (T[-1][0]<=A[i-2]<=A[i-1]<=A[i])):\n T.append([A[i]])\n else:\n T[-1].append(A[i])\nprint(len(T))\n']
['Runtime Error', 'Accepted']
['s445594358', 's120039872']
[19216.0, 14436.0]
[182.0, 120.0]
[347, 345]
p03745
u581309643
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['import numpy as np\nN, L, T = map(int, input().split())\nX = []\nW = []\nant = [i for i in range(N)]\nfor i in range(N):\n xi, wi = map(int, input().split())\n X.append(xi)\n W.append(wi)\n\nnpX = np.array(X).astype(np.float)\nnpW = np.array(W).astype(np.float)\nnpW[npW == 2] = -1\n\ndef swap(ant, i, j):\n tmp = ant[i]\n ant[i] = ant[j]\n ant[j] = tmp\n return ant\n\nans = (npX + npW * T) % L\n\nT %= L\nif T > L - T:\n T = L - T\n npW *= -1\nt = 0\nwhile t < T:\n t += 0.5\n npX = (npX + npW * 0.5) % L\n colision = set([e for e in set(npX) if np.sum(npX == e) == 2])\n if len(colision) != 0:\n for e in colision:\n i, j = np.where(npX == e)[0].tolist()\n swap(ant, i, j)\n\nfor i in range(N):\n print(int(ans[ant.index(i)]))\n\n', 'N = int(input())\nA = list(map(int, input().split()))\n\nsign = 0\nc = 0\nfor i in range(1,len(A)):\n dif = A[i] - A[i-1]\n if dif * sign < 0:\n c += 1\n sign = 0\n continue\n if dif != 0:\n sign = dif\nprint(c+1)\n']
['Runtime Error', 'Accepted']
['s398976415', 's839520549']
[21792.0, 15020.0]
[374.0, 78.0]
[765, 238]
p03745
u593567568
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['N = int(input())\nA = list(map(int,input().split()))\n\nprev = A[0]\nisUp = True\nisDown = True\n\nans = 0\nfor a in A[1:]:\n if prev == a:\n pass\n elif prev < a:\n isDown = False\n if not isUp:\n isUp = True\n ans += 1\n elif a < prev:\n isUp = False\n if not isDown:\n isDown = True\n ans += 1\n \n prev = a\n \nprint(ans)\n\n \n ', 'N = int(input())\nA = list(map(int,input().split()))\n\nprev = A[0]\nisUp = True\nisDown = True\n\nans = 0\nfor a in A[1:]:\n if prev == a:\n pass\n elif prev < a:\n isDown = False\n if not isUp:\n isUp = True\n isDown = True\n ans += 1\n elif a < prev:\n isUp = False\n if not isDown:\n isUp = True\n isDown = True\n ans += 1\n \n prev = a\n \nprint(ans+1)\n\n \n \n']
['Wrong Answer', 'Accepted']
['s148660352', 's226510448']
[14224.0, 14224.0]
[70.0, 73.0]
[353, 394]
p03745
u595064211
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['N = int(input())\nA = list(map(int, input().split()))\n\nword = []\ncount = 0\nstart = 0\nfor x in range(N):\n if start==N:\n print("break")\n break\n for i in range(N,1,-1):\n word = A[start:i]\n if word == sorted(word, reverse=True):\n count += 1\n start = i\n print(word)\n print(start)\n break\n elif word== sorted(word, reverse=False):\n count += 1\n start = i\n print(word)\n print(start)\n break\n \nprint("{}".format(count))', 'N = int(input())\nA = list(map(int, input().split()))\n\nans = 0\npos = 0\npos1 = 0\npos2 = 0\n\nwhile True:\n if pos==N:\n break\n pos1 = pos\n pos2 = pos\n while pos1<N-1 and A[pos1] <= A[pos1+1]:\n pos1 +=1\n# print(pos1)\n while pos2<N-1 and A[pos2] >= A[pos2+1]:\n pos2 +=1\n# print(pos2)\n large = max(pos1, pos2)\n pos = large+1\n ans += 1\nprint(ans)']
['Wrong Answer', 'Accepted']
['s481462550', 's431046263']
[14252.0, 14252.0]
[2104.0, 101.0]
[569, 389]
p03745
u598229387
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['n=int(input())\na=[int(i) for i in input().split()]\n\nans=0\ndef plus_minus(i):\n while True:\n if a[i]==a[i+1]:\n i+=1\n continue\n if a[i]<a[i+1]:\n return 1\n if a[i]>a[i+1]:\n return -1\n\ncheck=plus_minus(0) \nans=1\nfor j in range(i,n-1):\n if check==1:\n if a[j] <= a[j+1]:\n continue\n else:\n ans+=1\n check=plus_minus(j+1)\n else:\n if a[j]>=a[j+1]:\n continue\n else:\n ans+=1\n check=plus_minus(j+1)\nprint(ans)', 'n=int(input())\na=[int(i) for i in input().split()]\n\nans=0\ndef plus_minus(i):\n while True:\n if a[i]==a[i+1]:\n i+=1\n continue\n if a[i]<a[i+1]:\n return 1\n if a[i]>a[i+1]:\n return -1\n\nplus_minus(0) \nans=1\nfor j in range(i,n-1):\n if check==1:\n if a[j] <= a[j+1]:\n continue\n else:\n ans+=1\n check=plus_minus(j+1)\n else:\n if a[j]>=a[j+1]:\n continue\n else:\n ans+=1\n check=plus_minus(j+1)\nprint(ans)', 'n=int(input())\na=[int(i) for i in input().split()]\n\nans=0\ndef plus_minus(i):\n while True:\n if i==n-1:\n break\n if a[i]==a[i+1]:\n i+=1\n continue\n if a[i]<a[i+1]:\n return 1\n if a[i]>a[i+1]:\n return -1\n\ncheck=plus_minus(0) \nans=1\nfor j in range(n-1):\n if check==1:\n if a[j] <= a[j+1]:\n continue\n else:\n ans+=1\n check=plus_minus(j+1)\n else:\n if a[j]>=a[j+1]:\n continue\n else:\n ans+=1\n check=plus_minus(j+1)\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s100729454', 's102584348', 's334429904']
[14252.0, 14436.0, 14428.0]
[46.0, 46.0, 91.0]
[574, 568, 609]
p03745
u602860891
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['N, M = list(map(int, input().split()))\nline_list = list()\nfor _ in range(M):\n a, b = list(map(int, input().split()))\n line_list.append((a, b))\n\npath_points = [ line_list[0][0], line_list[0][1] ]\n\nfor i in range(1, M):\n if line_list[i][0] not in path_points and line_list[i][1] not in path_points:\n break\n\n if line_list[i][0] in path_points and line_list[i][1] not in path_points:\n path_points.append(line_list[i][1])\n elif line_list[i][1] in path_points and line_list[i][0] not in path_points:\n path_points.insert(0, line_list[i][0])\n\nfor point in path_points:\n print(point)\n\n', '\nN = int(input())\nA_list = list(map(int, input().split()))\n\nnum_split = 1\nis_increase = None\nlen_A_list = len(A_list)\n\nfor i in range(len_A_list-1):\n if is_increase == None:\n if A_list[i] < A_list[i+1]:\n is_increase = True\n else:\n is_increase = False\n\n if is_increase and A_list[i] < A_list[i+1]:\n continue\n if (not is_increase) and A_list[i] > A_list[i+1]:\n continue\n\n num_split += 1\n is_increase = None\n\nprint(num_split)\n', 'import math\n\nN = int(input())\nA_list = list(map(int, input().split()))\n\nnum_split = 1\nsign = None\nlen_A_list = len(A_list)\n\nfor i in range(len_A_list-1):\n if sign == None:\n sign = (A_list[i+1] - A_list[i]) / math.fabs(A_list[i+1] - A_list[i])\n\n if (A_list[i+1] - A_list[i]) * sign >= 0:\n continue\n\n num_split += 1\n sign = None\n\nprint(num_split)\n', 'N, L, T = list(map(int, input().split()))\n\nX = []\nW = []\nX_after = []\nfor _ in range(N):\n x, w = list(map(int, input().split()))\n if w == 1:\n x_after = (x + T) % L\n else:\n x_after = (x - T) % L\n x_after = x_after if x_after >= 0 else L + x_after\n X.append(x)\n W.append(w)\n X_after.append(x_after)\n\nn_colide = 0\nfor i in range(1, N):\n if W[0] == 1 and W[i] == 2:\n dist = X[i] - X[0]\n n_colide += 2 * (T - (dist / 2)) // L + 1\n elif W[0] == 2 and W[i] == 1:\n dist = (L + X[0]) - X[i]\n n_colide += 2 * (T - (dist / 2)) // L + 1\n\nif W[0] == 1:\n num_after = n_colide % N\nelse:\n num_after = N - (n_colide % N)\n\nnum_after = int(num_after)\n\nx_after_first = X_after[0]\nX_after = sorted(X_after)\ni = X_after.index(x_after_first)\nX_after = X_after[i-num_after:] + X_after[:i-num_after]\n\nfor x_after in X_after:\n print(x_after)\n', '\nN = int(input())\nA_list = list(map(int, input().split()))\n\nnum_split = 1\ndiff = None\nlen_A_list = len(A_list)\n\nfor i in range(len_A_list-1):\n if diff == None:\n diff = A_list[i+1] - A_list[i]\n\n if A_list[i+1] - A_list[i] == diff:\n continue\n\n num_split += 1\n diff = None\n\nprint(num_split)\n', 'import math\n\nN = int(input())\nA_list = list(map(int, input().split()))\n\nnum_split = 1\nsign = None\nlen_A_list = len(A_list)\n\nfor i in range(len_A_list-1):\n if sign == None:\n if A_list[i+1] - A_list[i] == 0:\n continue\n sign = (A_list[i+1] - A_list[i]) / math.fabs(A_list[i+1] - A_list[i])\n\n if (A_list[i+1] - A_list[i]) * sign >= 0:\n continue\n\n num_split += 1\n sign = None\n\nprint(num_split)\n']
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s286960725', 's451675268', 's503239936', 's567756578', 's765320966', 's124276680']
[3064.0, 14252.0, 15020.0, 3064.0, 14252.0, 15020.0]
[18.0, 89.0, 104.0, 17.0, 81.0, 113.0]
[617, 488, 372, 898, 314, 434]
p03745
u617116410
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['n = int(input())\narray = list(map(int, input().split()))\nisHead = True\nisIncrease = False\ncount = 1\nfor i in range(1, n):\n if(isHead):\n isHead = False\n if(array[i] > array[i-1]):\n isIncrease = True\n elif(array[i] < array[i-1]):\n isIncrease = False\n else:\n if(isIncrease):\n if(array[i] < array[i-1]):\n count += 1\n isHead = True\n continue\n else:\n if(array[i] > array[i-1]):\n count += 1\n isHead = True\n continue\nprint(count)', 'n = int(input())\narray = list(map(int, input().split()))\nstatus = 0\npast = 0\ncount = 1\nfor i in range(1, n):\n past = status\n if(array[i-1] < array[i]):\n if(status == 0):\n past = 1\n status = 1\n elif(array[i-1] > array[i]):\n if (status == 0):\n past = 2\n status = 2\n\n if(status != past):\n count += 1\n i += 2\n past = 0\n status = 0\n continue\n\nprint(count)']
['Wrong Answer', 'Accepted']
['s760707530', 's388677934']
[14252.0, 14252.0]
[72.0, 89.0]
[596, 447]
p03745
u626467464
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['n = int(input())\nline = list(map(int,input().split()))\ncount = 0\nup = False\ndown =False\nfor i in range(n - 1):\n if line[i] < line[i + 1]:\n up = True\n elif line[i] > line[i + 1]:\n down = True\n if up == down == True:\n count += 1\n up =False\n down =False\nprint(count)', 'n = int(input())\nline = list(map(int,input().split()))\ncount = 1\nup = False\ndown =False\nfor i in range(n - 1):\n if line[i] < line[i + 1]:\n up = True\n elif line[i] > line[i + 1]:\n down = True\n if up == down == True:\n count += 1\n up =False\n down =False\nprint(count)']
['Wrong Answer', 'Accepted']
['s152391999', 's404741591']
[14224.0, 14224.0]
[81.0, 85.0]
[281, 281]
p03745
u626468554
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['#n = int(input())\n#n,k = map(int,input().split())\n#x = list(map(int,input().split()))\n\nN = int(input())\nA = list(map(int,input().split()))\n\nans = 0\nmm = 0\ni = 0\nwhile(i<N-2):\n if (A[i]-A[i+1])*(A[i+1]-A[i+2])<0:\n ans += 1\n i+=1\n i+=1\n \nprint(ans)\n\n\n', '#n = int(input())\n#n,k = map(int,input().split())\n#x = list(map(int,input().split()))\n\nN = int(input())\nA = list(map(int,input().split()))\n\nans = 2\nmm = 0\ni = 0\nwhile(i<N-2):\n if (A[i]-A[i+1])*(A[i+1]-A[i+2])<0:\n ans += 1\n i+=1\n i+=1\n \nprint(ans)\n\n\n', '#n = int(input())\n#n,k = map(int,input().split())\n#x = list(map(int,input().split()))\n\nN = int(input())\nA = list(map(int,input().split()))\n\nans = 0\nmm = 0\ni = 0\nwhile(i<N-2):\n if (A[i]-A[i+1])*(A[i+1]-A[i+2])<0:\n ans += 1\n i+=1\n i+=1\n \nprint(ans)\n\n\n', '#n = int(input())\n#n,k = map(int,input().split())\n#x = list(map(int,input().split()))\n\nN = int(input())\nA = list(map(int,input().split()))\n\nans = 1\nmm = 0\ni = 0\nflg = 0\nwhile(i<N-1):\n if A[i]>A[i+1]:\n if mm>0:\n ans += 1\n flg = 1\n \n # print(i,A[i])\n mm = -1\n if flg:\n flg = 0\n mm = 0\n\n elif A[i]<A[i+1]:\n if mm<0:\n ans += 1\n flg = 1\n \n # print(i,A[i])\n\n mm = 1\n if flg:\n flg = 0\n mm = 0\n i+=1\n \nprint(ans)\n\n\n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s460294879', 's655698456', 's684879348', 's640161053']
[14252.0, 14252.0, 14228.0, 14252.0]
[93.0, 94.0, 90.0, 96.0]
[272, 272, 272, 593]
p03745
u629350026
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['n=int(input())\na=list(map(int,input().split()))\nans=1\ntemp=0\ncnt=0\nfor i in range(1,n-1):\n cnt=cnt+1\n if a[i-1]<a[i] and temp==0:\n temp=1\n elif a[i-1]>a[i] and temp==0:\n temp=2\n elif a[i-1]>a[i] and temp==1:\n temp=2\n if cnt>1:\n ans=ans+1\n cnt=0\n elif a[i-1]<a[i] and temp==2:\n temp=1\n if cnt>1:\n ans=ans+1\n cnt=0\nif cnt==1:\n print(ans+1)\nelse:\n print(ans)', 'n=int(input())\na=list(map(int,input().split()))\nans=1\ntemp=0\nfor i in range(1,n):\n if a[i-1]<a[i] and temp==0:\n temp=1\n elif a[i-1]>a[i] and temp==0:\n temp=2\n elif a[i-1]>a[i] and temp==1:\n temp=0\n ans=ans+1\n elif a[i-1]<a[i] and temp==2:\n temp=0\n ans=ans+1\nprint(ans)']
['Wrong Answer', 'Accepted']
['s423813166', 's321842667']
[14480.0, 14228.0]
[116.0, 102.0]
[400, 290]
p03745
u636387751
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['N = int(input())\nA = list(map(int, input().split()))\n\ncount = 0\nans = 1\nbef = 0\nbuff = True\nfor i in A:\n if count == 0:\n count = 1\n elif count == 1:\n if bef < i:\n count += 1\n elif bef > i:\n count += 1\n buff = False\n else:\n pass\n else:\n if buff:\n if bef <= i:\n pass\n else:\n ans += 1\n count = 1\n else:\n if bef >= i:\n pass\n else:\n ans += 1\n count = 1\n bef = i', 'N = int(input())\nA = list(map(int, input().split()))\n\ncount = 0\nans = 1\nbef = 0\nbuff = True\nfor i in A:\n if count == 0:\n count = 1\n elif count == 1:\n if bef < i:\n count += 1\n buff = True\n elif bef > i:\n count += 1\n buff = False\n else:\n pass\n else:\n if buff:\n if bef <= i:\n pass\n else:\n ans += 1\n count = 1\n else:\n if bef >= i:\n pass\n else:\n ans += 1\n count = 1\n bef = i\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s315670614', 's620169679']
[14252.0, 14252.0]
[69.0, 70.0]
[588, 624]
p03745
u672475305
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['n = int(input())\nlst = list(map(int,input().split()))\n\nm = -1 \nif n==1 or n==2:\n print(1)\nelse:\n cnt = 0\n num = lst[0]\n mode = 0\n for i in range(1,n):\n if mode==0:\u3000\n if lst[i]==num:\n continue \n elif lst[i] > num:\n mode = 1 \n elif lst[i] < num:\n mode = 2 \n elif mode == 1:\n if lst[i] < num:\n cnt += 1\n mode = 0\n elif mode == 2:\n if lst[i] > num:\n cnt += 1\n mode = 0\n num = lst[i]\n print(cnt + 1)', 'n = int(input())\nlst = list(map(int,input().split()))\nif n==1 or n==2:\n print(1)\nelse:\n cnt = 0\n num = lst[0]\n mode = 0\n for i in range(1,n):\n if mode==0:\n if lst[i]==num:\n continue \n elif lst[i] > num:\n mode = 1\n elif lst[i] < num:\n mode = 2\n elif mode == 1:\n if lst[i] < num:\n cnt += 1\n mode = 0\n elif mode == 2:\n if lst[i] > num:\n cnt += 1\n mode = 0\n num = lst[i]\n print(cnt + 1)']
['Runtime Error', 'Accepted']
['s620168336', 's476855410']
[2940.0, 14436.0]
[17.0, 74.0]
[661, 599]
p03745
u678167152
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['N = int(input())\nA = list(map(int, input().split()))\ndef solve(N,A):\n liss = []\n lis = []\n lis.append(A[0])\n a = A[0]\n for i in range(1,N):\n if len(lis)==1 or prev==0:\n if A[i]>a:\n prev = 1\n elif A[i]<a:\n prev = -1\n else:\n prev = 0\n elif ((A[i]-a)*prev<0:\n liss.append(lis)\n lis = []\n lis.append(A[i])\n a = A[i]\n liss.append(lis)\n ans = len(liss)\n return ans\nprint(solve(N,A))', 'N = int(input())\nA = list(map(int, input().split()))\ndef solve(N,A):\n ans = 0\n lis = []\n lis.append(A[0])\n a = A[0]\n for i in range(1,N):\n if len(lis)==1 or prev==0:\n prev = A[i]-a\n elif (A[i]-a)*prev<0:\n ans += 1\n lis = []\n lis.append(A[i])\n a = A[i]\n return ans\nprint(solve(N,A))', 'def solve():\n ans = 1\n N = int(input())\n A = list(map(int, input().split()))\n ud = 0\n for i in range(N-1):\n a = A[i+1]-A[i]\n if a*ud<0:\n ans += 1\n ud = 0\n elif ud==0:\n ud = a\n return ans\nprint(solve())']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s594112150', 's645505506', 's266774223']
[3060.0, 14252.0, 19908.0]
[17.0, 74.0, 67.0]
[528, 360, 231]
p03745
u691896522
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['n = int(input())\na = list(map(int, input().split()))\nans = 0\nif n <= 2:\n print(1)\n exit()\npre = a[1] - a[0]\ni = 2\nwhile i < n:\n if pre * (a[i] - a[i-1]) < 0:\n ans += 1\n i += 1\n if i == n:\n break\n if a[i] != a[i-1]:\n pre = a[i] - a[i-1]\n i += 1\nprint(ans + 1)\n', 'n = int(input())\na = list(map(int, input().split()))\nans = 0\nif n <= 2:\n print(1)\n exit()\npre = a[1] - a[0]\ni = 2\nwhile i < n:\n if pre * (a[i] - a[i-1]) < 0:\n ans += 1\n pre = 0\n i += 1\n if i == n:\n break\n if a[i] != a[i-1]:\n pre = a[i] - a[i-1]\n i += 1\nprint(ans + 1)\n']
['Wrong Answer', 'Accepted']
['s852129341', 's053805515']
[14252.0, 14224.0]
[108.0, 105.0]
[313, 329]
p03745
u692632484
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['N=int(input())\nA=[int(i) for i in input().split()]\nB=[]\nendflag=False\nans=1\nif N>2:\n\tfor i in range(N-1):\n\t\tif A[i]<A[i+1]:\n\t\t\tB.append(1)\n\t\telif A[i]==A[i+1]:\n\t\t\tB.append(0)\n\t\telse:\n\t\t\tB.append(-1)\n\tcount=0\n\twhile B[count]==0:\n\t\tcount+=1\n\t\tif count>N-1:\n\t\t\tendflag=True\n\t\t\tbreak\n\tprint(A)\n\tprint(B)\n\tif not endflag:\n\t\tmode=B[count]\n\t\t\n\t\twhile count<N-1:\n\t\t\tif B[count]+mode==0:\n\t\t\t\tprint(count,mode)\n\t\t\t\tans+=1\n\t\t\t\tif count==N-2:\n\t\t\t\t\tbreak\n\t\t\t\twhile B[count+1]==0:\n\t\t\t\t\tcount+=1\n\t\t\t\t\tif count>N-1:\n\t\t\t\t\t\tendflag=True\n\t\t\t\t\t\tbreak\n\t\t\t\tmode=B[count+1]\n\t\t\tcount+=1\n\t\t\tif endflag:\n\t\t\t\tbreak\nprint(ans)', 'N=int(input())\nA=[int(i) for i in input().split()]\nB=[]\nendflag=False\nans=1\nif N>2:\n\tfor i in range(N-1):\n\t\tif A[i]<A[i+1]:\n\t\t\tB.append(1)\n\t\telif A[i]==A[i+1]:\n\t\t\tB.append(0)\n\t\telse:\n\t\t\tB.append(-1)\n\tcount=0\n\twhile B[count]==0:\n\t\tcount+=1\n\t\tif count>N-1:\n\t\t\tendflag=True\n\t\t\tbreak\n\t#print(A)\n\t\n\tif not endflag:\n\t\tmode=B[count]\n\t\t\n\t\twhile count<N-1:\n\t\t\tif B[count]+mode==0:\n\t\t\t\t#print(count,mode)\n\t\t\t\tans+=1\n\t\t\t\tif count==N-2:\n\t\t\t\t\tbreak\n\t\t\t\twhile B[count+1]==0:\n\t\t\t\t\tcount+=1\n\t\t\t\t\tif count>N-1:\n\t\t\t\t\t\tendflag=True\n\t\t\t\t\t\tbreak\n\t\t\t\tmode=B[count+1]\n\t\t\tcount+=1\n\t\t\tif endflag:\n\t\t\t\tbreak\nprint(ans)']
['Wrong Answer', 'Accepted']
['s842960334', 's488675803']
[14480.0, 14480.0]
[189.0, 117.0]
[598, 601]
p03745
u706884679
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['N = int(input())\nA = input().split()\n\nc = 1\ni = 1\nwhile i <= N-2:\n\tif int(A[i])-int(A[i-1]) > 0:\n\t\tif int(A[i+1])-int(A[i]) < 0:\n\t\t\tc += 1\n\t\t\ti += 2\n\t\telse:\n\t\t\ti += 1\n\telif int(A[i])-int(A[i-1]) < 0:\n\t\tif int(A[i+1])-int(A[i]) > 0:\n\t\t\tc += 1\n\t\t\ti += 2\n\t\telse:\n\t\t\ti += 1\n\telse:\n\t\tc += 1\n\t\ti += 2\n\nprint(c)', 'N = int(input())\nA = input().split()\n\nc = 1\ni = 1\n\nwhile i <= N-1:\n\tif int(A[i])-int(A[i-1]) == 0:\n\t\tdel A[i-1]\n\t\tN -= 1\n\telse:\n\t\ti += 1\n\ni = 1\n\nwhile i <= N-2:\n\tif int(A[i])-int(A[i-1]) > 0:\n\t\tif int(A[i+1])-int(A[i]) < 0:\n\t\t\tc += 1\n\t\t\ti += 2\n\t\telse:\n\t\t\ti += 1\n\telse:\n\t\tif int(A[i+1])-int(A[i]) > 0:\n\t\t\tc += 1\n\t\t\ti += 2\n\t\telse:\n\t\t\ti += 1\n \nprint(c)']
['Wrong Answer', 'Accepted']
['s068160552', 's650624087']
[11096.0, 11448.0]
[202.0, 1541.0]
[304, 349]
p03745
u729707098
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['import numpy as np\nn = int(input())\na = [int(i) for i in input().split()]\nanswer= 1\nif n!=1: np.sign(a[1]-a[0])\nfor i in range(1,n-1):\n\tnum = np.sign(a[i+1]-a[i])\n\tif flag==0:\n\t\tflag = num\n\telif num==-flag:\n\t\tanswer += 1\n\t\tflag = 0\nprint(answer)', 'import numpy as np\nn = int(input())\na = [int(i) for i in input().split()]\nanswer = 1\nif n!=1: flag = np.sign(a[1]-a[0])\nfor i in range(1,n-1):\n\tnum = np.sign(a[i+1]-a[i])\n\tif flag==0:\n\t\tflag = num\n\telif num==-flag:\n\t\tanswer += 1\n\t\tflag = 0\nprint(answer)']
['Runtime Error', 'Accepted']
['s920471448', 's592218262']
[23104.0, 23100.0]
[182.0, 516.0]
[245, 253]
p03745
u731436822
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['\n\nN = int(input())\nA = list(map(int,input().split()))\n\ncount = 0\nsign = 0\nfor i in range(N-1):\n if sign == 0:\n sign = A[i+1]-A[i]\n elif sign*(A[i+1]-A[i]) < 0:\n count += 1\n sign = 0\nprint(count)', '\n\nN = int(input())\nA = list(map(int,input().split()))\n\ncount = 0\nsign = 0\nfor i in range(N):\n if sign == 0:\n sign = A[i+1]-A[i]\n elif sign*(A[i+1]-A[i]) < 0:\n count += 1\n sign = 0\nprint(count)', '\n\nN = int(input())\nA = list(map(int,input().split()))\n\ncount = 1\nsign = 0\nfor i in range(N-1):\n if sign == 0:\n sign = A[i+1]-A[i]\n elif sign*(A[i+1]-A[i]) < 0:\n count += 1\n sign = 0\nprint(count)']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s719261186', 's852757592', 's305101091']
[15020.0, 14224.0, 15020.0]
[75.0, 74.0, 72.0]
[332, 330, 332]
p03745
u731467249
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
["N = int(input())\nA = list(map(int, input().split()))\n\nli = []\n\nfor i in range(N-1):\n if A[i+1] - A[i] > 0:\n li.append('+')\n elif A[i+1] - A[i] < 0:\n li.append('-')\n else:\n pass\nprint(li)\nans = 1\np = 0\nm = 0\nfor i in li:\n if i == '+':\n p = 1\n elif i == '-':\n m = 1\n if p == 1 & m == 1:\n ans += 1\n p = 0\n m = 0\nprint(ans)", "N = int(input())\nA = list(map(int, input().split()))\n\nli = []\n\nfor i in range(N-1):\n if A[i+1] - A[i] > 0:\n li.append('+')\n elif A[i+1] - A[i] < 0:\n li.append('-')\n else:\n pass\n# print(li)\nans = 1\np = 0\nm = 0\nfor i in li:\n if i == '+':\n p = 1\n elif i == '-':\n m = 1\n if p == 1 & m == 1:\n ans += 1\n p = 0\n m = 0\nprint(ans)"]
['Wrong Answer', 'Accepted']
['s493999383', 's293592579']
[20268.0, 20452.0]
[98.0, 97.0]
[392, 394]
p03745
u733738237
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['N=int(input())\na=list(map(int,input().split()))\na.insert(0,0)\nprint(a,len(a))\ncnt=1\nval=0\nl=len(a)-1\nfor n in range(1,l):\n\tif a[n-1]<=a[n]:\n\t\tval=1\n\t\tcontinue\n\telif a[n-1]>a[n] and val==1:\n\t\tif n==l-2:\n\t\t\tcnt+=1\n\t\tval=0\n\t\tcnt+=1\n\telif a[n-1]>=a[n]:\n\t\tval=2\n\t\tcontinue\n\telif a[n-1]<a[n] and val==2:\n\t\tif n==l-2:\n\t\t\tcnt+=1\n\t\tval=0\n\t\tcnt+=1\nprint(cnt)', "N=int(input())\na=list(map(int,input().split()))\ncnt=1\nval='0'\nfor n in range(1,N):\n\tif a[n-1]==a[n] or (val=='+' and a[n-1]<a[n]) or (val=='-' and a[n-1]>a[n]):\n\t\tpass\n\telif val=='0':\n\t\t if a[n-1]<a[n]:\n\t\t \tval='+'\n\t\t elif a[n-1]>a[n]:\n\t\t \tval='-'\n\telse:\n\t\tval='0'\n\t\tcnt+=1\nprint(cnt)"]
['Wrong Answer', 'Accepted']
['s134064230', 's990969992']
[14480.0, 14228.0]
[101.0, 92.0]
[348, 284]
p03745
u740284863
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['import sys\ninput = sys.stdin.readline\nn = int(input())\nA = list(map(int,input().split()))\nans = 1\nfor i in range(n-1):\n if A[i] > A[i+1]:\n ans += 1\nprint(ans)', 'n = int(input())\na = list(map(int, input().split()))\n\nans = 1\nstatus = 0\nprev = a[0]\n\nfor i in a:\n diff = i - prev\n\n if diff == 0:\n pass\n elif diff > 0:\n if status >= 0:\n status = diff\n else:\n ans += 1\n status = 0\n else:\n if status <= 0:\n status = diff\n else:\n ans += 1\n status = 0\n\n prev = i\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s877325590', 's286423723']
[14252.0, 20140.0]
[73.0, 73.0]
[168, 420]
p03745
u757030836
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['N = int(input())\nA = list(map(int, input().split()))\n\nans = 1\nup,down = False,False\nfor i in range(N-1):\n if A[i] < A[i+1]:\n up = True\n elif A[i] > A[i+1]:\n down = True\n if up and dn:\n ans +=1\n up,down = False,False\n \nprint(ans)', 'N = int(input())\nA = list(map(int, input().split()))\n\nans = 1\nup, dn = False, False\nfor i in range(N-1):\n if A[i] < A[i+1]:\n up = True\n elif A[i] > A[i+1]:\n dn = True\n if up and dn:\n ans += 1\n up, dn = False, False\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s856027747', 's111967714']
[14252.0, 14252.0]
[75.0, 79.0]
[246, 263]
p03745
u760961723
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['N = int(input())\nA = list(map(int,input().split()))\n\nans = 1\ni = 0\n\nls = [0]*(N-1)\nfor i in range(N-1):\n if A[i] > A[i+1]:\n ls[i] = 1\n elif A[i] < A[i+1]:\n ls[i] = -1\n else:\n if i == 0:\n ls[i] = 0\n else:\n ls[i] = ls[i-1]\n\nprint(ls)\n\nj = 0\nwhile j < N-2:\n if ls[j] == 1:\n if ls[j+1] == -1:\n ans += 1\n j += 1\n elif ls[j] == -1:\n if ls[j+1] == 1:\n ans += 1\n j += 1\n j += 1\nprint(ans)\n', 'N = int(input())\nA = list(map(int,input().split()))\n \nans = 1\nmode = 0\nfor i in range(N-1):\n if mode == 0:\n if A[i] < A[i+1]:\n mode = 1\n elif A[i] > A[i+1]:\n mode = -1\n else:\n mode = 0\n if mode == 1:\n if A[i] > A[i+1]:\n ans += 1\n mode = 0\n elif mode == -1:\n if A[i] < A[i+1]:\n ans += 1\n mode = 0\n else:\n pass\nprint(ans)']
['Wrong Answer', 'Accepted']
['s920050581', 's837403482']
[14480.0, 14252.0]
[134.0, 79.0]
[435, 376]
p03745
u761320129
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['N = int(input())\nsrc = map(int,input().split())\nasc = 0\nans = 1\nfor i in range(N-1):\n d = src[i+1] - src[i]\n if asc * d < 0:\n ans += 1\n asc = 0\n else:\n asc = d\nprint(ans)', 'N = int(input())\nA = list(map(int,input().split()))\nup = dn = False\nans = 1\np = A[0]\nfor a in A:\n if p < a:\n up = True\n elif p > a:\n dn = True\n if up and dn:\n ans += 1\n up = dn = False\n p = a\nprint(ans)']
['Runtime Error', 'Accepted']
['s667534015', 's715212195']
[11096.0, 14252.0]
[27.0, 66.0]
[200, 242]
p03745
u767664985
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['N = int(input())\nA = [0] * N\nfor i in range(N):\n\tA[i] = int(input())\n\nfor j in range(1, N):\n\tif A[j] in A[: j]:\n\t\tA[A[: j].index(A[j])] = -1\n\t\tA[j] = -1\n\n\nprint(len([k for k in A if k != -1]))\n', 'N = int(input())\nA = list(map(int, input().split()))\n\nchange = 0 # 1, 0, -1\nans = 1\n\nfor i in range(N-1):\n if A[i+1] - A[i] > 0:\n if change == 0:\n change = 1\n elif change == -1:\n ans += 1\n change = 0\n else:\n continue\n elif A[i+1] - A[i] < 0:\n if change == 0:\n change = -1\n elif change == 1:\n ans += 1\n change = 0\n else:\n continue\n\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s763670611', 's334840992']
[5908.0, 14252.0]
[24.0, 82.0]
[193, 479]
p03745
u780475861
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['n, *lst = map(int, open(0).read().split())\nif n < 3:\n print(1)\n quit()\ngroup = 0\nstart = (lst[1] >= lst[0])\nfor i in range(2, n - 1):\n if (lst[i] >= lst[i - 1]) != start:\n start = (lst[i + 1] >= lst[i])\n group += 1\nif (lst[-1] >= lst[-2]) != start:\n group += 1\nif group != 0:\n group += 1\nprint(group)\n', 'n, *lst = map(int, open(0).read().split())\nif n < 3:\n print(0)\n quit()\ngroup = 0\nstart = lst[1] >= lst[0]\nfor i in range(2, n - 1):\n if (lst[i] >= lst[i - 1]) != start:\n start = (lst[i + 1] > lst[i])\n group += 1\nif (lst[-1] >= lst[-2]) != start:\n group += 1\nif group != 0:\n group += 1\nprint(group)', 'n, *lst = map(int, open(0).read().split())\nif n < 3:\n print(0)\n quit()\ngroup = 0\nstart = (lst[1] >= lst[0])\nfor i in range(2, n - 1):\n if (lst[i] >= lst[i - 1]) != start:\n start = (lst[i + 1] >= lst[i])\n group += 1\nif (lst[-1] >= lst[-2]) != start:\n group += 1\nif group != 0:\n group += 1\nprint(group)', 'n, *lst = map(int, open(0).read().split())\nif n < 3:\n print(1)\n quit()\ngroup = 1\nstart = (lst[1] >= lst[0])\nfor i in range(2, n - 1):\n if (lst[i] >= lst[i - 1]) != start:\n start = (lst[i + 1] >= lst[i])\n group += 1\nif (lst[-1] >= lst[-2]) != start:\n group += 1\nprint(group)\n', '_, *A = map(int, open(0).read().split())\nans = 1\nis_add = False\nis_minus = False\ntmp = A[0]\nfor a in A[1:]:\n if tmp > a:\n if is_add:\n ans += 1\n is_add = False\n else:\n is_minus = True\n elif tmp < a:\n if is_minus:\n ans += 1\n is_minus = False\n else:\n is_add = True\n tmp = a\nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s262817213', 's511302191', 's573592982', 's985622773', 's628138653']
[14052.0, 14052.0, 14052.0, 14052.0, 14052.0]
[71.0, 70.0, 70.0, 70.0, 69.0]
[312, 308, 311, 284, 326]
p03745
u785989355
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['\nN=int(input())\nA = list(map(int,input().split()))\nprev = A[0]\ncount=1\ndirection = 0\nfor i in range(1,N):\n if A[i] > prev:\n if direction==0:\n direction=1\n elif direction==-1:\n count+=1\n direction=1\n elif A[i] < prev:\n if direction==0:\n direction=-1\n elif direction==1:\n count+=1\n direction=1\n prev=A[i]\n \nprint(count)', 'N = int(input())\nA = list(map(int,input().split()))\n\norient=0\ncount=0\nprev=A[0]\n\nfor i in range(1,N):\n if A[i]<prev:\n if orient==1:\n count+=1\n prev=A[i]\n orient=0\n elif orient==-1:\n prev=A[i]\n else:\n orient=-1\n prev=A[i]\n elif A[i]>prev:\n if orient==-1:\n count+=1\n prev=A[i]\n orient=0\n elif orient==1:\n prev=A[i]\n else:\n orient=1\n prev=A[i]\n\n \nprint(count+1)']
['Wrong Answer', 'Accepted']
['s138968837', 's337041655']
[14252.0, 14436.0]
[82.0, 80.0]
[423, 544]
p03745
u787059958
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['n = int(input())\nL = list(map(int, input().split()))\n\nif n == 1:\n print(1)\n exit()\n\nd = [0] * (n - 1)\nif (L[0] > L[1]):\n d[0] = -1\nelif (L[0] < L[1]):\n d[0] = 1\n\ncnt = 1\ndec_cnt = 0\nfor i in range(n):\n if (i == 0):\n continue\n elif (i == n - 1):\n break\n else:\n print(d)\n if (L[i] < L[i + 1] and d[i - 1] >= 0):\n d[i] = 1\n elif (L[i] > L[i + 1] and d[i - 1] <= 0):\n d[i] = -1\n elif (L[i] < L[i + 1] and d[i - 1] < 0):\n cnt += 1\n elif (L[i] > L[i + 1] and d[i - 1] > 0):\n cnt += 1\n elif (L[i] == L[i + 1] and d[i - 1] > 0):\n cnt += 1\n elif (L[i] == L[i + 1] and d[i - 1] < 0):\n cnt += 1\n\n\nprint(cnt)\n', 'n = int(input())\nL = list(map(int, input().split()))\n\nif n == 1:\n print(1)\n exit()\n\nd = [0] * (n - 1)\nif (L[0] > L[1]):\n d[0] = -1\nelif (L[0] < L[1]):\n d[0] = 1\n\ncnt = 1\nfor i in range(n):\n if (i == 0):\n continue\n elif (i == n - 1):\n break\n else:\n if (L[i] < L[i + 1] and d[i - 1] >= 0):\n d[i] = 1\n if (d[i - 1] == 0):\n cnt += 1\n elif (L[i] > L[i + 1] and d[i - 1] <= 0):\n d[i] = -1\n if (d[i - 1] == 0):\n cnt += 1\n elif (L[i] < L[i + 1] and d[i - 1] < 0):\n cnt += 1\n elif (L[i] > L[i + 1] and d[i - 1] > 0):\n cnt += 1\n elif (L[i] == L[i + 1]):\n continue\n\nprint(cnt)\n', 'n = int(input())\nL = list(map(int, input().split()))\n\nif n == 1:\n print(1)\n exit()\n\nd = [0] * (n - 1)\nif (L[0] > L[1]):\n d[0] = -1\nelif (L[0] < L[1]):\n d[0] = 1\n\nfor i in range(n):\n if (i == 0):\n continue\n elif (i == n - 1):\n break\n else:\n if (L[i] < L[i + 1]):\n d[i] = 1\n elif (L[i] > L[i + 1]):\n d[i] = -1\n\nprev = 0\ncount = 0\nfor i in range(len(d)):\n if (i == 0):\n prev = d[i]\n continue\n if (prev == 1):\n if (d[i] == 1):\n continue\n elif (d[i] == 0):\n continue\n else:\n count += 1\n prev = 0\n elif (prev == -1):\n if (d[i] == -1):\n continue\n elif (d[i] == 0):\n continue\n else:\n count += 1\n prev = 0\n elif (prev == 0):\n if (d[i] == 1):\n prev = 1\n elif (d[i] == -1):\n prev = -1\n\nprint(count + 1)\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s323639785', 's858333001', 's984163596']
[109100.0, 14480.0, 14252.0]
[2104.0, 125.0, 115.0]
[747, 743, 955]
p03745
u787456042
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['N,*A=map(int,open(0).read().split());f=a=0\nfor i,j in zip(A,A[1:]):\n if f:\n if(f<0)&(i<j)|(0>f)&(i>j):a+=1;f=0\n else:f=(i<j)-(i>j)\nprint(a+1)', 'N,*A=map(int,open(0).read().split());f=a=0\nfor i,j in zip(A,A[1:]):\n if f:\n if(f<0)&(i<j)|(f>0)&(i>j):a+=1;f=0\n else:f=(i<j)-(i>j)\nprint(a+1)']
['Wrong Answer', 'Accepted']
['s145454296', 's947831237']
[14052.0, 14052.0]
[69.0, 73.0]
[142, 142]
p03745
u798818115
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['# coding: utf-8\n# Your code here!\n_=int(input())\nA=list(map(int,input().split()))\nN=len(A)\n\ntrend=0\nans=0\nfor i in range(N-1):\n temp=A[i+1]-A[i]\n if trend==0:\n if temp>0:\n trend=1\n ans+=1\n elif temp<0:\n trend=-1\n ans+=1\n else:\n pass\n elif trend==1:\n if temp>0:\n pass\n elif temp<0:\n trend=0\n else:\n pass\n elif trend==-1:\n if temp>0:\n trend=0\n elif temp<0:\n pass\n else:\n pass\nprint(trend)\nprint(ans if trend!=0 else ans+1)\n', '# coding: utf-8\n# Your code here!\n_=int(input())\nA=list(map(int,input().split()))\nN=len(A)\n\ntrend=0\nans=0\nfor i in range(N-1):\n temp=A[i+1]-A[i]\n if trend==0:\n if temp>0:\n trend=1\n ans+=1\n elif temp<0:\n trend=-1\n ans+=1\n else:\n pass\n elif trend==1:\n if temp>0:\n pass\n elif temp<0:\n trend=0\n else:\n pass\n elif trend==-1:\n if temp>0:\n trend=0\n elif temp<0:\n pass\n else:\n pass\n\nprint(ans if trend!=0 else ans+1)\n']
['Wrong Answer', 'Accepted']
['s778622490', 's488193075']
[14436.0, 14252.0]
[80.0, 82.0]
[617, 605]
p03745
u799479335
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['import numpy as np\nN = int(input())\nAs = input().split()\nfor i in range(N):\n As[i] = int(As[i])\nAs = np.array(As)\n\n\ndef get_sign(x):\n if x>0:\n return +1\n elif x<0:\n return -1\n else:\n return 0\n\nans = 1\na0 = None\na1 = None\nfor a in As:\n if a0 is None:\n a0 = a\n elif a1 is None:\n a1 = a\n else:\n if get_sign(a-a1)==get_sign(a1-a0):\n a0 = a1\n a1 = a\n elif get_sign(a-a1)==0:\n pass\n else:\n ans += 1\n a0 = a\n a1 = None\nprint(ans)', 'import numpy as np\nN = int(input())\nAs = input().split()\nfor i in range(N):\n As[i] = int(As[i])\nAs = np.array(As)\n\n\ndef get_sign(x):\n if x>=0:\n return +1\n else:\n return -1\n \nans = 1\na0 = None\na1 = None\nfor a in As:\n if a0 is None:\n a0 = a\n elif a1 is None:\n a1 = a\n else:\n if get_sign(a-a1)==get_sign(a1-a0):\n a0 = a1\n a1 = a\n else:\n ans += 1\n a0 = a\n a1 = None\nprint(ans)', 'import numpy as np\nN = int(input())\nAs = input().split()\nfor i in range(N):\n As[i] = int(As[i])\nAs = np.array(As)\n\n\ndef get_sign(x):\n if x>0:\n return +1\n elif x<0:\n return -1\n else:\n return 0\n\nans = 1\na0 = None\na1 = None\nfor a in As:\n if a0 is None:\n a0 = a\n elif a1 is None:\n a1 = a\n else:\n if (get_sign(a-a1)==get_sign(a1-a0))|(get_sign(a-a1)==0):\n a0 = a1\n a1 = a\n else:\n ans += 1\n a0 = a\n a1 = None\nprint(ans)', 'import numpy as np\nN = int(input())\nAs = input().split()\nfor i in range(N):\n As[i] = int(As[i])\nAs = np.array(As)\n\n\ndef get_sign(x):\n if x>0:\n return +1\n elif x<0:\n return -1\n else:\n return 0\n\nans = 1\na0 = None\na1 = None\nfor a in As:\n if a0 is None:\n a0 = a\n elif a1 is None:\n a1 = a\n else:\n if (get_sign(a-a1)==get_sign(a1-a0))|(get_sign(a1-a0)==0):\n a0 = a1\n a1 = a\n elif get_sign(a-a1)==0:\n pass\n else:\n ans += 1\n a0 = a\n a1 = None\nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s214016239', 's234638244', 's981636558', 's063729354']
[20160.0, 21392.0, 20144.0, 20164.0]
[538.0, 424.0, 690.0, 726.0]
[565, 498, 538, 588]
p03745
u814986259
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['N=int(input())\na=list(map(int,input().split()))\ndiff=[a[i+1]-a[i] for i in range(N-1)]\nans=[0,0]\n\nfor i in range(N-1):\n if diff[i]<0:\n ans[0]+=1\n elif diff[i]>0:\n ans[1]+=1\nprint(min(ans)+1)\n', 'N=int(input())\na=list(map(int,input().split()))\nflag=0\nans=1\nfor i in range(1,N):\n if flag== 0:\n if a[i]>a[i-1]:\n flag=1\n continue\n elif a[i]<a[i-1]:\n flag=-1\n continue\n else:\n continue\n elif flag>0:\n if a[i]<a[i-1]:\n ans+=1\n flag=0\n else:\n if a[i]>a[i-1]:\n ans+=1\n flag=0\nprint(ans) \n\n ']
['Wrong Answer', 'Accepted']
['s314650629', 's273946951']
[14252.0, 14252.0]
[76.0, 77.0]
[199, 356]
p03745
u835283937
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['def main():\n # N = int(input())\n # A = [int(a) for a in input().split()]\n\n f = open("subtask_1_02.txt", "r")\n N = int(f.readline())\n A = [int(a) for a in f.readline().split()]\n\n idx = 0\n ans = 0\n for i in range(len(A)):\n if idx + 1 > len(A) - 1 :\n break\n\n m = ""\n if A[idx] < A[idx + 1]:\n m = "+"\n elif A[idx] > A[idx + 1]:\n m = "-"\n else:\n find = False\n for j in range(idx, len(A)-1):\n if A[j] < A[j + 1]:\n m = "+"\n find = True\n idx = j\n break\n elif A[j] > A[j + 1]:\n m = "-"\n find = True\n idx = j\n break\n if find == False:\n print(ans + 1)\n exit()\n\n for j in range(idx, len(A) - 1):\n if m == "+":\n if A[j] <= A[j + 1]:\n idx = j + 1\n else:\n idx = j + 1\n ans += 1\n break\n elif m == "-":\n if A[j] >= A[j + 1]:\n idx = j + 1\n else:\n idx = j + 1\n ans += 1\n break\n\n print(ans + 1)\n\nif __name__ == "__main__":\n main()', 'def main():\n N = int(input())\n A = [int(a) for a in input().split()]\n\n idx = 0\n ans = 0\n for i in range(len(A)):\n if idx + 1 > len(A) - 1 :\n break\n\n m = ""\n if A[idx] < A[idx + 1]:\n m = "+"\n elif A[idx] > A[idx + 1]:\n m = "-"\n else:\n find = False\n for j in range(idx, len(A)-1):\n if A[j] < A[j + 1]:\n m = "+"\n find = True\n idx = j\n break\n elif A[j] > A[j + 1]:\n m = "-"\n find = True\n idx = j\n break\n if find == False:\n print(ans + 1)\n exit()\n\n for j in range(idx, len(A) - 1):\n if m == "+":\n if A[j] <= A[j + 1]:\n idx = j + 1\n else:\n idx = j + 1\n ans += 1\n break\n elif m == "-":\n if A[j] >= A[j + 1]:\n idx = j + 1\n else:\n idx = j + 1\n ans += 1\n break\n\n print(ans + 1)\n\nif __name__ == "__main__":\n main()']
['Runtime Error', 'Accepted']
['s516847398', 's474129629']
[9096.0, 20164.0]
[26.0, 91.0]
[1394, 1278]
p03745
u835482198
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['N = int(input())\nA = list(map(int, input().split))\n# N = 9\n# A = [1, 2, 1, 2, 1, 2, 1, 2, 1]\n# N = 7\n# A = [1, 2, 3, 2, 1, 999999999, 1000000000]\n# N = 6\n# A = [1, 2, 3, 2, 2, 1]\n# N = 2\n# A = [1, 1]\nA = A + [A[-1]]\n\nd = 0\ni = 0\n\ninc = None\nwhile i < N:\n if inc is None:\n if A[i] < A[i + 1]:\n inc = True\n d += 1\n elif A[i] > A[i + 1]:\n inc = False\n d += 1\n else:\n inc = None\n else:\n if inc:\n if A[i] > A[i + 1]:\n inc = None\n else:\n if A[i] < A[i + 1]:\n inc = None\n i += 1\n\nif inc is None:\n d += 1\nprint(d)\n', 'N = int(input())\nA = list(map(int, input().split()))\n# N = 9\n# A = [1, 2, 1, 2, 1, 2, 1, 2, 1]\n# N = 7\n# A = [1, 2, 3, 2, 1, 999999999, 1000000000]\n# N = 6\n# A = [1, 2, 3, 2, 2, 1]\n# N = 2\n# A = [1, 1]\nA = A + [A[-1]]\n\nd = 0\ni = 0\n\ninc = None\nwhile i < N:\n if inc is None:\n if A[i] < A[i + 1]:\n inc = True\n d += 1\n elif A[i] > A[i + 1]:\n inc = False\n d += 1\n else:\n inc = None\n else:\n if inc:\n if A[i] > A[i + 1]:\n inc = None\n else:\n if A[i] < A[i + 1]:\n inc = None\n i += 1\n\nif inc is None:\n d += 1\nprint(d)\n']
['Runtime Error', 'Accepted']
['s158174043', 's432767859']
[5132.0, 15020.0]
[19.0, 82.0]
[660, 662]
p03745
u846226907
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['import sys\n\nread= sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nMOD = 1000000007\nsys.setrecursionlimit(10**7)\n\nN = int(readline())\nA = list(map(int,readline().split()))\n\nres = 0\n\nin_i = 0\nde_i = 0\ni = 0\nwhile i <= N-1:\n for j in range(i+1,N):\n if A[j] >= A[j-1]:continue\n else:\n break\n\n in_i = j\n for j in range(i+1,N):\n if A[j] <= A[j-1]:continue\n else:\n break\n de_i = j\n\n i = max(de_i,in_i)\n res+=1\nprint(i)\n\nprint(res)\n\n', 'import sys\n\nread= sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nMOD = 1000000007\nsys.setrecursionlimit(10**7)\n\n#N,*A = map(int,read().split())\nN = int(input())\nA = list(map(int,input().split()))\n\n\n\n\n\nState = 0\n\n\nres = 1\n\nfor i in range(1,N):\n \n \n\n \n \n \n \n if A[i] > A[i-1]: \n X = 1 \n elif A[i] == A[i-1]: \n X = 0\n else :\n X = -1\n\n \n if X == State:\n continue\n \n \n if State == 0: \n State = X \n\n \n if X != State and X != 0: \n res += 1 \n State = 0 \n\nprint(res)\n\n\n']
['Runtime Error', 'Accepted']
['s984572817', 's527842943']
[12992.0, 14484.0]
[2104.0, 93.0]
[543, 1184]
p03745
u852798899
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['n = int(input())\na = list(map(int, input().split()))\n\nans = 1\njudge = -1\nfor i in range(n-1):\n if a[i] == a[i+1]:\n break\n elif a[i] < a[i+1]:\n if judge == -1:\n ans += 1\n else:\n judge = 1\n elif a[i] > a[i+1]:\n if judge == 1:\n ans += 1\n else:\n judge = 1 \nprint(ans)', 'n = int(input())\na = list(map(int, input().split()))\n\nflag = 0\n \nans = 1\nfor i in range(n - 1):\n if flag == 1:\n if a[i] > a[i + 1]:\n ans += 1\n flag = 0\n elif flag == -1:\n if a[i] < a[i + 1]:\n ans += 1\n flag = 0\n else:\n if a[i] > a[i + 1]:\n flag = -1\n elif a[i] < a[i + 1]:\n flag = 1\nprint(ans)']
['Wrong Answer', 'Accepted']
['s980554827', 's132343888']
[14252.0, 14252.0]
[89.0, 75.0]
[306, 338]
p03745
u854685751
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['N = int(input())\na = list(map(int,input().split(" ")))\n\nc = 1\n\nt = a[0]\nfor i in a[1:]:\n\tif t > i:\n\t\tc += 1\n\tt = i\n\nprint(c)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n', 'N = int(input())\na = list(map(int, input().split(" ")))\n\nl = [[] for i in range(N)]\nc = 0\n\ns = 0\nt = a[0]\n\nfor i in a[1:]:\n\tif t > i:\n\t\tl[s].append((s,c))\n\t\ts = c+1\n\tc += 1\n\tt = i\nelse:\n\tl[s].append((s,c))\n\nc = 0\n\ns = 0\nt = a[0]\n\nfor i in a[1:]:\n\tif t < i:\n\t\tl[s].append((s,c))\n\t\ts = c+1\n\tc += 1\n\tt = i\nelse:\n\tl[s].append((s,c))\n\nfor i in range(N):\n\tl[i].sort()\n\nnow = 0\nres = 0\nwhile now < N:\n\tnow = l[now][-1][1]+1\n\tres+=1\n\nprint(res)', 'N = int(input())\na = list(map(int, input().split(" ")))\n\n\nl = [[] for i in range(N)]\nc = 0\n\ns = 0\nt = a[0]\n\nfor i in a[1:]:\n\tif t > i:\n\t\tl[s].append((c))\n\t\ts = c+1\n\tc += 1\n\tt = i\nelse:\n\tl[s].append((c))\n\nc = 0\n\ns = 0\nt = a[0]\n\nfor i in a[1:]:\n\tif t < i:\n\t\tl[s].append((c))\n\t\ts = c+1\n\tc += 1\n\tt = i\nelse:\n\tl[s].append((c))\n\nl[0] = max(l[0])\nfor i in range(1,N):\n\tl[i].append(-1)\nfor i in range(1,N):\n\t\n\tif i!=N-1:\n\t\tl[i+1].append(-1)\n\t\tl[i] = max(l[i-1],max(l[i]),max(l[i+1]))\n\telse:\n\t\tl[i] = max(l[i-1],max(l[i]))\n\n\nnow = 0\nres = 0\n\nwhile now<N-1:\n\tnow = l[now]\t\n\tres+=1\nif N==1:\n\tprint(1)\n\texit()\nprint(res)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s003678069', 's558556986', 's698445343']
[14252.0, 33044.0, 23444.0]
[55.0, 170.0, 259.0]
[142, 436, 608]
p03745
u857070771
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['n=int(input())\n*a,=map(int,input().split())\ncnt=0\nmode=0\nfor i in range(n-1):\n if mode==0:\n if a[i]<a[i+1]:\n cnt+=1\n mode="inc"\n elif a[i]>a[i+1]:\n cnt+=1\n mode="dec"\n if a[i]<a[i+1]:\n if mode=="inc":\n pass\n else:\n mode=0\n elif a[i]>a[i+1]:\n if mode=="dec":\n pass\n else:\n mode=0\nif mode==0:\n print(cnt+1)\nelse:\n prnt(cnt)', 'n=int(input())\n*a,=map(int,input().split())\ncnt=0\nmode=0\nfor i in range(n-1):\n if mode==0:\n if a[i]<a[i+1]:\n cnt+=1\n mode="inc"\n elif a[i]>a[i+1]:\n cnt+=1\n mode="dec"\n if a[i]<a[i+1]:\n if mode=="inc":\n pass\n else:\n mode=0\n elif a[i]>a[i+1]:\n if mode=="dec":\n pass\n else:\n mode=0\nif mode==0:\n print(cnt+1)\nelse:\n print(cnt)']
['Runtime Error', 'Accepted']
['s273923830', 's051169538']
[14252.0, 14252.0]
[89.0, 94.0]
[466, 467]
p03745
u868701750
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['N = int(input())\nA = list(map(int, input().split()))\na = A[::]\n\ncount = 1\nwhile len(a) > 1:\n first_tilt = 0\n for i in range(1, len(a)):\n if a[i] - a[i - 1] > 0:\n first_tilt = 1\n break\n if a[i] - a[i - 1] < 0:\n first_tilt = -1\n break\n\n if first_tilt == 1:\n for i in range(1, len(a)):\n if a[i] - a[i-1] < 0:\n a = a[i:]\n count += 1\n break\n if len(a)-1 == i: \n a = a[i:]\n\n if first_tilt == -1:\n\n for i in range(1, len(a)):\n print(i, a[i])\n if a[i] - a[i-1] > 0:\n a = a[i:]\n count += 1\n break\n if len(a)-1 == i: \n a = a[i:]\n\nprint(count)', 'N = int(input())\nA = list(map(int, input().split()))\n\ncount = 1\nstate = 0\nfor i in range(N-1):\n diff = A[i+1] - A[i]\n if state == 0:\n if diff > 0:\n state = 1\n continue\n if diff == 0:\n state = 0\n continue\n if diff < 0:\n state = -1\n continue\n if state == 1:\n if diff > 0:\n state = 1\n continue\n if diff == 0:\n state = 1\n continue\n if diff < 0:\n count += 1\n state = 0\n continue\n if state == -1:\n if diff > 0:\n count += 1\n state = 0\n continue\n if diff == 0:\n state = -1\n continue\n if diff < 0:\n state = -1\n continue\n\nprint(count)\n']
['Wrong Answer', 'Accepted']
['s652912070', 's595342393']
[14100.0, 14432.0]
[2108.0, 83.0]
[827, 820]
p03745
u896741788
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['n=int(input())\nl=[0]+list(map(int,input().split()))+[0]\na,s=0,0\nfor i in range(1,n+1):\n fa,fs=1,1\n if l[i-1]<=l[i]:fa=0\n if l[n-i]>=l[n-i+1]:fs=0\n a+=fa\n s+=fs\nprint(min(a,s)+1)', 'n=int(input())\nl=list(map(int,input().split()))\nif len(set(l))==1:print(1);exit()\nfrom itertools import groupby as gb\nl=[a for a,b in gb(l)]\nans=1\nnow=0 if l[0]<l[1] else 1\npre=l[0]\nn=len(l)\nfor i in range(n):\n if pre<l[i] and now:\n if i==n-1:print(ans+1);exit()\n else:\n now=0 if l[i]<l[i+1] else 1\n ans+=1\n elif pre>l[i] and 1-now:\n if i==n-1:print(ans+1);exit()\n else:\n now=0 if l[i]<l[i+1] else 1\n ans+=1\n pre=l[i]\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s766591380', 's647283407']
[15020.0, 14736.0]
[112.0, 101.0]
[182, 513]
p03745
u897329068
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['N = int(input())\nAN = list(map(int,input().split()))\n\ncuts = []\ncutNum = []\nfor beforePM in [1,-1]:\n\tcuts = []\n\tfor ai in range(N-1):\n\t\tif beforePM == 1:\n\t\t\tif AN[ai] < AN[ai+1]:\n\t\t\t\tbeforePM = -1\n\t\t\t\tai+=1\n\t\t\t\tcuts.append(1)\n\t\t\telif AN[ai] > AN[ai+1]:\n\t\t\t\tcuts.append(0)\n\t\t\telse:\n\t\t\t\tcuts.append(0)\n\t\telse:\n\t\t\tif AN[ai] < AN[ai+1]:\n\t\t\t\tcuts.append(0)\n\t\t\telif AN[ai] > AN[ai+1]:\n\t\t\t\tbeforePM = 1\n\t\t\t\tai+=1\n\t\t\t\tcuts.append(1)\n\t\t\telse:\n\t\t\t\tcuts.append(0)\n\t\t\t\t\n\tfor i in range(len(cuts)-1):\n\t\tif cuts[i] == 1:\n\t\t\tcuts[i+1] = 0\n\t\n\tprint(cuts)\n\tcutNum.append(sum(cuts))\n\nprint(min(cutNum)+1)', 'N = int(input())\nA = list(map(int,input().split()))\n \nans = 1\nsumDiff = 0\t\n\t\t\n\t\t\nfor i in range(1,len(A)):\n\t\n\tdiff = A[i]-A[i-1]\n\tif sumDiff*diff < 0:\t\t\n\t\tans += 1\n\t\tsumDiff = 0\t\t\n\t\t\t\t\t\n\telse:\n\t\tsumDiff += diff\t\t\n \nprint(ans)']
['Wrong Answer', 'Accepted']
['s878775478', 's019517194']
[14100.0, 14252.0]
[160.0, 78.0]
[586, 856]
p03745
u903005414
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
["import numpy as np\nN = int(input())\nA = np.array(list(map(int, input().split())))\n\nv = A[1:] - A[:-1]\n# print(v)\n\ncnt = 0\ni = 0\nwhile i <= len(v) - 1:\n # print('i', i)\n if v[i] * v[i + 1] < 0:\n cnt += 1\n i += 1\n i += 1\nans = cnt + 1\nprint(ans)\n\n\n\n\n", 'import sys\ninput = sys.stdin.buffer.readline\nN = int(input())\nA = list(map(int, input().split()))\nd = 0\nans = 1\nfor i in range(1, N):\n if A[i - 1] < A[i]:\n if d < 0:\n ans += 1\n d = 0\n elif d == 0:\n d = 1\n elif A[i - 1] > A[i]:\n if d > 0:\n ans += 1\n d = 0\n elif d == 0:\n d = -1\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s429074710', 's103144115']
[23128.0, 18336.0]
[350.0, 76.0]
[418, 388]
p03745
u905582793
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['n = int(input())\na = list(map(int,input().split()))\nflg = 0\nans = 0\nfor i in range(1,n):\n if a[i] == a[i-1]:\n continue\n elif a[i] > a[i-1]:\n if flg == -1:\n ans += 1\n flg = 1\n elif a[i] < a[i-1]:\n if flg == 1:\n ans += 1\n flg = -1\nprint(ans)', 'n = int(input())\na = list(map(int,input().split()))\nflg = 0\nans = 0\nfor i in range(1,n):\n if a[i] == a[i-1]:\n continue\n elif a[i] > a[i-1]:\n if flg == -1:\n ans += 1\n flg = 0\n else:\n flg = 1\n elif a[i] < a[i-1]:\n if flg == 1:\n ans += 1\n flg = 0\n else:\n flg = -1\nprint(ans+1)']
['Wrong Answer', 'Accepted']
['s960215051', 's131000730']
[14224.0, 14224.0]
[90.0, 93.0]
[267, 321]
p03745
u912652535
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['\nimport numpy as np\n\nn = int(input())\na = np.array(list(map(int,input().split())))\n\n\nret = 0\ni = 0\nwhile i < len(a):\n j = i\n while j < n -1 and a[j] <= a[j+1]:\n j += 1\n h = i\n while h < n - i and a[h] >= a[h +1 ]:\n h += 1\n i = max(h,j) + 1\n ret += 1\n\nprint(ret)\n', '\nimport numpy as np\n\nn = int(input())\na = np.array(list(map(int,input().split())))\n\n\nret = 0\ni = 0\nwhile i < len(a):\n j = i\n while j < n -1 and a[j] <= a[j+1]:\n j += 1\n h = i\n while h < n - 1 and a[h] >= a[h +1]:\n h += 1\n i = max(h,j) + 1\n ret += 1\n\nprint(ret)\n']
['Runtime Error', 'Accepted']
['s623498491', 's568579399']
[23128.0, 23084.0]
[2109.0, 279.0]
[303, 294]
p03745
u941438707
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['n,*a=map(int,open(0).read().split()) \na+=[0]\nb,c,=a[0]>a[1],0\nfor i in range(n-1):\n if a[i]==a[i+1]:\n continue\n elif (a[i]>a[i+1])!=b:\n b=a[i+1]>a[i+2]\n c+=1\nprint(c+1) ', 'n,*a=map(int,open(0).read().split())\nans=1\nvec=0\nfor i in range(n-1):\n now=a[i+1]-a[i]\n if vec*now<0:\n ans+=1\n vec=0\n elif vec==0:\n vec=now\nprint(ans)']
['Wrong Answer', 'Accepted']
['s851142273', 's229586914']
[14052.0, 20072.0]
[83.0, 77.0]
[203, 180]
p03745
u942051624
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['N=int(input())\nA=list(map(int,input().split()))\nif N==1:\n print(1)\n exit()\n\nB=[A[i]-A[i-1] for i in range(1,N)]\nans=0\nfor i in range(N-1):\n if B[i]!=0:\n first=B[i]\nfor i in range(N-1):\n if first*B[i]>=0:\n pass\n else:\n ans+=1\n if i+1<=N-2:\n first=B[i+1]\n\nprint(ans+1)', 'N=int(input())\nA=list(map(int,input().split()))\nif N==1:\n print(1)\n exit()\n\nB=[A[i]-A[i-1] for i in range(1,N)]\nans=0\nflag=False\nfor i in range(N-1):\n if B[i]!=0:\n first=B[i]\n flag=True\n if flag:\n break\nfor i in range(N-1):\n if first*B[i]>=0:\n pass\n else:\n ans+=1\n j=i+1\n while j<=N-2:\n if B[j]!=0:\n first=B[j]\n break\n else:\n j+=1\n\nprint(ans+1)']
['Wrong Answer', 'Accepted']
['s000404519', 's588650184']
[20372.0, 20196.0]
[96.0, 88.0]
[320, 478]
p03745
u943707649
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['N = int(input())\nA = list(map(int, input().split(" ")))\n\nlist = []\nsim=0\nfor i in range(N-1):\n if A[i]<A[i+1]:\n list.append(1)\n if A[i]>A[i+1]:\n list.append(0)\n if A[i]==A[i+1]:\n sim+=1\n\nprint(list)\n\ni = 0\ncount = 0\n\nwhile i<N-2-sim:\n if list[i] != list[i+1]:\n count += 1\n i+=1\n i+=1\n\nprint(count + 1)', 'N = int(input())\nA = list(map(int, input().split(" ")))\n\nlist = []\nsim=0\nfor i in range(N-1):\n if A[i]<A[i+1]:\n list.append(1)\n if A[i]>A[i+1]:\n list.append(0)\n if A[i]==A[i+1]:\n sim+=1\n \ni = 0\ncount = 0\n\nwhile i<N-2-sim:\n if list[i] != list[i+1]:\n count += 1\n i+=1\n i+=1\n\nprint(count + 1)']
['Wrong Answer', 'Accepted']
['s335782947', 's913107703']
[20368.0, 20192.0]
[117.0, 111.0]
[321, 312]
p03745
u944643608
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['N = int(input())\nA = list(map(int, input().split()))\ncount = 0\nup = 0\ndown = 0\nbefore = A[0]\ntmp = 0\nfor i in range(1,N):\n tmp = A[i]\n if (up == 0) and (down == 0):\n if tmp > before:\n up = 1\n before = tmp\n elif tmp < before:\n down = 1\n before = tmp\n else:\n continue\n ', 'print(1)', 'N = int(input())\nA = list(map(int,input().split()))\ncount = 0\nup = 0\ndown = 0\nbefore = A[0]\ntmp = 0\nfor i in range(1,N):\n tmp = A[i]\n if (up == 0) and (down == 0):\n if tmp > before:\n up = 1\n before = tmp\n elif tmp < before:\n down = 1\n before = tmp\n else:\n continue\n elif up == 1:\n if tmp < before:\n count += 1\n up = 0\n before = tmp\n elif down = 1:\n if tmp > before:\n count += 1\n down = 0\n before = tmp\ncount += 1\nprint(count)\n ', 'N = int(input())\nA = list(map(int, input().split()))\ncount = 0\nup = 0\ndown = 0\nbefore = A[0]\ntmp = 0\nfor i in range(1,N):\n tmp = A[i]\n if (up == 0) and (down == 0):\n if tmp > before:\n up = 1\n before = tmp\n elif tmp < before:\n down = 1\n before = tmp\n else:\n continue\n elif up == 1:\n if tmp < before:\n count += 1\n up = 0\n before = tmp\n elif down = 1:\n if tmp > before:\n count += 1\n down = 0\n before = tmp\ncount += 1\nprint(count)\n \n', 'N = int(input())\nA = list(map(int, input().split()))\ncount = 0\nup = 0\ndown = 0\nbefore = A[0]\ntmp = 0\n', 'N = int(input())\nA = list(map(int, input().split()))\ncount = 0\nup = 0\ndown = 0\nbefore = A[0]\ntmp = 0\nfor i in range(1,N):\n tmp = A[i]\n if (up == 0) and (down == 0):\n if tmp > before:\n up = 1\n before = tmp\n elif tmp < before:\n down = 1\n before = tmp\n else:\n continue\n elif up == 1:\n if tmp < before:\n count += 1\n up = 0\n before = tmp\n else:\n before = tmp\n elif down == 1:\n if tmp > before:\n count += 1\n down = 0\n before = tmp\n else:\n before = tmp\ncount += 1\nprint(count)\n \n']
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s677578538', 's690924921', 's769203347', 's836471977', 's869057001', 's844251207']
[15020.0, 2940.0, 3064.0, 3064.0, 14252.0, 14436.0]
[57.0, 17.0, 17.0, 17.0, 45.0, 77.0]
[303, 8, 506, 508, 101, 567]
p03745
u948524308
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['N = int(input())\nA = list(map(int,input().split()))\n\nc = 0\ni =2\n\nif N ==1 or N ==2:\n print(1)\n exit()\nwhile i<N+1:\n if (A[i-1]-A[i-2])*(A[i]-A[i-1])<0:\n c=c+1\n i = i+1\n i = i+1\nprint(c+1)', 'N,C,K = map(int,input().split())\nT = [int(input()) for i in range(N)]\n\nT.sort()\ni = 0\nans = 0\n\nwhile i < N:\n t = T[i]\n x = T.count(T[i])\n ans = ans + (x-1+C)//C\n for j in range(i+((x-1+C)//C)*C-1,N):\n if T[j]>t+K:\n y = j-i\n break\n y = N-i\n \n y=min(C,y)\n i = i + y \n\nprint(ans)', 'N = int(input())\nA = list(map(int,input().split()))\n\nif N ==1 or N ==2:\n print(1)\n exit()\nt = 0\nc =1\nfor i in range(1,N):\n\n if A[i]-A[i-1]>0:\n if t == -1:\n c +=1\n t = 0\n else:\n t = 1\n elif A[i]-A[i-1]<0:\n if t == 1:\n c +=1\n t = 0\n else:\n t = -1 \nprint(c)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s257600506', 's819908091', 's328078628']
[14252.0, 3064.0, 14252.0]
[92.0, 17.0, 81.0]
[213, 341, 363]
p03745
u953794676
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['n = 6\na = [int(e) for e in input().split()]\ncount = 1\nfor i in range(1, len(a)-1):\n if a[i] < a[i-1] and a[i+1] < a[i]:\n count = count + 1\n elif a[i] > a[i-1] and a[i] > a[i+1] :\n count = count + 1\nprint(count)', 'N = int(input())\nA = list(map(int,input().split()))\ni = 0\ncount = 1\nwhile i < N-1:\n while i < N-1 and A[i] == A[i+1]:\n i += 1\n # Up\n if A[i] < A[i+1]:\n while i < N-1 and A[i] <= A[i+1]:\n i += 1\n if i < N-1:\n count += 1\n i += 1\n # Down\n elif A[i] > A[i+1]:\n while i < N-1 and A[i] >= A[i+1]:\n i += 1\n if i < N-1:\n count += 1\n i += 1\nprint(count)']
['Wrong Answer', 'Accepted']
['s099912449', 's512614531']
[3060.0, 14224.0]
[17.0, 96.0]
[230, 460]
p03745
u954774382
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['import sys\nfrom functools import lru_cache, cmp_to_key\nfrom heapq import merge, heapify, heappop, heappush\nfrom math import *\n# import math\nfrom collections import defaultdict as dd, deque, Counter as C\nfrom itertools import combinations as comb, permutations as perm\nfrom bisect import bisect_left as bl, bisect_right as br, bisect\nfrom time import perf_counter\nfrom fractions import Fraction\n\nsys.stdin = open("input.txt", "r")\nsys.stdout = open("output.txt", "w")\nmod = int(pow(10, 9) + 7)\nmod2 = 998244353\ndef data(): return sys.stdin.readline().strip()\ndef out(*var, end="\\n"): sys.stdout.write(\' \'.join(map(str, var))+end)\ndef l(): return list(sp())\ndef sl(): return list(ssp())\ndef sp(): return map(int, data().split())\ndef ssp(): return map(str, data().split())\ndef l1d(n, val=0): return [val for i in range(n)]\ndef l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]\n\n\n\n\n\n# @lru_cache(None)\n\n\n\n\n\n\n\n# for j in range(2*i,10**6+1,i):\n\n\n\nn=int(input())\na=list(map(int,input().split()))\nans=1\ntemp=0\nfor i in range(1,n):\n if a[i-1]<a[i] and temp==0:\n temp=1\n elif a[i-1]>a[i] and temp==0:\n temp=2\n elif a[i-1]>a[i] and temp==1:\n temp=0\n ans=ans+1\n elif a[i-1]<a[i] and temp==2:\n temp=0\n ans=ans+1\nprint(ans)', 'import sys\nfrom functools import lru_cache, cmp_to_key\nfrom heapq import merge, heapify, heappop, heappush\nfrom math import *\n# import math\nfrom collections import defaultdict as dd, deque, Counter as C\nfrom itertools import combinations as comb, permutations as perm\nfrom bisect import bisect_left as bl, bisect_right as br, bisect\nfrom time import perf_counter\nfrom fractions import Fraction\n\n\n#sys.stdout = open("output.txt", "w")\nmod = int(pow(10, 9) + 7)\nmod2 = 998244353\ndef data(): return sys.stdin.readline().strip()\ndef out(*var, end="\\n"): sys.stdout.write(\' \'.join(map(str, var))+end)\ndef l(): return list(sp())\ndef sl(): return list(ssp())\ndef sp(): return map(int, data().split())\ndef ssp(): return map(str, data().split())\ndef l1d(n, val=0): return [val for i in range(n)]\ndef l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]\n\n\n\n\n\n# @lru_cache(None)\n\n\n\n\n\n\n\n# for j in range(2*i,10**6+1,i):\n\n\n\nn=int(input())\na=list(map(int,input().split()))\nans=1\ntemp=0\nfor i in range(1,n):\n if a[i-1]<a[i] and temp==0:\n temp=1\n elif a[i-1]>a[i] and temp==0:\n temp=2\n elif a[i-1]>a[i] and temp==1:\n temp=0\n ans=ans+1\n elif a[i-1]<a[i] and temp==2:\n temp=0\n ans=ans+1\nprint(ans)']
['Runtime Error', 'Accepted']
['s440677161', 's464876063']
[5124.0, 16304.0]
[36.0, 123.0]
[1456, 1458]
p03745
u957084285
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['n = int(input())\na = list(map(int, input().split()))\n\na.sort(reverse=True)\n\nans = 0\nfor i in range(n):\n ans += a[2*i+1]\n\nprint(ans)', 'n = int(input())\nb = list(map(int, input().split()))\na = [b[0]]\nfor i in range(1, n):\n if a[-1] != b[i]:\n a.append(b[i])\n\nans = 1\ninc = a[0] < a[min(1, n-1)]\n\nn = len(a)\ni = 1\nwhile i < n:\n if (a[i-1] < a[i]) ^ inc:\n ans += 1\n inc = a[i] < a[min(i+1, n-1)]\n i += 2\n else:\n i += 1\nprint(ans)']
['Runtime Error', 'Accepted']
['s482480801', 's573690931']
[14252.0, 14224.0]
[87.0, 101.0]
[134, 334]
p03745
u962829271
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
["import pdb\n\n\ndef main():\n num = int(input())\n array = []\n tmp = input()\n for i in range(num):\n array.append(int(tmp.split()[i]))\n \n ans = 1\n div = 0\n prev = 0\n count = 0\n #pdb.set_trace()\n for tmp in array:\n count += 1\n if(count == 1):\n prev = tmp\n continue\n\n if div == 0:\n if prev < tmp:\n div = 1\n elif prev > tmp:\n div = -1\n else:\n if prev < tmp and div == -1:\n ans += 1\n div = 0\n elif prev > tmp and div == 1:\n ans += 1\n div = 0\n\n\n prev = tmp\n \n print(ans)\n\n \nif __name__ == '__main__':\n main()\n", "import pdb\n\n\ndef main():\n num = int(input())\n array = []\n tmp = input()\n tmp = tmp.split()\n for i in range(num):\n array.append(int(tmp[i]))\n \n ans = 1\n div = 0\n prev = 0\n count = 0\n #pdb.set_trace()\n for tmp in array:\n count += 1\n if count == 1:\n prev = tmp\n continue\n\n if div == 0:\n if prev < tmp:\n div = 1\n elif prev > tmp:\n div = -1\n else:\n if prev < tmp and div == -1:\n ans += 1\n div = 0\n elif prev > tmp and div == 1:\n ans += 1\n div = 0\n \n prev = tmp\n \n print(ans)\n\n \nif __name__ == '__main__':\n main()\n"]
['Wrong Answer', 'Accepted']
['s231226192', 's338054558']
[13344.0, 16284.0]
[2104.0, 97.0]
[781, 781]
p03745
u968404618
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['n = int(input())\na = list(map(int, input().split()))\n\nans = 1\nx = 0\n\nfor i in range(n-1):\n if A[i] < A[i+1]:\n if x == -1:\n ans += 1\n x = 0\n elif x == 0:\n x = 1\n elif A[i] > A[i+1]:\n if x == 1:\n ans += 1\n x = 0\n elif x == 0:\n x = -1\nprint(ans)', 'n = int(input())\na = list(map(int, input().split()))\n\nans = 1\nx = 0\n\nfor i in range(n-1):\n if a[i] < a[i+1]:\n if x == -1:\n ans += 1\n x = 0\n elif x == 0:\n x = 1\n elif a[i] > a[i+1]:\n if x == 1:\n ans += 1\n x = 0\n elif x == 0:\n x = -1\nprint(ans)']
['Runtime Error', 'Accepted']
['s529705504', 's080139080']
[14252.0, 14228.0]
[42.0, 80.0]
[342, 342]
p03745
u980205854
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['\nimport numpy as np\n\nN = int(input())\nA = list(map(int, input().split()))\nsgn = 0\nans = 1\n\nfor i in range(N-1):\n tmp = np.sign(A[i+1]-A[i])\n if tmp*sgn<0:\n ans += 1\n sgn = np.sign(2*sgn+tmp)\n\nprint(ans)', '\nimport numpy as np\n\nN = int(input())\nA = list(map(int, input().split()))\nsgn = 0\nans = 1\n\nfor i in range(N-1):\n tmp = np.sign(A[i+1]-A[i])\n if tmp*sgn<0:\n ans += 1\n sgn = 0\n else:\n sgn = np.sign(2*sgn+tmp)\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s255200633', 's319550619']
[23128.0, 23208.0]
[818.0, 810.0]
[237, 267]
p03745
u993268357
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
["n = int(input().split())\nnum_list = [int(i) for i in input().split()]\nif len(num_list)==1:\n print(1)\nelse:\n res = 1\n flag = None\n pre = num_list[0]\n for i in num_list[1:]:\n if pre > i and not flag:\n flag = 'down'\n \n elif pre < i and not flag:\n flag = 'up'\n \n elif (pre > i and flag=='up') or (pre < i and flag=='down'):\n res += 1\n flag = None\n pre = i\n print(res)", "n = int(input())\nnum_list = [int(i) for i in input().split()]\nif len(num_list)==1:\n print(1)\nelse:\n res = 1\n flag = None\n pre = num_list[0]\n for i in num_list[1:]:\n if pre > i and not flag:\n flag = 'down'\n \n elif pre < i and not flag:\n flag = 'up'\n \n elif (pre > i and flag=='up') or (pre < i and flag=='down'):\n res += 1\n flag = None\n pre = i\n print(res)"]
['Runtime Error', 'Accepted']
['s250474773', 's175905998']
[3064.0, 14252.0]
[17.0, 80.0]
[407, 399]
p03745
u997607103
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['n = int(input())\nl = [int(x) for x in input().split()]\n\norder = 0\nsubs = []\ntmp = []\n\nprev = 0\nd = []\nt = [l[0]]\nfor x in range(len(l)-1):\n a,b = l[x],l[x+1]\n c = a-b\n print(a,b,c, prev)\n if c == 0:\n t.append(b)\n elif prev == 0:\n t.append(b)\n prev = c\n elif (c < 0 and prev < 0) or (c > 0 and prev > 0):\n t.append(b)\n else:\n prev = 0\n d.append(t)\n t = [b]\nd.append(t)\n\nprint(len(d))\n', 'n = int(input())\nl = [int(x) for x in input().split()]\n\norder = 0\nsubs = []\ntmp = []\n\nprev = 0\nd = []\nt = [l[0]]\nfor x in range(len(l)-1):\n a,b = l[x],l[x+1]\n c = a-b\n print(a,b,c, prev)\n if c == 0:\n t.append(b)\n elif prev == 0:\n t.append(b)\n prev = c\n elif (c < 0 and prev < 0) or (c > 0 and prev > 0):\n t.append(b)\n else:\n prev = 0\n d.append(t)\n t = [b]\nd.append(t)\n', 'n = int(input())\nl = [int(x) for x in input().split()]\n\norder = 0\nsubs = []\ntmp = []\n\nprev = 0\nd = []\nt = [l[0]]\nfor x in range(len(l)-1):\n a,b = l[x],l[x+1]\n c = a-b\n # print(a,b,c, prev)\n if c == 0:\n t.append(b)\n elif prev == 0:\n t.append(b)\n prev = c\n elif (c < 0 and prev < 0) or (c > 0 and prev > 0):\n t.append(b)\n else:\n prev = 0\n d.append(t)\n t = [b]\nd.append(t)\n\nprint(len(d))\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s055359932', 's067760963', 's511678138']
[15732.0, 15664.0, 14428.0]
[368.0, 350.0, 121.0]
[412, 397, 414]
p03745
u999503965
2,000
262,144
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into?
['n=int(input())\nl=list(map(int,input().split()))\n\nif n=<2:\n print(1)\n exit()\n \ncnt=0\n\nif l[0]>l[1]:\n ans="low"\nelif l[0]<l[1]:\n ans="high"\nelse:\n ans="even"\n \nfor i in range(2,n):\n if l[i-1]>l[i] and (ans=="low" or ans=="even"):\n ans="low"\n elif l[i-1]<l[i] and (ans=="high" or ans=="even"):\n ans="high"\n elif l[i-1]==l[i]:\n continue\n else:\n cnt+=1\n ans="even"\n \nprint(cnt+1)\n', 'n=int(input())\nl=list(map(int,input().split()))\n\nif n<=2:\n print(1)\n exit()\n \ncnt=0\n\nif l[0]>l[1]:\n ans="low"\nelif l[0]<l[1]:\n ans="high"\nelse:\n ans="even"\n \nfor i in range(2,n):\n if l[i-1]>l[i] and (ans=="low" or ans=="even"):\n ans="low"\n elif l[i-1]<l[i] and (ans=="high" or ans=="even"):\n ans="high"\n elif l[i-1]==l[i]:\n continue\n else:\n cnt+=1\n ans="even"\n \nprint(cnt+1)\n']
['Runtime Error', 'Accepted']
['s228631361', 's821938583']
[9008.0, 20164.0]
[26.0, 84.0]
[404, 404]
p03747
u054556734
2,000
262,144
There is a circle with a circumference of L. Each point on the circumference has a coordinate value, which represents the arc length from a certain reference point clockwise to the point. On this circumference, there are N ants. These ants are numbered 1 through N in order of increasing coordinate, and ant i is at coordinate X_i. The N ants have just started walking. For each ant i, you are given the initial direction W_i. Ant i is initially walking clockwise if W_i is 1; counterclockwise if W_i is 2. Every ant walks at a constant speed of 1 per second. Sometimes, two ants bump into each other. Each of these two ants will then turn around and start walking in the opposite direction. For each ant, find its position after T seconds.
['\n\n\n\nn,l,t=map(int,input().split())\nx=[0 for i in range(n+1)]\nw=[0 for i in range(n+1)]\nans=[]\n\nfor i in range(1,n+1):\n x[i],w[i]=map(int,input().split())\n if w[i]==1: a=(x[i]+t)%l\n else: a=(x[i]-t+l)%l\n ans.append(a)\n\n\ncrash=0\nfor i in range(2,n+1):\n if w[i] != w[1]:\n if w[1] == 1:\n crash += (t-((x[i]-x[1])/2)) // (l/2) + 1\n else:\n crash += (t-(l-(x[i]-x[1]))/2) // (l/2) + 1\n\n\nans.sort()\ncrash = int(crash)\nfor i in range(n):\n i = (i-crash)%n\n print(ans[i])\nprint(ans,crash)\n\n', '\n\n\n\nn,l,t=map(int,input().split())\nx=[0 for i in range(n+1)]\nw=[0 for i in range(n+1)]\nans=[]\u3000\nw1=[]\u3000\nw2=[]\u3000\n\nfor i in range(1,n+1):\n x[i],w[i]=map(int,input().split())\n if w[i]==1: a=(x[i]+t)%l; w1.append(x[i])\n if w[i]==2: a=(x[i]-t+l)%l; w2.append(x[i])\n ans.append(a)\n\n\nk=0\nfor i in range(n):\n if w[i]==1:\u3000\n if (x[i]+2*t)>=l:\n for j in range(x[i],x[i]+2*t+1): k+=w2.count(j)\n for j in range((x[i]+2*t+1)%l,x[i]): k+=w2.count(j)\n else:\n for j in range(x[i],x[i]+2*t+1): k+=w2.count(j)\n break\u3000\n\n\nans.sort()\nfor i in range(n): print(ans[(i+k)%n])\n\n', '\n\n\n\nn,l,t=map(int,input().split())\nx=[]\nw=[]\nans=[]\n\ncrash=0\nfor i in range(n):\n xx,ww=map(int,input().split())\n x.append(xx); w.append(ww)\n if w[i]==1: anss=(x[i]+t)%l\n else: anss=(x[i]-t+l)%l\n ans.append(anss)\n if i!=0 and w[i] != w[0]:\n if w[0] == 1: crash += (t-((x[i]-x[0])/2)) // (l/2) + 1\n else: crash += (t-(l-(x[i]-x[0]))/2) // (l/2) + 1\n\n\nif w[0]==1: num0 =int(crash)%n\nelse: num0 =int(-crash)%n\n\nnowplace = ans[0]\nans.sort()\nnum = ans.index(nowplace)\nif w[0]==1 and ans.count(nowplace)==2: num += 1 \n\ngap = num0-num\nfor i in range(n):\n i = (i+gap)%n\n print(ans[i])\nprint(ans)\n\n', '\n\n\n\nn,l,t=map(int,input().split())\nx=[]\nw=[]\nans=[]\n\ncrash=0\nfor i in range(n):\n xx,ww=map(int,input().split())\n x.append(xx); w.append(ww)\n if w[i]==1: anss=(x[i]+t)%l\n else: anss=(x[i]-t+l)%l\n ans.append(anss)\n if i!=0 and w[i] != w[0]:\n if w[0] == 1: crash += (t-((x[i]-x[0])/2)) // (l/2) + 1\n else: crash += (t-(l-(x[i]-x[0]))/2) // (l/2) + 1\n\n\nif w[0]==1: num0 =int(crash)%n\nelse: num0 =int(-crash)%n\n\nnowplace = ans[0]\nans.sort()\nnum = ans.index(nowplace)\nif w[0]==1 and ans.count(nowplace)==2: num += 1 \n\ngap = num0-num\nfor i in range(n):\n i = (i-gap)%n\n print(ans[i])\nprint(ans)\n\n', 'n,l,t=map(int,input().split())\nx=[]\nw=[]\nans=[]\ncrash=0\nfor i in range(n):\n xx,ww=map(int,input().split())\n x.append(xx); w.append(ww)\n if w[i]==1: anss=(x[i]+t)%l\n else: anss=(x[i]-t+l)%l\n ans.append(anss)\n if i!=0 and w[i] != w[0]:\n if w[0] == 1: crash += (t-((x[i]-x[0])/2)) // (l/2) + 1\n else: crash += (t-(l-(x[i]-x[0]))/2) // (l/2) + 1\n\nif w[0]==1: num0 =int(crash)%n\nelse: num0 =int(-crash)%n\nnowplace = ans[0]\nans.sort()\nnum = ans.index(nowplace)\nif w[0]==1 and ans.count(nowplace)==2: num += 1\ngap = num-num0\nfor i in range(n):\n i = (i+gap)%n\n print(ans[i])']
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s225070966', 's376205139', 's512889040', 's965046347', 's977935243']
[16160.0, 2940.0, 15980.0, 15980.0, 12912.0]
[516.0, 17.0, 569.0, 557.0, 561.0]
[845, 1176, 1045, 1045, 604]
p03747
u095021077
2,000
262,144
There is a circle with a circumference of L. Each point on the circumference has a coordinate value, which represents the arc length from a certain reference point clockwise to the point. On this circumference, there are N ants. These ants are numbered 1 through N in order of increasing coordinate, and ant i is at coordinate X_i. The N ants have just started walking. For each ant i, you are given the initial direction W_i. Ant i is initially walking clockwise if W_i is 1; counterclockwise if W_i is 2. Every ant walks at a constant speed of 1 per second. Sometimes, two ants bump into each other. Each of these two ants will then turn around and start walking in the opposite direction. For each ant, find its position after T seconds.
["N, L, T=map(int, input().split())\nXW=[list(map(int, input().split())) for _ in range(N)]\nX_=[(XW[i][0]+T)%L if XW[i][1]==1 else (XW[i][0]-T)%L for i in range(N)]\nX_.sort()\nA0_=(XW[0][0]+T)%L if XW[0][1]==1 else (XW[0][0]-T)%L\nP0_=X_.index(A0_)\nif P0_>0:\n X_=X_[P0_:]+X_[:P0_]\n \nif XW[0][1]==1:\n C0_=round(sum([(T-(XW[i][0]-XW[0][0])/2)//(L/2)+1 if XW[i][1]!=1 and (XW[i][0]-XW[0][0])/2<=T else 0 for i in range(1, N)])%N)\nelse:\n C0_=round(N-sum([(T-(XW[0][0]+L-XW[i][0])/2)//(L/2)+1 if XW[i][1]!=2 and (XW[0][0]+L-XW[i][0])/2<=T else 0 for i in range(1, N)])%N)\n \nif X_[0]==X_[1] and XW[0][1]==1:\n C0_=round((C0_-1)%N)\n'''\nif C0_>0:\n X_=X_[N-C0_:]+X_[:N-C0_]\n'''\nprint(*X_, sep='\\n')", "N, L, T=map(int, input().split())\nXW=[list(map(int, input().split())) for _ in range(N)]\nX_=[(XW[i][0]+T)%L if XW[i][1]==1 else (XW[i][0]-T)%L for i in range(N)]\nX_.sort()\nA0_=(XW[0][0]+T)%L if XW[0][1]==1 else (XW[0][0]-T)%L\nP0_=X_.index(A0_)\nif P0_>0:\n X_=X_[P0_:]+X_[:P0_]\n \nif XW[0][1]==1:\n C0_=round(sum([(T-(XW[i][0]-XW[0][0])/2)//(L/2)+1 if XW[i][1]!=1 and (XW[i][0]-XW[0][0])/2<=T else 0 for i in range(1, N)])%N)\nelse:\n C0_=round(N-sum([(T-(XW[0][0]+L-XW[i][0])/2)//(L/2)+1 if XW[i][1]!=2 and (XW[0][0]+L-XW[i][0])/2<=T else 0 for i in range(1, N)])%N)\n \nif N>1 and X_[0]==X_[1] and XW[0][1]==1:\n C0_=round((C0_-1)%N)\n\nif C0_>0:\n X_=X_[N-C0_:]+X_[:N-C0_]\n\nprint(*X_, sep='\\n')"]
['Runtime Error', 'Accepted']
['s511303391', 's563055444']
[31052.0, 31664.0]
[462.0, 454.0]
[700, 702]
p03747
u099643902
2,000
262,144
There is a circle with a circumference of L. Each point on the circumference has a coordinate value, which represents the arc length from a certain reference point clockwise to the point. On this circumference, there are N ants. These ants are numbered 1 through N in order of increasing coordinate, and ant i is at coordinate X_i. The N ants have just started walking. For each ant i, you are given the initial direction W_i. Ant i is initially walking clockwise if W_i is 1; counterclockwise if W_i is 2. Every ant walks at a constant speed of 1 per second. Sometimes, two ants bump into each other. Each of these two ants will then turn around and start walking in the opposite direction. For each ant, find its position after T seconds.
['N, L, T = map(int, input().split())\nX = [0 for i in range(N)]\nW = [0 for i in range(N)]\nE = [0 for i in range(N)]\ncount = 0\nfor i in range(N):\n X[i], W[i] = map(int, input().split())\n if W[i] == 1:\n end = X[i] + T\n end = end % L\n if W[i] == 2:\n end = X[i]-T\n end = end % L\n if end < 0:\n end += L\n E[i] = end\n shu = L / 2.0\n if i > 0 and W[i] == 2 and W[0] == 1:\n sa = X[i] -X[0]\n if sa < 0:\n sa += L\n gikan = sa / 2.0\n count += (T - gikan ) // shu + 1\n\n if i > 0 and W[i] == 1 and W[0] == 2:\n sa = X[0] -X[i]\n if sa < 0:\n sa += L\n gikan = sa / 2.0\n count -= (T - gikan ) // shu + 1\n\nprint(E)\ncount = count % N\nif count < 0:\n count += N\ncount = int(count)\nprint(count)\nbasho = E[0]\nE.sort()\nind = E.index(basho)\nresult = [0 for i in range(N)]\nfor i in range(N):\n newind = ind + i\n if newind >= N :\n newind -= N\n result[count] = E[newind]\n count += 1\n if count >= N:\n count -= N\n\nfor i in range(N):\n print(result[i])', 'N, L, T = map(int, input().split())\nX = [0 for i in range(N)]\nW = [0 for i in range(N)]\nE = [0 for i in range(N)]\ncount = 0\nfor i in range(N):\n X[i], W[i] = map(int, input().split())\n if W[i] == 1:\n end = X[i] + T\n end = end % L\n if W[i] == 2:\n end = X[i]-T\n end = end % L\n if end < 0:\n end += L\n E[i] = end\n shu = L / 2.0\n if i > 0 and W[i] == 2 and W[0] == 1:\n sa = X[i] -X[0]\n if sa < 0:\n sa += L\n gikan = sa / 2.0\n count += (T - gikan ) // shu + 1\n if (T - gikan) % shu == 0:\n count -= 1\n\n if i > 0 and W[i] == 1 and W[0] == 2:\n sa = X[0] -X[i]\n if sa < 0:\n sa += L\n gikan = sa / 2.0\n count -= (T - gikan ) // shu + 1\n\n#print(E)\ncount = count % N\nif count < 0:\n count += N\ncount = int(count)\n#print(count)\nbasho = E[0]\nE.sort()\nind = E.index(basho)\nresult = [0 for i in range(N)]\nfor i in range(N):\n newind = ind + i\n if newind >= N :\n newind -= N\n result[count] = E[newind]\n count += 1\n if count >= N:\n count -= N\n\nfor i in range(N):\n print(result[i])\n']
['Wrong Answer', 'Accepted']
['s465367224', 's102106514']
[15044.0, 13864.0]
[630.0, 648.0]
[1096, 1157]
p03747
u104282757
2,000
262,144
There is a circle with a circumference of L. Each point on the circumference has a coordinate value, which represents the arc length from a certain reference point clockwise to the point. On this circumference, there are N ants. These ants are numbered 1 through N in order of increasing coordinate, and ant i is at coordinate X_i. The N ants have just started walking. For each ant i, you are given the initial direction W_i. Ant i is initially walking clockwise if W_i is 1; counterclockwise if W_i is 2. Every ant walks at a constant speed of 1 per second. Sometimes, two ants bump into each other. Each of these two ants will then turn around and start walking in the opposite direction. For each ant, find its position after T seconds.
['# C\nimport numpy as np\nN, L, T = map(int, input().split())\nX = list()\nW = list()\npositions = list()\nfor _ in range(N):\n x, w = map(int, input().split())\n X.append(x)\n W.append(w)\n if w == 1:\n positions.append((x + T) % L)\n else:\n positions.append((x - T) % L)\n\n# find which is the position\ncnt_conf = 0\nfor i in range(N):\n if W[i] != W[0]:\n cnt_conf += (2*T - (X[i] - X[0])) // L + 1\nn0 = cnt_conf % N\nif W[0] == 1:\n p0 = (X[0] + T) % L\nelse:\n p0 = (X[0] - T) % L\n\npositions.sort()\n\n# find index\nif W[0] == 1:\n num = np.argmax(np.arange(N)[positions==p0])\nelse:\n num = np.argmin(np.arange(N)[positions==p0])\nfor i in range(N):\n print(positions[(num - n0 + i) % N])', '# C\nimport numpy as np\nN, L, T = map(int, input().split())\nX = list()\nW = list()\npositions = list()\nfor _ in range(N):\n x, w = map(int, input().split())\n X.append(x)\n W.append(w)\n if w == 1:\n positions.append((x + T) % L)\n else:\n positions.append((x - T) % L)\n\n# find which is the position\ncnt_conf = 0\nfor i in range(N):\n if W[i] != W[0]:\n cnt_conf += (2*T - (X[i] - X[0])) // L + 1\nn0 = cnt_conf % N\nif W[0] == 1:\n p0 = (X[0] + T) % L\nelse:\n p0 = (X[0] - T) % L\n\npositions.sort()\n\n# find index\nif W[0] == 1:\n num = np.argmax(np.arange(N)[positions==p0])\nelse:\n num = np.argmin(np.arange(N)[positions==p0])\nfor i in range(N):\n print(positions[(num - n0 + i) % N])', '# C\nN, L, T = map(int, input().split())\nX = list()\nW = list()\npositions = list()\nfor _ in range(N):\n x, w = map(int, input().split())\n X.append(x)\n W.append(w)\n if w == 1:\n positions.append((x + T) % L)\n else:\n positions.append((x - T) % L)\n\n# find which is the position\ncnt_conf = 0\nif W[0] == 1:\n for i in range(N):\n if W[i] != W[0]:\n cnt_conf += (2*T - (X[i] - X[0])) // L + 1\n n0 = cnt_conf % N\n p0 = (X[0] + T) % L\nelse:\n for i in range(N):\n if W[i] != W[0]:\n cnt_conf += (2*T - (X[0] + L - X[i])) // L + 1\n n0 = -cnt_conf % N\n p0 = (X[0] - T) % L\n\npositions.sort()\n\n# find index\nif W[0] == 1:\n num = max([n for n in range(N) if positions[n]==p0])\nelse:\n num = min([n for n in range(N) if positions[n]==p0])\n\nfor i in range(N):\n print(positions[(num - n0 + i) % N])']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s372319767', 's760707802', 's136403361']
[22452.0, 21872.0, 12860.0]
[917.0, 906.0, 470.0]
[718, 718, 862]