当前位置:网站首页>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;
}边栏推荐
- Unity发布WebGL播放声音的一种方法
- Market Research - current market situation and future development trend of aircraft audio control panel system
- Objects and object variables
- 杰理之样机在多次触摸后会触发关机【篇】
- It's not easy to say I love you | use the minimum web API to upload files (swagger support) # yyds dry inventory #
- Market Research - current market situation and future development trend of aircraft wireless intercom system
- 【板栗糖GIS】arcmap—为什么使用自定义捕捉的时候,经典捕捉的勾要去掉呢?
- Rails 3 activerecord: sort by association count - rails 3 activerecord: order by count on Association
- 数组进阶提高
- Market Research - current situation and future development trend of anti-counterfeiting label market
猜你喜欢

uniapp微信登录返显用户名和头像

基于ASP.net的手机销售管理系统(二手手机销售管理系统)+ASP.NET+C#语言+VS2010+数据库可以用于课设、毕设学习

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

kubernetes 使用主机名将 pod 分配在指定节点上

NC50965 Largest Rectangle in a Histogram

牛客网:最大子矩阵

Socket socket c/s end process
![[shutter] shutter custom fonts (download TTF fonts | pubspec.yaml configure font resources | synchronize resources | globally apply fonts | locally apply fonts)](/img/27/8594ba0b49d5008b7469967babed17.jpg)
[shutter] shutter custom fonts (download TTF fonts | pubspec.yaml configure font resources | synchronize resources | globally apply fonts | locally apply fonts)
![[LeetCode] 多数元素【169】](/img/72/d3e46a820796a48b458cd2d0a18f8f.png)
[LeetCode] 多数元素【169】

Source code analysis - lightweight asynchronous crawler framework Ruia
随机推荐
【板栗糖GIS】arcmap—如何批量修改注记要素的字体,颜色,大小等
[LeetCode] 多数元素【169】
对象与对象变量
Get off work on time! Episode 6 of Excel Collection - how to split and count document amounts
Market Research - current situation and future development trend of preclinical medical device testing service market
[ODX studio edit PDX] -0.1- how to quickly view the differences in supported diagnostic information between variant variants (service, sub function...)
Perceptron model and Application
PMP项目整合管理
[LeetCode] 反转字符串中的单词 III【557】
【板栗糖GIS】arcmap—为什么使用自定义捕捉的时候,经典捕捉的勾要去掉呢?
杰理之快速触摸不响应问题【篇】
Utilisation de simpletk - 4. Question étrange
Market Research - current market situation and future development trend of night vision goggles for pilots
《乔布斯传》英文原著重点词汇笔记(九)【 chapter seven】
U++ 原始内存 学习笔记
图形视图框架
百度智能云-创建人脸识别应用
Market Research - current market situation and future development trend of marine wet exhaust hose
杰理之直接触摸样机的顶针反应不正常【篇】
Additional: [login information storage] and [login status verification]; (including: summarizing all the contents of [login information storage] and [login status verification] so far;)