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

Codeforces Round #555 (Div. 3) c2 d e f的更多相关文章

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

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

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

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

  3. Codeforces Round #622 (Div. 2) C2. Skyscrapers (hard version)(单调栈,递推)

    Codeforces Round #622 (Div. 2) C2. Skyscrapers (hard version) 题意: 你是一名建筑工程师,现给出 n 幢建筑的预计建设高度,你想建成峰状, ...

  4. 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 ...

  5. Codeforces Round #622 (Div. 2).C2 - Skyscrapers (hard version)

    第二次写题解,请多多指教! http://codeforces.com/contest/1313/problem/C2 题目链接 不同于简单版本的暴力法,这个数据范围扩充到了五十万.所以考虑用单调栈的 ...

  6. Codeforces Round #622 (Div. 2)C2 Skyscrapers最大"尖"性矩形,思维||分治

    题:https://codeforces.com/contest/1313/problem/C2 题意:给出n个数,分别代表第i个位置所能搭建的最大高度,问以哪一个位置的塔的高度为基准向左的每一个塔都 ...

  7. Codeforces Round #555 (Div. 3) C1,C2【补题】

    D1:思路:L,R指针移动,每次选最小的即可. #include<bits/stdc++.h> using namespace std; #define int long long #de ...

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

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

  9. CodeForces Round #555 Div.3

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

随机推荐

  1. 使用delphi 开发多层应用(十九) ios通过soap 访问kbmmw服务器

    随着delphi XE4 的推出,开始真正意义上支持ios 的开发,由于目前kbmmw 还不完全支持ios 的开发,因此 无法直接使用kbmmw 的客户端访问kbmmw 的服务器(虽然kbmmw 也提 ...

  2. 2018.08.19 洛谷P1402 酒店之王(最大流)

    传送门 最大流入门题,把人拆点即可. 代码: #include<bits/stdc++.h> #define N 505 using namespace std; inline int r ...

  3. hadoop学习笔记(五):java api 操作hdfs

    HDFS的Java访问接口 1)org.apache.hadoop.fs.FileSystem 是一个通用的文件系统API,提供了不同文件系统的统一访问方式. 2)org.apache.hadoop. ...

  4. 优秀前端工程师必备:" checkbox & radio--单钩 & 多钩 "大比较:你是♂||♀ , 还是 ♂&♀

    1 单选: type="radio"  需求: 男女input只能选择一个 <input type="radio" name="sex" ...

  5. yersinia的DHCP池耗尽断网攻击

    http://jingyan.baidu.com/article/0eb457e5045bd703f1a9051d.html yersinia -G

  6. Perf -- Linux下的系统性能调优工具,第 1 部分

    Perf 简介 Perf 是用来进行软件性能分析的工具. 通过它,应用程序可以利用 PMU,tracepoint 和内核中的特殊计数器来进行性能统计.它不但可以分析指定应用程序的性能问题 (per t ...

  7. C++ 中数组做参数的分析

    C++ 中数组做参数的分析 1.数组降价问题? "数组引用"以避免"数组降阶",数组降阶是个讨厌的事,这在C语言中是个无法解决的问题,先看一段代码,了解什么是& ...

  8. MSVC vs. MinGW 之dll玩转攻略手记【转

    一份粗糙的研究记录,有待补完和整理. MinGW:c -> o           gcc -c a.cc -> exe         gcc a.c libs.o -o a.exe ( ...

  9. hdu 5001 从任意点出发任意走d步不经过某点概率

    http://acm.hdu.edu.cn/showproblem.php?pid=5001 给定n个点m条边的无向图问从任意点出发任意走d步,从不经过某个点的概率 本想先算路过每个点的概率然后用1减 ...

  10. Ansible配置文件

    官方配置文件文档 Ansible安装完成之后默认配置文件为:/etc/asnible/ansible.cfg Ansible配置文件内容: cat ansible.cfg # config file ...