首页 技术 正文
技术 2022年11月21日
0 收藏 844 点赞 2,588 浏览 2151 个字

c2:Increasing Subsequence (hard version)

那边小取那边,然后相等比较后面的长度

#include<bits/stdc++.h>using namespace std;#define maxn 500005int 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;}

D:N Problems During K Days

#include<bits/stdc++.h>using namespace std;#define maxn 500005#define LL long longLL 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]<<" ";   }}

E:Minimum Array

#include<bits/stdc++.h>using namespace std;#define maxn 500005#define LL long longint 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);      }   }}

F:Maximum Balanced Circle

#include<bits/stdc++.h>using namespace std;#define maxn 500005#define LL long longint 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]<<" ";   }}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,909
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,434
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,249
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,060
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,692
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,730