Problem Statement

There is a sequence $A=(A_0,\ldots,A_{N-1})$ of length $N$.

Determine if there exists a tuple of integers $(x,y,z,w)$ that satisfies all of the following conditions:

  • $0 \leq x < y < z < w \leq N$
  • $A_x + A_{x+1} + \ldots + A_{y-1} = P$
  • $A_y + A_{y+1} + \ldots + A_{z-1} = Q$
  • $A_z + A_{z+1} + \ldots + A_{w-1} = R$

Constraints

  • $3 \leq N \leq 2\times 10^5$
  • $1 \leq A_i \leq 10^9$
  • $1 \leq P,Q,R \leq 10^{15}$
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

$N$ $P$ $Q$ $R$
$A_0$ $A_1$ $\ldots$ $A_{N-1}$

Output

If there exists a tuple that satisfies the conditions, print Yes; otherwise, print No.


Sample Input 1

10 5 7 5
1 3 2 2 2 3 1 4 3 2

Sample Output 1

Yes

$(x,y,z,w)=(1,3,6,8)$ satisfies the conditions.


Sample Input 2

9 100 101 100
31 41 59 26 53 58 97 93 23

Sample Output 2

No

Sample Input 3

7 1 1 1
1 1 1 1 1 1 1

Sample Output 3

Yes

预处理前缀和,然后枚举 $w$,如果存在 $s_z=s_w-r$,$s_y=s_w-r-q$,$s_x=s_w-r-p-q$,那么由于 $s$ 具有严格单调性,$x< y < z$,所以如果存在,答案就为 Yes.

#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int n,a[N],k;
long long p,q,r,s[N],lst(-1);
map<long long,int>t;
int can(long long x)
{
return t.find(x)!=t.end();
}
int main()
{
scanf("%d%lld%lld%lld",&n,&p,&q,&r);
t[0]=1;
for(int i=1;i<=n;i++)
scanf("%d",&a[i]),s[i]=s[i-1]+a[i],t[s[i]]=1;
for(int i=1;i<=n;i++)
{
if(can(s[i]-r)&&can(s[i]-q-r)&&can(s[i]-p-q-r))
{
printf("Yes");
return 0;
}
}
printf("No");
}

