模拟。

连续的一段$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. 与http协作的web服务器、http首部(第五章、第六章)

    第五章 与http协作的web服务器 1.用单台虚拟主机实现多个域名 通过域名访问主机,经过DNS解析成ip地址,反向代理,可以代理多台服务器,正向代理则相反,代理客户端 2.通信数据转化程序:代理. ...

  2. 图论:Prufer编码

    BZOJ1211:使用prufer编码解决限定结点度数的树的计数问题 首先学习一下prufer编码是干什么用的 prufer编码可以与无根树形成一一对应的关系 一种无根树就对应了一种prufer编码 ...

  3. Linux之防火墙与端口

    1.关闭所有的 INPUT FORWARD OUTPUT 只对某些端口开放.下面是命令实现: iptables -P INPUT DROPiptables -P FORWARD DROPiptable ...

  4. 元类编程-- metaclass

    #类也是对象,type创建类的类 def create_class(name): if name == "user": class User: def __str__(self): ...

  5. 【BZOJ】2060: [Usaco2010 Nov]Visiting Cows 拜访奶牛

    [算法]树形DP [题解]没有上司的舞会?233 f[x][0]=∑max(f[v][0],f[v][1]) f[x][1]=(∑f[v][0])+1 #include<cstdio> # ...

  6. 【BZOJ】2502 清理雪道

    [算法]有源汇上下界最小流 [题解]上下界 初看以为是最小覆盖,发现边可以重复经过,不对. 要求所有边都经过……那就下界为1,上界为inf的可行流. 源汇……S连入度为0的点,T连出度为0的点?(反正 ...

  7. 【CC2530入门教程-01】CC2530微控制器开发入门基础

    [引言] 本系列教程就有关CC2530单片机应用入门基础的实训案例进行分析,主要包括以下6部分的内容:[1]CC2530微控制器开发入门基础.[2]通用I/O端口的输入和输出.[3]外部中断初步应用. ...

  8. charles https抓包

    1. 配置 Charles 根证书 首先打开 Charles: Charles 启动界面 主界面 然后如下图操作:   之后会弹出钥匙串,如果不弹出,请自行打开钥匙串,如下图: 钥匙串 系统默认是不信 ...

  9. Python第三方库wordcloud(词云)快速入门与进阶

    前言: 笔主开发环境:Python3+Windows 推荐初学者使用Anaconda来搭建Python环境,这样很方便而且能提高学习速度与效率. 简介: wordcloud是Python中的一个小巧的 ...

  10. clientX,offsetX,layerX,pageX,screenX,X鼠标位置全解

    clientX,offsetX,layerX,pageX,screenX,X有时容易记混,通过测试当前的主流浏览器疏理了自己的一些看法以供参考. Chrome下(测试版本为51.0.2704.106  ...