Codeforces Round #555 (Div. 3) c2 d e f
c2:Increasing Subsequence (hard version)
那边小取那边,然后相等比较后面的长度
#include<bits/stdc++.h>
using namespace std;
#define maxn 500005
int a[maxn];
int main(){
,in;
scanf("%d",&n);
;j<n;j++){
scanf("%d",&a[j]);
if(mx<a[j]){
mx = a[j];
in = j;
}
}
string s="";
,r = n-,k=-;
while(l<=r){
if(k<min(a[l],a[r])){
if(a[l]<a[r]){
s+="L";
k=a[l];
l++;
}else if(a[l]>a[r]){
s+='R';
k=a[r];
r--;
}else{
,x=k;
,y=k;
for(int i = l;i<=in;i++){
if(a[i]>x){
x = a[i];
res1++;
}else break;
}
for(int i = r;i>=in;i--){
if(a[i]>y){
y = a[i];
res2++;
}else break;
}
if(res1>res2){
k = a[l];
l++;
s+='L';
}else{
k = a[r];
r--;
s+='R';
}
}
}else if(k<a[l]){
s+='L';
k = a[l];
l++;
}else if(k<a[r]){
s+='R';
k = a[r];
r--;
}else break;
}
cout<<s.size()<<endl;
cout<<s<<endl;
}
#include<bits/stdc++.h>
using namespace std;
#define maxn 500005
#define LL long long
LL a[maxn];
int main(){
LL n,m;
scanf(;j<m;j++){
a[j] = (n - (m - j) * (m - -j) / ) / (m-j);
//cout<<a[j]<<endl;
&&a[j]>a[j-]*){
a[j]=a[j-]*;
}
n-=a[j];
){
cout<<"NO"<<endl;
;
}
}
if(n){
cout<<"NO"<<endl;
;
}
cout<<"YES"<<endl;
;j<m;j++){
cout<<a[j]<<" ";
}
}
#include<bits/stdc++.h>
using namespace std;
#define maxn 500005
#define LL long long
int a[maxn];
map<int,int>mp;
set<int>s;
vector<int>Q;
int main(){
int n;
cin>>n;
;j<n;j++){
cin>>a[j];
}
;j<n;j++){
int x;
cin>>x;
mp[x]++;
s.insert(x);
}
;j<n;j++){
int x = (n-a[j])%n;
set<int> ::iterator it = s.lower_bound(x);
if(it==s.end()){
it=s.begin();
}
){
mp[*it]--;
cout<<(*it+a[j])%n<<" ";
}
){
s.erase(it);
}
}
}
#include<bits/stdc++.h>
using namespace std;
#define maxn 500005
#define LL long long
int a[maxn];
map<int,int>mp;
set<int>s;
vector<int>q,w;
int main(){
int n;
cin>>n;
;j<n;j++){
scanf("%d",&a[j]);
mp[a[j]]++;
q.push_back(a[j]);
}
sort(q.begin(),q.end());
q.erase(unique(q.begin(),q.end()),q.end());
,mx = ,res = ,r=-;
;j<q.size();j++){
){
res+=mp[q[j]];
if(res>mx){
mx = res;
r = j;
}
}else{
]+){
){
res+=mp[q[j]];
if(res>mx){
mx = res;
r = j;
}
}else{
res+=mp[q[j]];
if(res>mx){
mx = res;
r = j;
}
res = mp[q[j]];
}
}else{
res=mp[q[j]];
if(res>mx){
mx = res;
r = j;
}
}
}
}
// if(mx==21){
// cout<<q[r]<<endl;
// }
// cout<<mx<<" "<<r<<endl;
int s = mp[q[r]];
;j>=;j--){
!=q[j+]){
l=j+;
break;
}else{
s+=mp[q[j]];
if(s==mx){
l=j;
break;
}
}
}
// cout<<l<<endl;
for(int j=l;j<=r;j++){
){
w.push_back(q[j]);
mp[q[j]]--;
}
}
for(int j=r;j>=l;j--){
w.push_back(q[j]);
}
cout<<w.size()<<endl;
;j<w.size();j++){
cout<<w[j]<<" ";
}
}
Codeforces Round #555 (Div. 3) c2 d e f的更多相关文章
- Codeforces Round #555 (Div. 3) C2. Increasing Subsequence (hard version)【模拟】
一 题面 C2. Increasing Subsequence (hard version) 二 分析 需要思考清楚再写的一个题目,不能一看题目就上手,容易写错. 分以下几种情况: 1 左右两端数都小 ...
- Codeforces Round #555 (Div. 3) C2. Increasing Subsequence (hard version) (贪心)
题意:给你一组数,每次可以选队首或队尾的数放入栈中,栈中元素必须保持严格单增,问栈中最多能有多少元素,并输出选择情况. 题解:首先考虑队首和队尾元素不相等的情况,如果两个数都大于栈顶元素,那么我们选小 ...
- Codeforces Round #622 (Div. 2) C2. Skyscrapers (hard version)(单调栈,递推)
Codeforces Round #622 (Div. 2) C2. Skyscrapers (hard version) 题意: 你是一名建筑工程师,现给出 n 幢建筑的预计建设高度,你想建成峰状, ...
- Codeforces Round #568 (Div. 2) C2. Exam in BerSU (hard version)
链接: https://codeforces.com/contest/1185/problem/C2 题意: The only difference between easy and hard ver ...
- Codeforces Round #622 (Div. 2).C2 - Skyscrapers (hard version)
第二次写题解,请多多指教! http://codeforces.com/contest/1313/problem/C2 题目链接 不同于简单版本的暴力法,这个数据范围扩充到了五十万.所以考虑用单调栈的 ...
- Codeforces Round #622 (Div. 2)C2 Skyscrapers最大"尖"性矩形,思维||分治
题:https://codeforces.com/contest/1313/problem/C2 题意:给出n个数,分别代表第i个位置所能搭建的最大高度,问以哪一个位置的塔的高度为基准向左的每一个塔都 ...
- Codeforces Round #555 (Div. 3) C1,C2【补题】
D1:思路:L,R指针移动,每次选最小的即可. #include<bits/stdc++.h> using namespace std; #define int long long #de ...
- 老年OIer的Python实践记—— Codeforces Round #555 (Div. 3) solution
对没错下面的代码全部是python 3(除了E的那个multiset) 题目链接:https://codeforces.com/contest/1157 A. Reachable Numbers 按位 ...
- CodeForces Round #555 Div.3
A. Reachable Numbers 代码: #include <bits/stdc++.h> using namespace std; ; int N; set<int> ...
随机推荐
- 2018.10.12 NOIP模拟 棋盘问题(切比雪夫距离)
传送门 貌似是防ak题? 考试的时候想到了做四次cdqcdqcdq于是给自己多套了一个lognlognlogn结果还MLEMLEMLE 0分.(记得最后5分钟调出来的时候是那么的欣喜 下来发现并不需要 ...
- java编程规范-阿里
- 如何用命令行将我的Phonegap环境更新到最新版本?
从npm安装的Phonegap(version > 3.0),更新命令如下 npm update -g phonegap 检查当前本机环境的最新版本 phonegap -v 检查npm的最新ph ...
- 20155320 2016-2017-2 《Java程序设计》第五周学习总结
20155320 2016-2017-2 <Java程序设计>第五周学习总结 教材学习内容总结 错误处理 java中所有错误都会被打包为对象,可以通过try catch 代表错误的对象后做 ...
- hdu 5024 最长的L型
http://acm.hdu.edu.cn/showproblem.php?pid=5024 找到一个最长的L型,L可以是斜着的 简单的模拟 #include <cstdio> #incl ...
- C# Socket 实现WebSocket服务器端
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.N ...
- C#图片处理,缩略图制作
准备参数:图片文件流.文件名 方法:1.先将图片流通过System.Drawing.Image.FromStream方法转成图片对象 2.通过图片对象.GetThumbnailImage方法生成自定义 ...
- Entity Framework学习记录
记录一次ef code first的学习记录 最近想做一套自己的框架,正在寻找合适的ORM,之前参照力软(很早之前的版本了)的底层代码,做了一套自己的增删改查, 但是使用起来总觉得缺了点什么? 所以决 ...
- C# autofac配置文件中设置单例
设置instance-scope属性值为SingleInstance
- 使用Git上传代码到远程仓库
1.进入文件夹,cd f:/test/ 2.初始化远程仓库,git init 3.添加代码,git add . (注意add后面的点前面有一个空格) 4.提交代码到远程仓库,git commit -m ...