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. kbmMWEncodeEscapes 中汉字编码的问题及解决办法

    kbmMWEncodeEscapes 是kbmmw 里面的一个函数,用来对URL 中的汉字进行编码,例如 http://127.0.0.1/getname?name=春节,由于'春节'是汉字,浏览器向 ...

  2. 2018.10.02 NOIP模拟 序列维护(线段树+广义欧拉定理)

    传送门 一道比较好的线段树. 考试时线性筛打错了于是弃疗. 60分暴力中有20分的快速幂乘爆了于是最后40分滚粗. 正解并不难想. 每次区间加打懒标记就行了. 区间查询要用到广义欧拉定理. 我们会发现 ...

  3. python操作数据库-安装

    首先是下载软件: 链接:http://pan.baidu.com/s/1nvp1imX 密码:6i0x 之后就是一系列设置. 安装教程:自行百度就行.需要注意的是设置my.ini时,需要加上这些东西( ...

  4. 获取手机的唯一标示uuid

    NSString *idfv = [[[UIDevice currentDevice] identifierForVendor] UUIDString];

  5. POJ2676 – Sudoku(数独)—DFS

    Sudoku Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 24081   Accepted: 11242   Specia ...

  6. iterm2 学习笔记

    itrem 笔记 选中即复制,有两种方式. 在新Tab中自动使用前一Tab路径,该怎么用? 系统热键:option+space 自动完成:输入打头几个字母,然后输入command+“;” iterm2 ...

  7. JavaSocket简单通信

    以下介绍:简单的socket发送消息,服务的Server 相互 客户端Client,进行简单的传递消息: 服务端代码: package test; import java.io.DataInputSt ...

  8. StructuredStream StateStore机制

    ref: https://jaceklaskowski.gitbooks.io/spark-structured-streaming/ StruncturedStream的statefule实现基于S ...

  9. abp + angular $http + webapi 服务

    什么是angular $http服务 http是angularjs的一个核心服务,用于读取远程服务器的数据,也就是封装了浏览器原生的xhtmlrequest对象,可以直接同外部进行通信. 怎样使用an ...

  10. LinkedBlockingQueue源码解析(2)

    此文已由作者赵计刚授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. 3.3.public void put(E e) throws InterruptedException 原 ...