D1:思路:L,R指针移动,每次选最小的即可。

 #include<bits/stdc++.h>

 using namespace std;
#define int long long
#define N 200009
int arr[N];
int ans[N];
signed main(){
int n;
cin>>n;
for(int i=;i<=n;i++){
cin>>arr[i];
}
int l=,r=n;
int cnt=;
int now=;
while(){
if(now<arr[l]&&now<arr[r]){
if(arr[l]<arr[r]){ ans[++cnt]=;
now=arr[l];
l++;
}else{ ans[++cnt]=;
now=arr[r];
r--;
}
}else if(now<arr[l]){ ans[++cnt]=;
now=arr[l];l++;
}else if(now<arr[r]){ ans[++cnt]=;
now=arr[r];r--;
}else{
break;
}
}
cout<<cnt<<'\n';
for(int i=;i<=cnt;i++){
if(ans[i])
cout<<"R";
else
cout<<"L"; }
return ;
}

D1:思路:L,R指针移动,每次选最小的即可。【注意:特判左右两个数相等即可】

 #include<bits/stdc++.h>

 using namespace std;
#define int long long
#define N 200009
int arr[N];
int ans[N];
signed main(){
int n;
cin>>n;
for(int i=;i<=n;i++) cin>>arr[i];
int l=,r=n;
int cnt=;
int now=;
while(){
if(arr[l]==arr[r]&&l<r&&arr[l]>now){
//cout<<"==";
int temp;
temp=l;
int sum1=;
while(arr[temp]<arr[temp+]&&(temp+)<r){
temp++;
sum1++;
}
temp=r;
int sum2=;
while(arr[temp]<arr[temp-]&&(temp-)>l){
temp--;
sum2++;
}
if(sum1>sum2){
ans[++cnt]=;
now=arr[l];
l++;
}else{
ans[++cnt]=;
now=arr[r];
r--;
}
}else if(now<arr[l]&&now<arr[r]){
if(arr[l]<arr[r]){
ans[++cnt]=;
now=arr[l];
l++;
}else{
ans[++cnt]=;
now=arr[r];
r--;
}
}else if(now<arr[l]){ ans[++cnt]=;
now=arr[l];l++;
}else if(now<arr[r]){ ans[++cnt]=;
now=arr[r];r--;
}else{
break;
}
}
cout<<cnt<<'\n';
for(int i=;i<=cnt;i++){
if(ans[i])
cout<<"R";
else
cout<<"L";
}
return ;
} /*
1 3 5 4 2 1
15
37504 79054 80071 95721 135743 164345 189260 190810 191657 196168 200000 200000 190810 190018 185437
*/

左右两端数都小于等于构造的数组的最后一个数字

Codeforces Round #555 (Div. 3) C1,C2【补题】的更多相关文章

  1. Codeforces Round #524 (Div. 2)(前三题题解)

    这场比赛手速场+数学场,像我这样读题都读不大懂的蒟蒻表示呵呵呵. 第四题搞了半天,大概想出来了,但来不及(中途家里网炸了)查错,于是我交了两次丢了100分.幸亏这次没有掉rating. 比赛传送门:h ...

  2. 老年OIer的Python实践记—— Codeforces Round #555 (Div. 3) solution

    对没错下面的代码全部是python 3(除了E的那个multiset) 题目链接:https://codeforces.com/contest/1157 A. Reachable Numbers 按位 ...

  3. Codeforces Round #426 (Div. 2)A B C题+赛后小结

    最近比赛有点多,可是好像每场比赛都是被虐,单纯磨砺心态的作用.最近讲的内容也有点多,即便是点到为止很浅显的版块,刷了专题之后的状态还是~"咦,能做,可是并没有把握能A啊".每场网络 ...

  4. Codeforces Round #350 (Div. 2) C. Cinema 水题

    C. Cinema 题目连接: http://www.codeforces.com/contest/670/problem/C Description Moscow is hosting a majo ...

  5. Codeforces Round #555 (Div. 3) c2 d e f

    c2:Increasing Subsequence (hard version) 那边小取那边,然后相等比较后面的长度 #include<bits/stdc++.h> using name ...

  6. Codeforces Round #555 (Div. 3) C2. Increasing Subsequence (hard version)【模拟】

    一 题面 C2. Increasing Subsequence (hard version) 二 分析 需要思考清楚再写的一个题目,不能一看题目就上手,容易写错. 分以下几种情况: 1 左右两端数都小 ...

  7. Codeforces Round #555 (Div. 3) A B C1(很水的题目)

    A. Reachable Numbers 题意:设f(x)为 x+1 这个数去掉后缀0的数,现在给出n,问经过无数次这种变换后,最多能得到多少个不同的数. 代码 #include<cstdio& ...

  8. Codeforces Round #555 (Div. 3) C2. Increasing Subsequence (hard version) (贪心)

    题意:给你一组数,每次可以选队首或队尾的数放入栈中,栈中元素必须保持严格单增,问栈中最多能有多少元素,并输出选择情况. 题解:首先考虑队首和队尾元素不相等的情况,如果两个数都大于栈顶元素,那么我们选小 ...

  9. CodeForces Round #555 Div.3

    A. Reachable Numbers 代码: #include <bits/stdc++.h> using namespace std; ; int N; set<int> ...

随机推荐

  1. Session中清除对象方法比较

    转载. https://blog.csdn.net/u014401141/article/details/51816308 Session中清除对象方法比较   http://blog.csdn.ne ...

  2. Git服务器搭建--ssh/http

    测试环境 Windows 7 Ultimate, 64-bit 6.1.7601, Service Pack 1(实体机,虚拟机VMware的宿主机) VMware® Workstation 7.1. ...

  3. 长乐培训Day6

    T1 数列 题目 [题目描述] [输入格式] [输出格式] [输入样例] [输出样例] [数据规模] 如上所述. 解析 身为T1,居然比T4还难......让我怎么办......以下为巨佬题解: 我猜 ...

  4. Python对象的引用、可变性和垃圾回收

    1.标识.相等性和别名 别名的例子 >>> charles = {'name': 'Charles L. Dodgson', 'born': 1832} >>> l ...

  5. Ubuntu的apt命令详解()deepin linux是在Ubuntu基础上开发的

    apt-cache和apt-get是apt包的管理工具,他们根据/etc/apt/sources.list里的软件源地址列表搜索目标软件.并通过维护本地软件包列表来安装和卸载软件. 查看本机是否安装软 ...

  6. 使用docker-compose搭建WordPress

    今天博主使用typecho各种不爽,索性干掉typecho,使用WordPress 依赖 mysql nginx yml 文件 version: '3' services: nginx: image: ...

  7. IIS不能下载config配置文件的解决方法

    之前作程序升级的时候,需要从服务端下载后缀为config的配置文件,结果程序抛出404异常.后来百度才知道,是IIS禁止下载config文件的原因.在这里记录一下解决方法. 在我的电脑,右键管理,打开 ...

  8. centos7 GNOME 安装微信客户端

    写在前边 最近新装了一个 centos7 GNOME 系统,用了很久了 win,突然转换 linux 桌面版,觉得焕然一新,给搬砖生活增添了一份新意 ~ 先看一下效果图: 怎么弄呢? 下载最新版本 t ...

  9. AetherUpload大文件传输

    AetherUpload-Laravel是laravel框架下的一个大文件传输组件 github:https://github.com/peinhu/AetherUpload-Laravel 文件传输 ...

  10. SDL -安全开发生命周期

    1.学习SDL https://www.cnblogs.com/whoami101/p/9914862.html 2.学习SDL https://blog.csdn.net/whatday/artic ...