当前位置:网站首页>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;
}边栏推荐
- 解决Chrome浏览器和Edeg浏览器主页被篡改的方法
- Using rendertext() to output multiple lines of text with rendertext() in R shiny
- Film and television excerpts
- 性能优化----严苛模式
- I admire that someone explained such an obscure subject as advanced mathematics so easily
- [autosar-dcm] - 4.3-how UDS $22 and $2e services read and write NVM data
- wait解决僵尸进程
- Golang面试整理 三 简历如何书写
- 用sentinel熔断比例阈值改不了,设置慢调用比例没效果
- 存储单位换算
猜你喜欢

数组进阶提高
![[羊城杯2020]easyphp](/img/12/da28f738e50e625b0a66a94af3703d.png)
[羊城杯2020]easyphp

mysql重置密码,忘记密码,重置root密码,重置mysql密码

【外刊】睡眠与减肥
![[chestnut sugar GIS] ArcMap - how to batch modify the font, color, size, etc. of annotation elements](/img/b1/1fae909fb6a9231096a93d741d6426.png)
[chestnut sugar GIS] ArcMap - how to batch modify the font, color, size, etc. of annotation elements

分享 10 个 JS 闭包面试题(图解),进来看看你能答对多少

Performance optimization - rigorous mode

Local dealers play the community group purchase mode and share millions of operations

Uniapp wechat login returns user name and Avatar

牛客网:龙与地下城游戏
随机推荐
QT qsplitter splitter
[羊城杯2020]easyphp
Webrtc audio and video capture and playback examples and mediastream media stream analysis
Local dealers play the community group purchase mode and share millions of operations
Developers share | HLS and skillfully use Axi_ Customize the master bus interface instructions and improve the data bandwidth - area exchange speed
杰理之快速触摸不响应问题【篇】
牛客网:龙与地下城游戏
存储单位换算
wait解决僵尸进程
LeetCode 968. 监控二叉树
go 4種單例模式
JS syntax ES6, ES7, es8, es9, ES10, es11, ES12 new features (Abstract)
傑理之修改不需要長按開機功能【篇】
杰理之、产线装配环节【篇】
[micro service sentinel] rewrite Sentinel's interface blockexceptionhandler
杰理之内置关机电流 1.2uA,之后不能长按开机【篇】
解决 excel 文件上传时更改选中的文件出现错误net::ERR_UPLOAD_FILE_CHANGED
分享 10 个 JS 闭包面试题(图解),进来看看你能答对多少
悬镜安全在RSAC2022上斩获Global InfoSec Awards四项大奖
Comprehensively analyze the logic of the shared purchase business model? How sharing purchase empowers Enterprises