B. New Year and Ascent Sequence

题意:定义上升序列Ascent,在一组序列A中,存在1<i<j<n,使得Ai<Aj。现在给定n个序列,求n个序列两两组合的n^2个组合序列中,有多少个组合是Ascent序列。。

思路: 用两个MAX,MIN数组分别记录下每个序列的最大值和最小值,然后把最大值进行排序。每次做一遍二分,取每个数组中的最小值到所有数组中的最大值中找有多少个数比它大,这样组合的新序列便是满足Ascent性质。如果本身这个序列就已经满足Ascent的性质,那么直接把最大值设置为9999999,最小值设置为-1存进去。

AC代码:

 #include<iostream>
#include<vector>
#include<cstring>
#include<map>
#include<algorithm>
using namespace std;
vector<int> MAX;
vector<int> MIN;
int main(){
int t;
cin>>t;
for(int i = ;i<t;i++){
int Length;
cin>>Length;
long long Min = ;
long long Max = -;
int ok = ;
for(int j = ;j<Length;j++){
long long cur;
cin>>cur;
if(cur> Min && ok == ){
ok = ;
}
Min = min(Min,cur);
Max = max(Max,cur);
}
if(ok == ){
MAX.push_back(Max);
MIN.push_back(Min);
}
else{
MAX.push_back();
MIN.push_back(-);
}
}
sort(MAX.begin() ,MAX.end() );
long long ans = ;
for(int i = ;i<t;i++){
ans+=(MAX.end() -upper_bound(MAX.begin() ,MAX.end() ,MIN[i]));
//cout<<ans<<endl;
}
cout<<ans;
return ;
}

codeforces 1284B. New Year and Ascent Sequence(二分)的更多相关文章

  1. (CodeForces - 5C)Longest Regular Bracket Sequence(dp+栈)(最长连续括号模板)

    (CodeForces - 5C)Longest Regular Bracket Sequence time limit per test:2 seconds memory limit per tes ...

  2. [Codeforces 865C]Gotta Go Fast(期望dp+二分答案)

    [Codeforces 865C]Gotta Go Fast(期望dp+二分答案) 题面 一个游戏一共有n个关卡,对于第i关,用a[i]时间通过的概率为p[i],用b[i]通过的时间为1-p[i],每 ...

  3. Codeforces Round #279 (Div. 2) E. Restoring Increasing Sequence 二分

    E. Restoring Increasing Sequence time limit per test 1 second memory limit per test 256 megabytes in ...

  4. codeforces 622A A. Infinite Sequence (二分)

    A. Infinite Sequence time limit per test 1 second memory limit per test 256 megabytes input standard ...

  5. Codeforces Gym 100500F Problem F. Door Lock 二分

    Problem F. Door LockTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100500/at ...

  6. Codeforces 749D:Leaving Auction(set+二分)

    http://codeforces.com/contest/749/problem/D 题意:有几个人在拍卖场竞价,一共有n次喊价,有q个询问,每一个询问有一个num,接下来num个人从这次拍卖中除去 ...

  7. Educational Codeforces Round 15 C. Cellular Network(二分)

    C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input standard ...

  8. Codeforces Gym 100803G Flipping Parentheses 线段树+二分

    Flipping Parentheses 题目连接: http://codeforces.com/gym/100803/attachments Description A string consist ...

  9. CodeForces 689D Friends and Subsequences (RMQ+二分)

    Friends and Subsequences 题目链接: http://acm.hust.edu.cn/vjudge/contest/121333#problem/H Description Mi ...

随机推荐

  1. 关于所学,及JNI问题

    上周每天学习Java两个小时,随后两个小时里对教材上的例子进行验证,学会了如何使用Javac对文件进行终端编译,输出,但由于所下载的 jdk版本问题出现了JNI问题,正在尝试解决.并学会了如何使用ec ...

  2. 【58】目标检测之YOLO 算法

    YOLO 算法(Putting it together: YOLO algorithm) 你们已经学到对象检测算法的大部分组件了,在这个笔记里,我们会把所有组件组装在一起构成YOLO对象检测算法.   ...

  3. AE神奇插件TypeMonkey—抖音点赞100W+的文字视频特效是如何做出来的?

    现在最火的东西,短视频必须要拥有姓名啦,抖音这些短视频平台风头正盛,我们也常常在上面看到一些文字动画Vlog,看着并不复杂,但是有些却有上百万的点击量,今天介绍的一款神奇插件——TypeMonkey, ...

  4. JAVA输出流与输入流

    输出流 编程入门的第一个程序,输出一串字符串 public class C { public static void main(String[] args) { System.out.println( ...

  5. MySQL 8 服务器插件

    安装插件 内置插件时服务器能够自动识别的,通常在服务器启动时加载内置插件. 在mysql.plugin表中注册的插件,这种插件不同于内置插件(内置插件不需要注册),通常在服务器启动时会加载mysql. ...

  6. Ubuntu中FTP安装配置及基本概念(原创)

    注:本文出自博主 Chloneda:个人博客 | 博客园 | Github | Gitee | 知乎 本文源链接:https://www.cnblogs.com/chloneda/p/ftp-inst ...

  7. JS Radio结合TEXT

    <script> function fun_a(value){ if(value === "on"){ document.getElementById('a').dis ...

  8. PTA 1002 A+B for Polynomials

    问题描述: This time, you are supposed to find A+B where A and B are two polynomials. Input Specification ...

  9. fastadmin中curd生成的表单将数字展示为文字

    1.在require-table.js文件中找到formatter 在status中将下列参数自行替换为你的表达方式 var custom = {2: 'success', 3: 'danger', ...

  10. vjudge 最大公约数GCD 直接求最大共约束和最小公倍数的指令

    原题链接https://vjudge.net/contest/331993#problem/C 输入2个正整数A,B,求A与B的最大公约数. Input2个数A,B,中间用空格隔开.(1<= A ...