思路:按照题意,用双指针进行模拟即可
代码:
import sys
input = lambda: sys.stdin.readline().strip()
import math
inf = 10 ** 18
def I():
return input()
def II():
return int(input())
def MII():
return map(int, input().split())
def GMI():
return map(lambda x: int(x) - 1, input().split())
def LI():
return input().split()
def LII():
return list(map(int, input().split()))
def LFI():
return list(map(float, input().split()))
fmax = lambda x, y: x if x > y else y
fmin = lambda x, y: x if x < y else y
isqrt = lambda x: int(math.sqrt(x))
'''
0 1 3 4
0 6 # 初始状态
0 4 # 交换
1 4 # 前指针移动
1 3 # 交换
2 3 # 前指针移动
tmp[k] < i,无法交换,后指针只能不动
3 3 # 前指针移动
4 3 # 前指针移动,i > j结束
'''
def solve():
n = II()
a = LII()
c = II()
tmp = []
for i, x in enumerate(a):
if x > c:
tmp.append(i)
ans = 0
i, j = 0, n
k = len(tmp) - 1
while i <= j:
if k >= 0 and i <= tmp[k]:
j = tmp[k]
k -= 1
i += 1
ans += 1
print(ans)
t = 1
# t = II()
for _ in range(t):
solve()

京公网安备 11010502036488号