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的更多相关文章

  1. Android配置----DDMS 连接真机(己ROOT),用file explore看不到data/data文件夹的解决办法

    Android DDMS 连接真机(己ROOT),用file explore看不到data/data文件夹,问题在于data文件夹没有权限,用360手机助手或豌豆荚也是看不见的. 有以下两种解决方法: ...

  2. android DDMS 连接真机(己ROOT),用file explore看不到data/data文件夹的解决办法

    android DDMS 连接真机(己ROOT),用file explore看不到data/data文件夹的解决办法 问题是没有权限,用360手机助手或豌豆荚也是看不见的. 简单的办法是用RE文件管理 ...

  3. HDU 5476 Explore Track of Point 数学平几

    Explore Track of Point Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem ...

  4. 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 ...

  5. Android studio3.0打开Device File Explore(文件管理器)的方法(图文教程)

    Android studio3.0打开Device File Explore(文件管理器)的方法(图文教程) 看到网上AS3.0新增加的查看手机文件的新功能,全部都是转载的,没有几个人心细的把如何打开 ...

  6. Process Explore & Windbg

    遇到点内存泄漏.句柄泄漏,应该是家常便饭了.这次就是,程序运行内存一点点增加,句柄也是只增不减,个数竟然可以达到几十万,真是瞪大了我的双眼. 借此机会,学习下相关工具~ Process Explore ...

  7. explore your hadoop data and get real-time results

    deep api integration makes getting value from your big data easy 深度api集成使你大数据訪问更加easy Elasticsearch ...

  8. eclipse插件-easy explore

    最近找到一个Eclipse的插件,名字是Easy Explore,是Easy Structs 其 中的一个部分.主要的功能就是在Eclipse里面视图的部分如果看到自己的工程,或者Package,包什 ...

  9. eclipse中package explore和project explore 怎么相互切换???

    window--->show view--->other---->Java---->Package Explorer或者选project explore之后就可以相互切换了

  10. gitbook.explore更新升级了, 不能再搜索了

    www.gitbook.com/explore 不再是一个索引页面 Can I browse existing projects on GitBook ? The new version of Git ...

随机推荐

  1. 《代码整洁之道 Clean Code》学习笔记 Part 1

    前段时间在看<架构整洁之道>,里面提到了:构建一个好的软件系统,应该从写整洁代码做起.毕竟,如果建筑使用的砖头质量不佳,再好的架构也无法造就高质量的建筑.趁热打铁,翻出<代码整洁之道 ...

  2. Unity TextMeshPro 添加中文字体遇见的问题以及解决方案

    前言 按标准官方教程为 Unity TextMeshPro 添加中文字体时出现了各种奇奇怪怪的问题,于是有了这篇随笔. 中文字体解决方案 以下步骤适用于 TextMeshPro 3.0.6. 字符数量 ...

  3. Blazor前后端框架Known-V1.2.14

    V1.2.14 Known是基于C#和Blazor开发的前后端分离快速开发框架,开箱即用,跨平台,一处代码,多处运行. Gitee: https://gitee.com/known/Known Git ...

  4. WPF 在MVVM模式下应用动画

    一个简单的需求:当程序发生异常时候,在界面上动画显示异常信息. 这个需求看似简单,只需要try--catch到异常,然后把异常的信息写入界面就OK了. 但在MVVM时,就不是这么简单了.MVVM模式下 ...

  5. 保护个人数据安全,使用luks加密硬盘分区

    create:2023-01-24 17:44:44 准备工作 新硬盘4T,无数据.在root用户或sudo状态下执行. 首先创建分区表,由于mbr最大支持只有2T,因此分区表创建为gpt格式. 然后 ...

  6. NAT模式LVS负载均衡集群

    NAT模式LVS负载均衡集群 负载调度器:内网 网关 ens33:192.168.1.200,外网 网关 ens36:12.0.0.10 Web节点服务器1:192.168.1.100 Web节点服务 ...

  7. salesforce零基础学习(一百三十一)Validation 一次的bypass设计

    本篇参考: https://admin.salesforce.com/blog/2022/how-i-solved-it-bypass-validation-rules-in-flows 背景:作为系 ...

  8. Solution -「洛谷 P4451」「国家集训队」整数的 lqp 拆分

    Description Link. 求 \[\sum\prod_{i=1}^{m}F_{a_{i}},(m>0,a_{1},\cdots a_{m}>0,\sum a_{i}=n) \] ...

  9. 前端设计模式:工厂模式(Factory)

    00.基础概念 工厂模式封装了对象的创建new(),将消费者(使用)和生产者(实现)解耦. 工厂是干什么的?工厂是生产标准规格的商品的地方,建好工厂,投入原料(参数),产出特定规格的产品.so,工厂模 ...

  10. ptaCCF

    返回首页 English站点地图联系我们常见问题CCF招聘登录 加入CCF 计算机 CCF简介   中国计算机学会(CCF)成立于1962年,全国性学会,独立社团法人,中国科学技术协会成员. CCF是 ...