当前位置:网站首页>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;
}边栏推荐
- Introduction to database system Chapter 1 short answer questions - how was the final exam?
- Market Research - current market situation and future development trend of high tibial osteotomy plate
- Objects and object variables
- Market Research - current situation and future development trend of marine clutch Market
- [LeetCode] 存在重复元素【217】
- DTM distributed transaction manager PHP collaboration client V0.1 beta release!!!
- JS syntax ES6, ES7, es8, es9, ES10, es11, ES12 new features (Abstract)
- 对象与对象变量
- U++ 原始内存 学习笔记
- U++ 学习笔记 堆
猜你喜欢

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

Build your own website (22)

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

Utilisation de simpletk - 4. Question étrange

Based on asp Net (used mobile phone sales management system) +asp Net+c # language +vs2010+ database can be used for course design and post design learning

Oracle cursor

性能优化----严苛模式

`${}`的用法

小鹏P7出事故,安全气囊未弹出,这正常吗?

Socket套接字C/S端流程
随机推荐
Phpcms realizes the direct Alipay payment function of orders
SimpleITK使用——3. 常见操作
Zhong Xuegao responded that the product will not melt for 1 hour: it contains solid components and cannot melt into water
悬镜安全在RSAC2022上斩获Global InfoSec Awards四项大奖
php优化foreach中的sql查询
Socket socket c/s end process
UE4 游戏架构 学习笔记
Market Research - current market situation and future development trend of marine wet exhaust hose
Notes on key vocabulary in the English original of the biography of jobs (10) [chapter eight]
佩服,竟然有人把高等数学这么晦涩难懂的科目,讲解得如此通俗易懂
How should programmers write logs
[QT] Q multithreaded development - Analysis of multithreaded application examples (Mandelbrot)
性能优化----严苛模式
《乔布斯传》英文原著重点词汇笔记(九)【 chapter seven】
phpcms实现订单直接支付宝支付功能
[LeetCode] 存在重复元素【217】
Market Research - current market situation and future development trend of night vision goggles for pilots
牛客网:最大子矩阵
php实现根据输入的年龄查询出生日期符合的数据
Market Research - current situation and future development trend of marine clutch Market