codeforces-367#A. Beru-taxi
来源:互联网 发布:淘宝卖阿迪达斯的c店 编辑:程序博客网 时间:2024/06/08 00:14
题意:
给出初始点,以及车辆位置N个点和各个车的速度,问时间最短到达的是多久
#include <iostream>#include <stdio.h>#include <stack>using namespace std;int a[1005];int l[1005];int r[1005];int main(){ stack <int> s; int n; cin>>n; while(!s.empty()) s.pop(); int i; for(i=1;i<=n;i++) scanf("%d",&a[i]); for(i=1;i<=n;i++) { while(s.size()>0&&a[s.top()]>=a[i]) s.pop(); if(s.size()==0) l[i]=1; else l[i]=s.top()+1; s.push(i); } //cout<<"x"<<endl; while( ! s.empty())s.pop(); for(i=n;i>=1;i--) { while(s.size()>0&&a[s.top()]>=a[i]) s.pop(); if(s.size()==0) r[i]=n; else r[i]=s.top()-1; s.push(i); } //cout<<"x"<<endl; int tmp,ans=0; for(i=1;i<=n;i++) { int tmp=(r[i]-l[i]+1)*a[i]; if(tmp>ans) ans=tmp;; } printf("%d\n",ans); return 0;}
0 0
- codeforces-367#A. Beru-taxi
- CodeForces 706A Beru-taxi
- 【codeforces 706A Beru-taxi】
- CodeForces-706A.Beru-taxi
- codeforces 706A Beru-taxi
- 【Codeforces Round 367 (Div 2) A】【水题】Beru-taxi
- Codeforces Round #367 (Div. 2) A. Beru-taxi
- Codeforces Round #367 (Div. 2) A. Beru-taxi(很水)
- codeforces 706A A. Beru-taxi
- 【模拟】Codeforces 706A Beru-taxi
- CodeForces 706A Beru-taxi 【水题】
- A. Beru-taxi
- codeforces706A之Beru-taxi
- Codeforces Round #367 (Div. 2)ABeru-taxi
- CodeForces 158B taxi
- 【codeforces】B. Taxi
- CodeForces 158B Taxi
- codeforces 158B Taxi
- PyQT4图形界面开发入门实例
- 欢迎使用CSDN-markdown编辑器
- Java代码性能优化总结
- android ScrollView控件使用
- 【poj 2264】 Advanced Fruits
- codeforces-367#A. Beru-taxi
- BZOJ2809 [Apio2012]dispatching 解题报告
- Android中MVP模式的简单实现
- 高校云平台(七):选课中应用Redis一些思考
- 没人能想象到安装Android studio我花了多长时间~~~·今天我将遇到的问题写下来
- 百度地图植入教程(1)-基础地图
- Python正则表达式
- android在调用js中的alert无效
- Java开发必会的Linux命令