当前位置:网站首页>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;
}
边栏推荐
猜你喜欢
Developers share | HLS and skillfully use Axi_ Customize the master bus interface instructions and improve the data bandwidth - area exchange speed
大话云原生之负载均衡篇-小饭馆客流量变大了
Higher order operation of bits
[error record] the flutter reports an error (could not read script 'xxx\flutter\u tools\gradle\app\u plugin\u loader.gradle')
kubernetes 使用主机名将 pod 分配在指定节点上
【板栗糖GIS】global mapper 如何通过dsm批量制作贴地等高线
【板栗糖GIS】arcmap—为什么使用自定义捕捉的时候,经典捕捉的勾要去掉呢?
电商系统微服务架构
boot actuator - prometheus使用
Dahua cloud native load balancing article - the passenger flow of small restaurants has increased
随机推荐
uniapp微信登录返显用户名和头像
E-commerce system microservice architecture
php优化foreach中的sql查询
Xiaopeng P7 had an accident and the airbag did not pop up. Is this normal?
位的高阶运算
To myself who is about to work
PHP optimizes SQL queries in foreach
MySQL查询附近的数据.并按距离进行排序.
P1007 独木桥
大话云原生之负载均衡篇-小饭馆客流量变大了
[LeetCode] 反转字符串中的单词 III【557】
用sentinel熔断比例阈值改不了,设置慢调用比例没效果
加油站[问题分析->问题转换->贪心]
Wait to solve the zombie process
Dahua cloud native load balancing article - the passenger flow of small restaurants has increased
Radis:Linux上安装Redis(步骤)
mysql重置密码,忘记密码,重置root密码,重置mysql密码
对象与对象变量
[LeetCode] 存在重复元素【217】
杰理之内置关机电流 1.2uA,之后不能长按开机【篇】