当前位置:网站首页>P1007 single log bridge
P1007 single log bridge
2022-07-02 22:55:00 【Evil_ boy__】
Topic link :
P1007 Single-plank bridge - Luogu | New ecology of computer science education (luogu.com.cn)
Topic :
Title Description :
Input description :

Output description :

Examples and explanations : 
Ideas :
The minimum time is the maximum of the minimum value of each person to both ends
The collision problem needs to be considered in the maximum time , But the collision problem is considered on the basis of different people , The position of two people colliding and penetrating the past two points is the same , So it's equivalent to the maximum value of the maximum value of everyone at both ends
#include<bits/stdc++.h>
using namespace std;
int arr[5005];
int main(){
int n;
cin >> n;
int m;
cin >> m;
int maxn = 0;
int minn = 0;
for(int i = 0; i < m; i++){
cin >> arr[i];
maxn = max(maxn, min(arr[i], n + 1 - arr[i]));
minn = max(minn, max(arr[i], n + 1 - arr[i]));
}
cout << maxn << " " << minn << endl;;
return 0;
}边栏推荐
- Zhong Xuegao responded that the product will not melt for 1 hour: it contains solid components and cannot melt into water
- 大话云原生之负载均衡篇-小饭馆客流量变大了
- MySQL reset password, forget password, reset root password, reset MySQL password
- NC50965 Largest Rectangle in a Histogram
- 牛客网:最大子矩阵
- 手写ORM(对象关系映射)增删改查
- [LeetCode] 反转字符串【344】
- MySQL查询附近的数据.并按距离进行排序.
- Wait to solve the zombie process
- 佩服,竟然有人把高等数学这么晦涩难懂的科目,讲解得如此通俗易懂
猜你喜欢

wait解决僵尸进程

Oracle-PL/SQL编程
![[leetcode] reverse the word III in the string [557]](/img/72/d3e46a820796a48b458cd2d0a18f8f.png)
[leetcode] reverse the word III in the string [557]

悬镜安全在RSAC2022上斩获Global InfoSec Awards四项大奖

首批 | 腾讯云完成国内首个云原生安全成熟度评估

地方经销商玩转社区团购模式,百万运营分享
![NC24325 [USACO 2012 Mar S]Flowerpot](/img/cf/86acbcb524b3af0999ce887c877781.png)
NC24325 [USACO 2012 Mar S]Flowerpot

Dahua cloud native load balancing article - the passenger flow of small restaurants has increased

大话云原生之负载均衡篇-小饭馆客流量变大了

【硬件】标准阻值的由来
随机推荐
【板栗糖GIS】arcmap—如何批量修改注记要素的字体,颜色,大小等
P7072 [CSP-J2020] 直播获奖
uniapp微信登录返显用户名和头像
[leetcode] number of palindromes [9]
【板栗糖GIS】arcscene—如何做出有高度的高程图
Array advanced improvement
To myself who is about to work
pytorch训练CPU占用持续增长(bug)
悬镜安全在RSAC2022上斩获Global InfoSec Awards四项大奖
NC24325 [USACO 2012 Mar S]Flowerpot
easyclick,ec权朗网络验证源码
Jerry's modification does not require long press the boot function [chapter]
`${}`的用法
Jerry's charge unplugged, unable to touch the boot [chapter]
Hanging mirror security won four global infosec awards on rsac2022
存储单位换算
PMP项目整合管理
对象与对象变量
Developers share | HLS and skillfully use Axi_ Customize the master bus interface instructions and improve the data bandwidth - area exchange speed
mysql重置密码,忘记密码,重置root密码,重置mysql密码