[ABC265B] Explore
Problem Statement
Takahashi is exploring a cave in a video game.
The cave consists of $N$ rooms arranged in a row. The rooms are numbered Room $1,2,\ldots,N$ from the entrance.
Takahashi is initially in Room $1$, and the time limit is $T$.
For each $1 \leq i \leq N-1$, he may consume a time of $A_i$ to move from Room $i$ to Room $(i+1)$. There is no other way to move between rooms.
He cannot make a move that makes the time limit $0$ or less.
There are $M$ bonus rooms in the cave. The $i$-th bonus room is Room $X_i$; when he arrives at the room, the time limit increases by $Y_i$.
Can Takahashi reach Room $N$?
Constraints
- $2 \leq N \leq 10^5$
- $0 \leq M \leq N-2$
- $1 \leq T \leq 10^9$
- $1 \leq A_i \leq 10^9$
- $1 < X_1 < \ldots < X_M < N$
- $1 \leq Y_i \leq 10^9$
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
$N$ $M$ $T$
$A_1$ $A_2$ $\ldots$ $A_{N-1}$
$X_1$ $Y_1$
$X_2$ $Y_2$
$\vdots$
$X_M$ $Y_M$
Output
If Takahashi can reach Room $N$, print Yes
; otherwise, print No
.
Sample Input 1
4 1 10
5 7 5
2 10
Sample Output 1
Yes
- Takahashi is initially in Room $1$, and the time limit is $10$.
- He consumes a time of $5$ to move to Room $2$. Now the time limit is $5$. Then, the time limit increases by $10$; it is now $15$.
- He consumes a time of $7$ to move to Room $3$. Now the time limit is $8$.
- He consumes a time of $5$ to move to Room $4$. Now the time limit is $3$.
Sample Input 2
4 1 10
10 7 5
2 10
Sample Output 2
No
He cannot move from Room $1$ to Room $2$.
到达一个洞穴,减去路程的价格,加上这里增加的价格,判断有没有时候价格小于等于0.
```cpp
#include
using namespace std;
const int N=1e5+5;
int n,m,x[N],y[N],a[N],p[N];
long long t;
int main()
{
scanf("%d%d%lld",&n,&m,&t);
for(int i=2;i<=n;i++)
scanf("%d",a+i);
for(int i=1;i<=m;i++)
scanf("%d%d",x+i,y+i),p[x[i]]+=y[i];
for(int i=1;i<=n;i++)
{
t-=a[i];
if(t<=0)
{
printf("No");
return 0;
}
t+=p[i];
}
printf("Yes");
return 0;
}
```
[ABC265B] Explore的更多相关文章
- Android配置----DDMS 连接真机(己ROOT),用file explore看不到data/data文件夹的解决办法
Android DDMS 连接真机(己ROOT),用file explore看不到data/data文件夹,问题在于data文件夹没有权限,用360手机助手或豌豆荚也是看不见的. 有以下两种解决方法: ...
- android DDMS 连接真机(己ROOT),用file explore看不到data/data文件夹的解决办法
android DDMS 连接真机(己ROOT),用file explore看不到data/data文件夹的解决办法 问题是没有权限,用360手机助手或豌豆荚也是看不见的. 简单的办法是用RE文件管理 ...
- HDU 5476 Explore Track of Point 数学平几
Explore Track of Point Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem ...
- Ambari REST API 使用介绍 - How To: Use Swagger with Ambari (Explore Ambari REST)
How To: Use Swagger with Ambari (Explore Ambari REST) Article Note : This feature is available from ...
- Android studio3.0打开Device File Explore(文件管理器)的方法(图文教程)
Android studio3.0打开Device File Explore(文件管理器)的方法(图文教程) 看到网上AS3.0新增加的查看手机文件的新功能,全部都是转载的,没有几个人心细的把如何打开 ...
- Process Explore & Windbg
遇到点内存泄漏.句柄泄漏,应该是家常便饭了.这次就是,程序运行内存一点点增加,句柄也是只增不减,个数竟然可以达到几十万,真是瞪大了我的双眼. 借此机会,学习下相关工具~ Process Explore ...
- explore your hadoop data and get real-time results
deep api integration makes getting value from your big data easy 深度api集成使你大数据訪问更加easy Elasticsearch ...
- eclipse插件-easy explore
最近找到一个Eclipse的插件,名字是Easy Explore,是Easy Structs 其 中的一个部分.主要的功能就是在Eclipse里面视图的部分如果看到自己的工程,或者Package,包什 ...
- eclipse中package explore和project explore 怎么相互切换???
window--->show view--->other---->Java---->Package Explorer或者选project explore之后就可以相互切换了
- gitbook.explore更新升级了, 不能再搜索了
www.gitbook.com/explore 不再是一个索引页面 Can I browse existing projects on GitBook ? The new version of Git ...
随机推荐
- 三维模型OBJ格式轻量化压缩变形现象分析
三维模型OBJ格式轻量化压缩变形现象分析 三维模型的OBJ格式轻量化压缩是一种常见的处理方法,它可以减小模型文件的体积,提高加载和渲染效率.然而,在进行轻量化压缩过程中,有时会出现模型变形的现象,即压 ...
- ABP Framework 7.4 RC 新增功能简介:增强微服务架构支持
ABP Framework 版本号:7.4.0-rc.1 发布时间:2023.8.16 阅读原文:ABP.IO Platform 7.4 RC Has Been Published 翻译:iEricL ...
- JOIN 关联表中 ON、WHERE 后面跟条件的区别
SQL中join连接查询时条件放在on后与where后的区别 数据库在通过连接两张或多张表来返回记录时,都会生成一张中间的临时表,然后再将这张临时表返回给用户. 在使用left jion时,on和wh ...
- Solution -「洛谷 P5176」公约数
Description Link. 求 \[\sum_{i=1}^n\sum_{j=1}^m\sum_{k=1}^p\gcd(i\cdot j,i\cdot k,j\cdot k)\times \gc ...
- Ds100p -「数据结构百题」31~40
31.P2163 [SHOI2007]园丁的烦恼] 很久很久以前,在遥远的大陆上有一个美丽的国家.统治着这个美丽国家的国王是一个园艺爱好者,在他的皇家花园里种植着各种奇花异草. 有一天国王漫步在花园里 ...
- IPv6的基本认识
IPv6 1.IPv6的基本认识 IPv4 位数是 32位,4字节,能够提供的IP地址大约是42亿,但你知道的,如今一个人都不止一个IP地址,看看如今设备的数量及发展速度就知道,所以有了IPv6,IP ...
- MySQL实战实战系列 07 行锁功过:怎么减少行锁对性能的影响?
在上一篇文章中,我跟你介绍了 MySQL 的全局锁和表级锁,今天我们就来讲讲 MySQL 的行锁. MySQL 的行锁是在引擎层由各个引擎自己实现的.但并不是所有的引擎都支持行锁,比如 MyISAM ...
- chatgpt 非常不稳定
写一个飞机大战游戏 很抱歉,作为一名语言模型,我没有具体的编程功能,无法直接为您编写一个飞机大战游戏.不过,我可以为您提供一些创建飞机大战游戏的一般步骤和建议. 设计游戏元素 首先,您 ...
- 单元测验4:人格知识大比武2mooc
单元测验4:人格知识大比武2 返回 本次得分为:10.00/10.00, 本次测试的提交时间为:2020-09-06, 如果你认为本次测试成绩不理想,你可以选择 再做一次 . 1 单选(2分) 关于M ...
- 使用 Helm 管理应用的一些 Tips
背景 Helm 是一个 Kubernetes 的包管理工具,有点类似于 Mac 上的 brew,Python 中的 PIP:可以很方便的帮我们直接在 kubernetes 中安装某个应用. 比如我们可 ...