@[huang66](/user/1111593) markdown挂了,请阅读[markdown规范](https://help.luogu.com.cn/rules/academic/handbook/markdown)。
by NFGase @ 2023-12-06 09:46:21
```python
L = int(input())
N = int(input())
pos = list(map(int, input().split()))
#统计每个坐标出现的次数
count = [0] * (L + 2)
for p in pos:
count[p] += 1
#统计每个士兵的方向
direction = [0] * N
for i in range(N):
if pos[i] == 1:
direction[i] = 1
elif pos[i] == L:
direction[i] = -1
else:
direction[i] = 0
#统计每个士兵的最远距离
max_distance = [0] * N
for i in range(N):
if direction[i] == 1:
max_distance[i] = L - pos[i]
elif direction[i] == -1:
max_distance[i] = pos[i] - 1
else:
max_distance[i] = 0
#统计最小时间和最大时间
min_time = 0
max_time = 0
for i in range(N):
if direction[i] == 1:
min_time += max_distance[i]
max_time += max_distance[i]
elif direction[i] == -1:
min_time += max_distance[i]
max_time += max_distance[i]
else: min_time += max_distance[i] - 1
max_time += max_distance[i] + 1
print(min_time, max_time)
#为pycharm运行的结果符合题目给出的输入输出样例,但是洛谷上会给0分
```
我来做个好心人。
by xiaoshumiao @ 2023-12-06 10:08:29
@[xiaoshumiao](/user/1008513)
是错的呀,语法错误了都
by huang66 @ 2023-12-06 10:24:36
@[huang66](/user/1111593) 你会markdown吗?人家是在帮你修markdown
by _O_v_O_ @ 2023-12-06 10:27:41
@[huang66](/user/1111593) 抱歉,我是 C++ 党(doge
by xiaoshumiao @ 2023-12-06 10:27:59
@[_O_v_O_](/user/782941)
我不是很清楚,在百度上说是一种轻量标记语言,这个东西应该不影响代码运行的吧。
(别喷我)
by huang66 @ 2023-12-06 10:49:37