2017多校第8场 HDU 6138 Fleet of the Eternal Throne 思维,暴力
2017-08-20 10:21
513 查看
题目链接: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; }
相关文章推荐
- HDU 6138 2017多校第八场1006 Fleet of the Eternal Throne :AC自动机
- hdu 6138 Fleet of the Eternal Throne
- hdu 6138 Fleet of the Eternal Throne(AC自动机)
- (后缀数组/Trie)HDU 6138-Fleet of the Eternal Throne
- HDU 6138 Fleet of the Eternal Throne AC自动机||后缀数组
- HDU 6138 Fleet of the Eternal Throne(2017 Multi-University Training Contest 8)
- HDU 6138 Fleet of the Eternal Throne (2017多校8 - AC自动机)
- HDU 6138 Fleet of the Eternal Throne (2017多校8 - AC自动机)
- HDU 6138 Fleet of the Eternal Throne ( AC自动机)
- HDU 6138 Fleet of the Eternal Throne(AC自动机)
- HDU 6138 Fleet of the Eternal Throne 后缀数组 + 二分
- HDU 6138 Fleet of the Eternal Throne 多校#8 AC自动机
- hdu 6138 Fleet of the Eternal Throne (ac自动机)
- HDU 6138 Fleet of the Eternal Throne(AC自动机)
- HDU 6138 Fleet of the Eternal Throne (后缀数组+字典树, 2017 Multi-Univ Training Contest 8)
- HDU 6138 Fleet of the Eternal Throne
- hdu 6138 Fleet of the Eternal Throne 基于kmp算法的求解
- HDU 6138 Fleet of the Eternal Throne (AC自动机)
- HDU 6138 Fleet of the Eternal Throne [AC自动机]
- HDU-2017 多校训练赛8-1006-Fleet of the Eternal Throne