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;
}

D:N Problems During K Days

#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]<<" ";
   }
}

E:Minimum Array

#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);
      }

   }
}

F:Maximum Balanced Circle

#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]<<" ";
   }
}

最新文章

  1. 【原创】Js:日期处理(日期格式必须【yyyy-mm-dd】才能转成long的毫秒!其他的不是【年-月-日】的格式,结果会是【NaN】)
  2. idea项目无法自动导入maven库
  3. linux ubuntu装机到可实现java(eclipse,intellij IDEA,android)开发全过程
  4. applicationContext.xml xxx-servlet.xml
  5. leetcode oj s_06
  6. 第一百九十三天 how can I 坚持
  7. Unity3d + UGUI 的多分辨率适配
  8. EasyUI中combotree允许多选的时候onSelect事件会重复触发onCheck事件
  9. IOS 错误集合以及解决办法(持续整理中)
  10. 转:lr_eval_string函数的用法解析
  11. const与readonly
  12. MySQL(十三)之MySQL事务
  13. 4、ABPZero系列教程之拼多多卖家工具 集成短信发送模块
  14. winsock I/O模型的分析
  15. jenkins可选插件为空的解决方式
  16. Spark线性回归实现优化
  17. JS基础-组成
  18. PHP虚拟主机的配置
  19. c++计算器后续(3)
  20. phpmailer配置qq邮箱

热门文章

  1. DevExpress VCL 13.1.2 发布
  2. 2018.07.31 POJ1741Tree(点分治)
  3. RHEL6解决无法使用YUM源问题(转)
  4. Java带图片预览功能的图片上传兼容火狐ie
  5. Linux必须学的东西,鉴于各大公司实际开发都不用Windows系统
  6. AE和Mocha结合做视频后期制作
  7. shell中的重定向(输入输出)
  8. springmvc 开涛 拦截器
  9. 16、Docker的网络-host和none
  10. web.xml中Filter,Listener,Servlet的区别