POJ2785(upper_bound)
- #include"cstdio"
- #include"algorithm"
- using namespace std;
- const int MAXN=;
- int A[MAXN],B[MAXN],C[MAXN],D[MAXN];
- int CD[MAXN*MAXN];
- int n;
- int main()
- {
- while(scanf("%d",&n)!=EOF)
- {
- for(int i=;i<n;i++)
- scanf("%d %d %d %d",&A[i],&B[i],&C[i],&D[i]);
- for(int i=;i<n;i++)
- for(int j=;j<n;j++) CD[i*n+j]=C[i]+D[j];
- sort(CD,CD+n*n);
- int res=;
- for(int i=;i<n;i++)
- for(int j=;j<n;j++)
- res+=upper_bound(CD,CD+n*n,-(A[i]+B[j]))-lower_bound(CD,CD+n*n,-(A[i]+B[j]));
- printf("%d\n",res);
- }
- return ;
- }
POJ2785(upper_bound)的更多相关文章
- STL源码学习----lower_bound和upper_bound算法
转自:http://www.cnblogs.com/cobbliu/archive/2012/05/21/2512249.html 先贴一下自己的二分代码: #include <cstdio&g ...
- 【刷题记录】 && 【算法杂谈】折半枚举与upper_bound 和 lower_bound
[什么是upper_bound 和 lower_bound] 简单来说lower_bound就是你给他一个非递减数列[first,last)和x,它给你返回非递减序列[first, last)中的第一 ...
- STL_lower_bound&upper_bound用法
ForwardIter lower_bound(ForwardIter first, ForwardIter last,const _Tp& val)算法返回一个非递减序列[first, la ...
- STL之lower_bound和upper_bound
ForwardIter lower_bound(ForwardIter first, ForwardIter last,const _Tp& val)算法返回一个非递减序列[first, la ...
- 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 ...
- [STL] lower_bound和upper_bound
STL中的每个算法都非常精妙, ForwardIter lower_bound(ForwardIter first, ForwardIter last,const _Tp& val)算法返回一 ...
- STL lower_bound upper_bound binary-search
STL中的二分查找——lower_bound .upper_bound .binary_search 二分查找很简单,原理就不说了.STL中关于二分查找的函数有三个lower_bound .upper ...
- vector的插入、lower_bound、upper_bound、equal_range实例
对于这几个函数的一些实例以便于理解: #include <cstdlib> #include <cstdio> #include <cstring> #includ ...
- STL中的lower_bound和upper_bound的理解
STL迭代器表述范围的时候,习惯用[a, b),所以lower_bound表示的是第一个不小于给定元素的位置 upper_bound表示的是第一个大于给定元素的位置. 譬如,值val在容器内的时候,从 ...
随机推荐
- PhotoKit type类型
参考链接: https://www.jianshu.com/p/42e5d2f75452/ 1.获取图像类型 enum PHAssetCollectionType : Int { case Album ...
- 【Robot Framework】---- Robot Framework简介、特点、RIDE
Robot Framework简介.特点.RIDE 一.简介.特点. Robot Framework是一款python编写的功能自动化测试框架.具备良好的可扩展性,支持关键字驱动,可以同时测试多种类型 ...
- Spring mvc 与 strust
1. 机制:spring mvc的入口是servlet,而struts2是filter 2. 性能:spring会稍微比struts快.spring mvc是基于方法,单例(servlet也是单例): ...
- Django使用富文本编辑器
1.下载kindeditor 网址:http://kindeditor.net/demo.php2.解压到项目中 地址:\static\js\kindeditor-4.1.103.删除没用的文件 例如 ...
- 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 ...
- HDU 4824 Disk Schedule
//
- windows下的mysql闪退问题
早上来启动MySQL发现输入密码就闪退,连续试了好几次,最后到网上查到了解决方案. 与Linux系统下MySQL密码丢失的操作步骤基本一样. 首先要跳过密码启动MySQL服务. 启动服务必须使用全路径 ...
- spring 注解事务
前提:在applicationContext.xml中配置<tx:annotation-driven transaction-manager="transactionManager&q ...
- 培训笔记——Linux基本命令
在介绍命令之前,更重要的要先介绍一下快速输入命令的方法. 如果你能记住一些常用命令,毫无疑问,通过命令的操作方式比通过鼠标的操作方式要快. 但是有一些命令或是命令用到的参数如文件名特别复杂特别长,这时 ...
- ARM汇编学习笔记
ARM RISC (Reduced Instruction Set Computers) X86 CISC (Complex Instruction Set Computers) ...