题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6138

题意:给了初始区间[-1,1],然后有一些操作,可以r加上一个数,l减掉一个数,或者同时操作,问最后能不能凑出k。

解法:由于开始是-1,所以l,r能延伸到的任何区间都可以凑出来,直接判断即可。

#include <bits/stdc++.h>
using namespace std;
int a[1010];
int main()
{
int T,n,k;
scanf("%d",&T);
while(T--)
{
scanf("%d%d", &n,&k);
int l=-1,r=1;
for(int i=1; i<=n; i++) scanf("%d", &a[i]);
for(int i=1; i<=n; i++){
char op[3];
scanf("%s", op);
if(op[0]=='L'){
r+=a[i];
}
if(op[0]=='N'){
r+=a[i];
l-=a[i];
}
if(op[0]=='D'){
l-=a[i];
}
}
if(k>=l&&k<=r) puts("yes");
else puts("no");
}
return 0;
}

2017多校第8场 HDU 6138 Fleet of the Eternal Throne 思维,暴力的更多相关文章

  1. 2017多校第8场 HDU 6138 Fleet of the Eternal Throne AC自动机或者KMP

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6138 题意:给n个串,每次询问x号串和y号串的最长公共子串的长度,这个子串必须是n个串中某个串的前缀 ...

  2. 2017ACM暑期多校联合训练 - Team 8 1006 HDU 6138 Fleet of the Eternal Throne (字符串处理 AC自动机)

    题目链接 Problem Description The Eternal Fleet was built many centuries ago before the time of Valkorion ...

  3. HDU 6138 Fleet of the Eternal Throne(AC自动机)

    [题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=6138 [题目大意] 给出一些串,询问第x个串和第y个串的公共子串, 同时要求该公共子串为某个串的前 ...

  4. HDU 6138 Fleet of the Eternal Throne(后缀自动机)

    题意 题目链接 Sol 真是狗血,被疯狂卡常的原因竟是 我们考虑暴力枚举每个串的前缀,看他能在\(x, y\)的后缀自动机中走多少步,对两者取个min即可 复杂度\(O(T 10^5 M)\)(好假啊 ...

  5. HDU 6138 Fleet of the Eternal Throne 后缀数组 + 二分

    Fleet of the Eternal Throne Problem Description > The Eternal Fleet was built many centuries ago ...

  6. 2017多校第9场 HDU 6170 Two strings DP

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6170 题意:给了2个字符串,其中第2个字符串包含.和*两种特别字符,问第二个字符串能否和第一个匹配. ...

  7. 2017多校第9场 HDU 6161 Big binary tree 思维,类似字典树

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6161 题意: 题目是给一棵完全二叉树,从上到下从左到右给每个节点标号,每个点有权值,初始权值为其标号, ...

  8. 2017多校第9场 HDU 6169 Senior PanⅡ 数论,DP,爆搜

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6169 题意:给了区间L,R,求[L,R]区间所有满足其最小质数因子为k的数的和. 解法: 我看了这篇b ...

  9. 2017多校第10场 HDU 6181 Two Paths 次短路

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6181 题意:给一个图,求出次短路. 解法:我之前的模板不能解决这种图,就是最短路和次短路相等的情况,证 ...

随机推荐

  1. Go语言【第一篇】:Go初识

    Go语言特色 简洁.快速.安全 并行.有趣.开源 内存管理.数据安全.编译迅速 Go语言用途 Go语言被设计成一门应用于搭载Web服务器,存储集群或类似用途的巨型中央服务器的系统编程语言.对于高性能分 ...

  2. JavaScript-序列化及转义

    1.  for循环: while循环: 2. 条件语句: 类似于if else的功能. name='1'; switch(name){ case:'1': console.log(123); brea ...

  3. hadoop的第一个hello world程序(wordcount)

    在hadoop生态中,wordcount是hadoop世界的第一个hello world程序. wordcount程序是用于对文本中出现的词计数,从而得到词频,本例中的词以空格分隔. 关于mapper ...

  4. CentOS 查看系统内核和版本

    1.uname 命令用于查看系统内核与系统版本等信息,格式为“uname [-a]”. [root@bigdata-senior01 ~]# uname -a Linux bigdata-senior ...

  5. 51NOD 1594:Gcd and Phi——题解

    http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1594 参考及详细推导:http://www.cnblogs.com/ri ...

  6. C++中static用法

    本文为个人学习笔记,参考<C++ Primer(中文第五版)>和<王道程序员求职宝典> 本文分为两个部分:不考虑类.类中static的作用 一.不考虑类,static的作用 1 ...

  7. Poco::Path 和 DirectoryIterator

    #include<iostream>#include<typeinfo>#include<Poco/Path.h>using namespace std;using ...

  8. Codeforces Round #401 (Div. 2) A B C 水 贪心 dp

    A. Shell Game time limit per test 0.5 seconds memory limit per test 256 megabytes input standard inp ...

  9. tp if condition in_array用法

    <if condition="in_array($vo['status'],[3])"> <a href="javascript:void(0);&qu ...

  10. git merge与git rebase

    文章源:https://blog.csdn.net/wh_19910525/article/details/7554489 git merge是用来合并两个分支的. git merge b # 将b分 ...