当前位置:网站首页>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;
}
边栏推荐
- 杰理之快速触摸不响应问题【篇】
- How can I use knockout's $parent/$root pseudovariables from inside a . computed() observable?
- 位的高阶运算
- Rails 3 activerecord: sort by association count - rails 3 activerecord: order by count on Association
- 大话云原生之负载均衡篇-小饭馆客流量变大了
- Server response status code
- Pointer - function pointer
- Golang面试整理 三 简历如何书写
- SimpleITK使用——4. 奇怪的问题
- 【ODX Studio编辑PDX】-0.1-如何快速查看各Variant变体间的支持的诊断信息差异(服务,Sub-Function...)
猜你喜欢
加油站[问题分析->问题转换->贪心]
Task and privilege level protection
PMP项目整合管理
Simpleitk use - 3 Common operations
#include errors detected. Please update your includePath.
数组进阶提高
基于ASP.net的手机销售管理系统(二手手机销售管理系统)+ASP.NET+C#语言+VS2010+数据库可以用于课设、毕设学习
E-commerce system microservice architecture
Oracle cursor
Jatpack------LiveData
随机推荐
NC24325 [USACO 2012 Mar S]Flowerpot
开发者分享 | HLS, 巧用AXI_master总线接口指令的定制并提升数据带宽-面积换速度...
Oracle cursor
U++ 学习笔记 ----松弛
Market Research - current situation and future development trend of sickle cell therapy Market
Market Research - current market situation and future development trend of high tibial osteotomy plate
Source code analysis - lightweight asynchronous crawler framework Ruia
What is the'function'keyword used in some bash scripts- What is the 'function' keyword used in some bash scripts?
Market Research - current situation and future development trend of herringbone gear Market
分享 10 个 JS 闭包面试题(图解),进来看看你能答对多少
数组进阶提高
[shutter] shutter application theme (themedata | dynamic modification theme)
PHP微信抢红包的算法
【AUTOSAR-DCM】-4.3-UDS $22和$2E服务如何读取和写入NVM数据
数学建模——图与网络模型及方法(一)
建立自己的网站(22)
JS solution for obtaining the width and height of hidden elements whose display is none
Jerry's modification does not require long press the boot function [chapter]
Introduction to database system Chapter 1 short answer questions - how was the final exam?
php优化foreach中的sql查询