当前位置:网站首页>P1007 独木桥
P1007 独木桥
2022-07-02 22:07:00 【Evil_boy__】
题目链接:
P1007 独木桥 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)
题面:
题目描述:
输入描述:
输出描述:
样例及解释: 
思路:
最小时间就是每个人到两端的最小值的最大值
最大时间需要考虑相撞问题,但是相撞问题是在不同的人基础上考虑的,两个人相撞和穿透过去的两个点的位置是一样的,所以就相当每个人到两端的最大值的最大值
#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;
}
边栏推荐
- SimpleITK使用——3. 常见操作
- 基于ASP.net的手机销售管理系统(二手手机销售管理系统)+ASP.NET+C#语言+VS2010+数据库可以用于课设、毕设学习
- [LeetCode] 反转字符串【344】
- 《乔布斯传》英文原著重点词汇笔记(十)【 chapter eight】
- 【AUTOSAR-DCM】-4.3-UDS $22和$2E服务如何读取和写入NVM数据
- 杰理之如何测试按键的误触率【篇】
- U++ 学习笔记 堆
- Rails 3 activerecord: sort by association count - rails 3 activerecord: order by count on Association
- [error record] the flutter reports an error (could not read script 'xxx\flutter\u tools\gradle\app\u plugin\u loader.gradle')
- 开发者分享 | HLS, 巧用AXI_master总线接口指令的定制并提升数据带宽-面积换速度...
猜你喜欢
Dynamic memory allocation (malloc calloc realloc free)
建立自己的网站(22)
NC50965 Largest Rectangle in a Histogram
数组进阶提高
[error record] the flutter reports an error (could not read script 'xxx\flutter\u tools\gradle\app\u plugin\u loader.gradle')
Phpcms realizes the direct Alipay payment function of orders
手写ORM(对象关系映射)增删改查
Perceptron model and Application
世界环境日 | 周大福用心服务推动减碳环保
phpcms实现订单直接支付宝支付功能
随机推荐
位的高阶运算
数组进阶提高
Market Research - current market situation and future development trend of genome editing mutation detection kit
杰理之、产线装配环节【篇】
phpcms实现订单直接支付宝支付功能
Socket套接字C/S端流程
Jerry's modification does not require long press the boot function [chapter]
Film and television excerpts
JS solution for obtaining the width and height of hidden elements whose display is none
Socket socket c/s end process
钟薛高回应产品1小时不化:含固体成分 融化不能变成水
【洛谷P1541】乌龟棋【DP】
What is the'function'keyword used in some bash scripts- What is the 'function' keyword used in some bash scripts?
杰理之直接触摸样机的顶针反应不正常【篇】
杰理之内置关机电流 1.2uA,之后不能长按开机【篇】
杰理之如何测试按键的误触率【篇】
PHP implements querying the data matching the date of birth according to the entered age
[QT] Q multithreaded development - Analysis of multithreaded application examples (Mandelbrot)
百度智能云-创建人脸识别应用
go 4種單例模式