模拟。

连续的一段$a$合成一个$b$。每段中如果数字只有$1$个,那么可以合成。如果数字个数大于等于$2$个,如果都是一样的,那么无法合成,否则要找到一个可以移动的最大值位置开始移动。一开始写了一个模拟,没考虑到严格大于,$WA$在$106$组数据了......

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<ctime>
#include<iostream>
using namespace std;
typedef long long LL;
const double pi=acos(-1.0);
void File()
{
freopen("D:\\in.txt","r",stdin);
freopen("D:\\out.txt","w",stdout);
}
template <class T>
inline void read(T &x)
{
char c = getchar();
x = ;
while(!isdigit(c)) c = getchar();
while(isdigit(c))
{
x = x * + c - '';
c = getchar();
}
} int n,k;
long long a[],b[];
vector<int>p,op; int main()
{
cin>>n;
for(int i=;i<=n;i++) cin>>a[i];
cin>>k;
for(int i=;i<=k;i++) cin>>b[i]; long long sum=;
int pos=,pre=,fail=; for(int i=;i<=n;i++)
{
sum=sum+a[i];
if(sum<b[pos]) continue;
else if(sum>b[pos]) {fail=; break;}
else
{
if(i-pre==)
{
pos++; sum=; pre=i;
continue;
} bool d=;
for(int j=pre+;j<i;j++) if(a[j]!=a[j+]) d=;
if(d==) {fail=; break;} long long mx=; int idx;
for(int j=pre+;j<=i;j++) mx=max(mx,a[j]); for(int j=pre+;j<=i;j++)
{
if(a[j]!=mx) continue;
if(j->=pre+&&a[j-]!=mx)
{
idx=j;
for(int t=;t<=idx-pre-;t++) { p.push_back(idx-pre+pos--t+); op.push_back(); }
for(int t=;t<=i-idx+-;t++) { p.push_back(pos); op.push_back(); }
break;
} else if(j+<=i&&a[j+]!=mx)
{
idx=j;
for(int t=;t<=i-idx+-;t++) { p.push_back(idx-pre+pos-); op.push_back(); }
for(int t=;t<=idx-pre-;t++) { p.push_back(idx-pre+pos--t+); op.push_back(); }
break;
} } pos++; sum=; pre=i;
}
} if(pos!=k+) fail=; if(fail==) printf("NO\n");
else
{
printf("YES\n");
for(int i=;i<p.size();i++)
{
cout<<p[i]<<" ";
if(op[i]==) cout<<"L";
else cout<<"R";
cout<<endl;
}
} return ;
}

CodeForces 733C Epidemic in Monstropolis的更多相关文章

  1. 【16.52%】【codeforces 733C】Epidemic in Monstropolis

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  2. Codeforces Round #378 (Div. 2) C. Epidemic in Monstropolis 模拟

    C. Epidemic in Monstropolis time limit per test 1 second memory limit per test 256 megabytes input s ...

  3. Codeforces Round #378 (Div. 2)-C. Epidemic in Monstropolis

    C. Epidemic in Monstropolis time limit per test 1 second memory limit per test 256 megabytes input s ...

  4. Epidemic in Monstropolis

    Epidemic in Monstropolis 题目链接:http://codeforces.com/contest/733/problem/C 贪心 新序列的m个数肯定是由原序列的连续的m个子序列 ...

  5. CF733C Epidemic in Monstropolis[模拟 构造 贪心]

    C. Epidemic in Monstropolis time limit per test 1 second memory limit per test 256 megabytes input s ...

  6. Codeforces 733C:Epidemic in Monstropolis(暴力贪心)

    http://codeforces.com/problemset/problem/733/C 题意:给出一个序列的怪兽体积 ai,怪兽只能吃相邻的怪兽,并且只有体积严格大于相邻的怪兽才能吃,吃完之后, ...

  7. C. Epidemic in Monstropolis

    http://codeforces.com/contest/733/problem/C 一道很恶心的模拟题. 注意到如果能凑成b[1],那么a的前缀和一定是有一个满足是b[1]的,因为,如果跳过了一些 ...

  8. codeforces733-C. Epidemic in Monstropolis 贪心加链表

    题意 现在有一个怪兽序列a[i],权值大的怪兽可以吃权值小的怪兽,吃完之后权值大的怪兽的权值会变成两者权值的和,相邻的怪兽才能吃 吃完之后,位置合并,队列前移,从左到右重新编号,重复这一过程, 然后给 ...

  9. Codeforces Round #378 (Div. 2) A B C D 施工中

    A. Grasshopper And the String time limit per test 1 second memory limit per test 256 megabytes input ...

随机推荐

  1. 字符串类dp的题目总结

    熟练掌握回文串吧,大致有dp或者模拟类的吧 ①dp+预处理,懂得如何枚举回文串(一) ②dp匹配类型的题目(二) ③dp+预处理 子串类型 (三) ④字符串的组合数(四) 一:划分成回文串 UVA11 ...

  2. Java堆内存Heap与非堆内存Non-Heap

    堆(Heap)和非堆(Non-heap)内存     按照官方的说法:“Java 虚拟机具有一个堆,堆是运行时数据区域,所有类实例和数组的内存均从此处分配.堆是在 Java 虚拟机启动时创建的.”“在 ...

  3. Divergent Change(发散式变化)---要重构的信号

    “ 当你看着一个类说,呃,如果新加入一个数据库,我必须修改这三个函数:如果新出现一种金融工具,我必须修改这四个函数.那么,此时也许将这个类分成两个会更好,这么一来每个对象就可以只因一种变化而需要修改. ...

  4. bzoj2516 电梯

    传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=2516 [题解] 状压dp. $f_{sta,i}$表示状态为sta,当前在第i层的最小花费时 ...

  5. VSCode Web Developement for Javascript. Must have plugins.

    Es6 Javascript front-end web developemnt must have plugins Prettier - Code Formatter Javascript (ES6 ...

  6. 【HNOI】 小A的树 tree-dp

    [题目描述]给定一颗树,每个点有各自的权值,任意选取两个点,要求算出这两个点路径上所有点的and,or,xor的期望值. [数据范围]n<=10^5 首先期望可以转化为求树上所有点对的and,o ...

  7. End to End Sequence Labeling via Bidirectional LSTM-CNNs-CRF论文小结

    本篇论文是卡内基梅隆大学语言技术研究所2016年  arXiv:1603.01354v5 [cs.LG] 29 May 2016 今天先理解一下这个是什么意思:        找到的相关理解:arXi ...

  8. linux 3389连接工具Rdesktop

    简单使用 工作机换成战斗机了,改用ubuntu,原来的windows7上东西笔记多,还不想重装.用rdesktop来远程连接windows: sudo apt-get install rdesktop ...

  9. 数组返回NULL绕过

    BUGKU:http://120.24.86.145:9009/19.php 还没看完源码,我就直接加了一个password[]=1结果就拿到flag了.然后再看源码我自己都搞不懂为什么可以得到源码. ...

  10. PHP路由代码

    <?php /**  * 路由  * @author 角度 QQ:1286522207  *  */ class Dispatcher extends Action {     private ...