模拟。

连续的一段$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. centos7-每天定时备份 mysql数据库

    centos7-每天定时备份 mysql数据库 第一步:编写数据库备份脚本database_mysql_shell.sh #!/bin/bash DATE=`date +%Y%m%d%H%M` #ev ...

  2. ES6 利用集合Set解决数组 交集 并集 差集的问题

    根据阮一峰老师的ES6教程自己体会而写的,希望能给一些朋友有帮助到 let a = new Set([1,2,3,4]) let b = new Set([2,3,4,5,]) 并集 let unio ...

  3. C11简洁之道:lambda表达式

    1.  定义 lambda表达式是C++11非常重要也是很常用的特性之一,来源于函数式编程的概念,也是现代编程语言的一个特点.它有如下特点: 声明式编程风格:就地匿名定义目标函数或者函数,不需要额外写 ...

  4. redis linux下的环境搭建

    系统  CentOS7 Redis 官网下载   https://redis.io/download 1.下载解压 [root@TestServer-DFJR programs]# /usr/loca ...

  5. mysql 数据库备份与还原,用户的创建与删除,用户的密码修改

    1.备份数据库 要退出mysql rimideiMac-23:~ rimi$    mysqldump -u root -p pro >pro.sql ls 查看路径 2.恢复数据库 2.1直接 ...

  6. Linux Shell下执行sqlplus

    转载自: http://www.cnblogs.com/include/archive/2011/12/30/2307889.html 以下方法解决了在linux下自动的删除创建用户 sqlplus ...

  7. Tomcat 7下如何利用 catalina.properties 部署公用类

    Tomcat 有很多配置文件,其中一个是  catalina.properties ,本文介绍catalina.properties 中的设置项. 一.组成   catalina.properties ...

  8. 【BZOJ】3626 [LNOI2014]LCA

    [算法]树链剖分+线段树(区间加值,区间求和) [题解]http://hzwer.com/3891.html 中间不要取模不然相减会出错. 血的教训:线段树修改时标记下传+上传,查询时下传.如果修改时 ...

  9. GBK UTF-16 UTF-8 编码表

    GBK   UTF-16 UTF-8 ================== D2BB  4E00  E4 B8 80  一 B6A1  4E01  E4 B8 81  丁 C6DF  4E03  E4 ...

  10. Python模块学习 - psutil

    psutil模块介绍 psutil是一个开源切跨平台的库,其提供了便利的函数用来获取才做系统的信息,比如CPU,内存,磁盘,网络等.此外,psutil还可以用来进行进程管理,包括判断进程是否存在.获取 ...