1. #include"cstdio"
  2. #include"algorithm"
  3. using namespace std;
  4. const int MAXN=;
  5. int A[MAXN],B[MAXN],C[MAXN],D[MAXN];
  6. int CD[MAXN*MAXN];
  7. int n;
  8. int main()
  9. {
  10. while(scanf("%d",&n)!=EOF)
  11. {
  12. for(int i=;i<n;i++)
  13. scanf("%d %d %d %d",&A[i],&B[i],&C[i],&D[i]);
  14.  
  15. for(int i=;i<n;i++)
  16. for(int j=;j<n;j++) CD[i*n+j]=C[i]+D[j];
  17. sort(CD,CD+n*n);
  18.  
  19. int res=;
  20. for(int i=;i<n;i++)
  21. for(int j=;j<n;j++)
  22. res+=upper_bound(CD,CD+n*n,-(A[i]+B[j]))-lower_bound(CD,CD+n*n,-(A[i]+B[j]));
  23. printf("%d\n",res);
  24.  
  25. }
  26. return ;
  27. }

POJ2785(upper_bound)的更多相关文章

  1. STL源码学习----lower_bound和upper_bound算法

    转自:http://www.cnblogs.com/cobbliu/archive/2012/05/21/2512249.html 先贴一下自己的二分代码: #include <cstdio&g ...

  2. 【刷题记录】 && 【算法杂谈】折半枚举与upper_bound 和 lower_bound

    [什么是upper_bound 和 lower_bound] 简单来说lower_bound就是你给他一个非递减数列[first,last)和x,它给你返回非递减序列[first, last)中的第一 ...

  3. STL_lower_bound&upper_bound用法

    ForwardIter lower_bound(ForwardIter first, ForwardIter last,const _Tp& val)算法返回一个非递减序列[first, la ...

  4. STL之lower_bound和upper_bound

    ForwardIter lower_bound(ForwardIter first, ForwardIter last,const _Tp& val)算法返回一个非递减序列[first, la ...

  5. LeetCode:Search Insert Position,Search for a Range (二分查找,lower_bound,upper_bound)

    Search Insert Position Given a sorted array and a target value, return the index if the target is fo ...

  6. [STL] lower_bound和upper_bound

    STL中的每个算法都非常精妙, ForwardIter lower_bound(ForwardIter first, ForwardIter last,const _Tp& val)算法返回一 ...

  7. STL lower_bound upper_bound binary-search

    STL中的二分查找——lower_bound .upper_bound .binary_search 二分查找很简单,原理就不说了.STL中关于二分查找的函数有三个lower_bound .upper ...

  8. vector的插入、lower_bound、upper_bound、equal_range实例

    对于这几个函数的一些实例以便于理解: #include <cstdlib> #include <cstdio> #include <cstring> #includ ...

  9. STL中的lower_bound和upper_bound的理解

    STL迭代器表述范围的时候,习惯用[a, b),所以lower_bound表示的是第一个不小于给定元素的位置 upper_bound表示的是第一个大于给定元素的位置. 譬如,值val在容器内的时候,从 ...

随机推荐

  1. PhotoKit type类型

    参考链接: https://www.jianshu.com/p/42e5d2f75452/ 1.获取图像类型 enum PHAssetCollectionType : Int { case Album ...

  2. 【Robot Framework】---- Robot Framework简介、特点、RIDE

    Robot Framework简介.特点.RIDE 一.简介.特点. Robot Framework是一款python编写的功能自动化测试框架.具备良好的可扩展性,支持关键字驱动,可以同时测试多种类型 ...

  3. Spring mvc 与 strust

    1. 机制:spring mvc的入口是servlet,而struts2是filter 2. 性能:spring会稍微比struts快.spring mvc是基于方法,单例(servlet也是单例): ...

  4. Django使用富文本编辑器

    1.下载kindeditor 网址:http://kindeditor.net/demo.php2.解压到项目中 地址:\static\js\kindeditor-4.1.103.删除没用的文件 例如 ...

  5. You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

    [root@localhost dreamstart]# composer installLoading composer repositories with package informationI ...

  6. HDU 4824 Disk Schedule

    //

  7. windows下的mysql闪退问题

    早上来启动MySQL发现输入密码就闪退,连续试了好几次,最后到网上查到了解决方案. 与Linux系统下MySQL密码丢失的操作步骤基本一样. 首先要跳过密码启动MySQL服务. 启动服务必须使用全路径 ...

  8. spring 注解事务

    前提:在applicationContext.xml中配置<tx:annotation-driven transaction-manager="transactionManager&q ...

  9. 培训笔记——Linux基本命令

    在介绍命令之前,更重要的要先介绍一下快速输入命令的方法. 如果你能记住一些常用命令,毫无疑问,通过命令的操作方式比通过鼠标的操作方式要快. 但是有一些命令或是命令用到的参数如文件名特别复杂特别长,这时 ...

  10. ARM汇编学习笔记

    ARM  RISC  (Reduced Instruction Set Computers) X86   CISC  (Complex Instruction Set Computers)      ...