[ABC265D] Iroha and Haiku (New ABC Edition)的更多相关文章

  1. 和風いろはちゃんイージー / Iroha and Haiku (ABC Edition) (水水)

    题目链接:http://abc042.contest.atcoder.jp/tasks/abc042_a Time limit : 2sec / Memory limit : 256MB Score ...

  2. [Arc058E] Iroha and Haiku

    [Arc058E] Iroha and Haiku 题目大意 问有多少\(n\)个数的正整数序列,每个数在\([1,10]\)之间,满足存在\(x,y,z,w\)使得\(x\to y-1,y\to z ...

  3. 文字列大好きいろはちゃんイージー / Iroha Loves Strings (ABC Edition) (优先队列)

    题目链接:http://abc042.contest.atcoder.jp/tasks/abc042_b Time limit : 2sec / Memory limit : 256MB Score ...

  4. Solution -「ARC 058C」「AT 1975」Iroha and Haiku

    \(\mathcal{Description}\)   Link.   称一个正整数序列为"俳(pái)句",当且仅当序列中存在连续一段和为 \(x\),紧接着连续一段和为 \(y ...

  5. AtCoder Beginner Contest 265(D-E)

    D - Iroha and Haiku (New ABC Edition) 题意: 找一个最少含有三个点的区间,将区间分成三块,三块的和分别为p,q,r,问是否存在这样的区间 题解:先预处理一遍前缀和 ...

  6. AtCoder 瞎做

    目录 ARC 058 E - 和風いろはちゃん / Iroha and Haiku 题意 题解 技巧 代码 ARC 059 F - バイナリハック / Unhappy Hacking 题意 题解 技巧 ...

  7. AtCoder Regular Contest

    一句话题解 因为上篇AGC的写的有点长……估计这篇也短不了所以放个一句话题解方便查阅啥的吧QwQ 具体的题意代码题解还是往下翻…… ARC 058 D:简单容斥计数. E:用二进制表示放的数字,然后状 ...

  8. AtCoder-arc058(题解)

    A - こだわり者いろはちゃん / Iroha's Obsession(暴力) 题目链接 题目大意: 给你 \(k\) 个个位数字和一个数字 \(n\) ,要求找到一个大于等于n的数字,使得不出现 \ ...

  9. csp退役前的做题计划1(真)

    csp退役前的做题计划1(真) 因为我太菜了,所以在第一次月考就会退役,还是记录一下每天做了什么题目吧. 任务计划 [ ] Z算法(Z Algorithm) 9.28 [x] ARC061C たくさん ...

  10. 【AtCoder】ARC058

    ARC058 C - こだわり者いろはちゃん / Iroha's Obsession 暴力一个个枚举是最简单的方式 #include <bits/stdc++.h> #define fi ...

随机推荐

  1. [ABC128D] equeue

    2023-01-14 题目 题目传送门 翻译 翻译 难度&重要性(1~10):4 题目来源 AtCoder 题目算法 暴力,贪心 解题思路 由题意可以得出,数据只有 \(n \leq 50,k ...

  2. 构建iOS交叉编译环境

    要进行高级的iOS编程,我们需要很多工具链来帮我们完成这一目的 构建iOS交叉编译环境: 1.新建一个iphone交叉编译虚拟机 2. 为我们的虚拟机添加第二个网卡,设为host-only来达到能与宿 ...

  3. 在 RedHat Enterprise、CentOS 或 Fedora Linux 上安装 MongoDB

    在 RedHat Enterprise.CentOS 或 Fedora Linux 上安装 MongoDB 1.大纲 备注:采用yum安装后,所有进程将自动在/usr/bin下,如下的mongo.mo ...

  4. PanGu-Coder2:从排序中学习,激发大模型潜力

    本文分享自华为云社区<PanGu-Coder2:从排序中学习,激发大模型潜力>,作者: 华为云软件分析Lab . 2022年7月,华为云PaaS技术创新Lab联合华为诺亚方舟语音语义实验室 ...

  5. 「luogu - P3158」「cqoi 2011」放棋子

    link. 解读一下,大概就是一种颜色放进去就会占据一行一列,dp 状态就好想了:\(f_{i,j,k}\) 表示恰好用完前 \(k\) 种颜色的所有棋子,占据了 \(i\) 行 \(j\) 列的方案 ...

  6. Solution -「洛谷 P2000」拯救世界

    Description Link. 概括什么好麻烦哦 w. Solution 生成函数裸题. 把所有情况罗列出来: kkk: 金: \(1+x^6+x^{12}+\dots=\frac{1}{1-x^ ...

  7. Tomcat--文件上传--文件包含--(CVE-2017-12615)&&(CVE-2020-1938)

    Tomcat--文件上传--文件包含--(CVE-2017-12615)&&(CVE-2020-1938) 复现环境 采用Vulfocus靶场环境进行复现,搭建操作和文章参考具体搭建教 ...

  8. [SWPUCTF 2021 新生赛]老鼠走迷宫(详细版

    附件下载 https://wwvc.lanzouj.com/iYLez1br84jg 解题思路 用pyinstxtrator解析exe 重点:将无后缀的5先修改后缀为pyc,然后随便找一个pyc文件补 ...

  9. salesforce零基础学习(一百三十三)ListView的button思考

    本篇参考: salesforce零基础学习(九十五)lightning out salesforce零基础学习(一百一十)list button实现的一些有趣事情 https://help.sales ...

  10. Util应用框架Web Api开发环境搭建

    要使用Util应用框架开发项目,首先需要搭建合适的开发环境. 迈出第一步,对于很多.Net新人可能并不简单. 如果你对.Net环境并不熟悉,请尽量按照本文档进行操作. 操作系统 请安装 Windows ...