无题 stl 二分
来源:互联网 发布:松下plc编程手册 编辑:程序博客网 时间:2024/06/01 09:17
#include <iostream>#include <cstdio>#include <cstring>#include <math.h>#include <algorithm>#include <cstdlib>using namespace std;int A[100005];int main() { int T; scanf("%d",&T); while(T--) { int n,m; scanf("%d%d",&n,&m); for(int i=0; i<n; i++) { scanf("%d",&A[i]); } sort(A,A+n,less<int>() ); int pos1,pos2; pos1=0; int res=0; while(pos1<n) { int data; data=m-A[pos1]; pos2=upper_bound(A,A+n,data)-A; pos2=pos2-1; if(pos2>pos1) { res=res+pos2-pos1; } pos1++; } printf("%d\n",res); }}//就是练练upper_bound 和lower_bound 而已
阅读全文
0 0
- 无题 stl 二分
- HDU2236 无题II 二分匹配+二分枚举
- 【HDU】2236 无题II 二分+二分匹配
- hdu 2236 无题II 二分 + 二分匹配
- hdu 2336 无题II 【二分+二分匹配】
- hdu2236 无题II (二分+最大匹配)
- Hdu 2236 无题II 最大匹配+二分
- HDU 2236 无题II 二分+最大匹配
- #HDU2236#无题II(二分 + 匈牙利匹配)
- 二分法-手写二分-STL二分
- HDU 2236 无题II(二分图匹配+二分)
- stl二分用法
- STL中的二分查找
- STL中的二分查找
- STL之二分查找
- STL 二分查找
- STL-二分检索函数
- STL 中的二分函数
- Junit测试maven+ssm项目的过程及出现的错误总结
- block,inline和inline-block概念和区别
- UVA 11732 链式字典树
- 【JavaScript】alert()confirm() prompt()
- DrawerLayout实现侧拉索引
- 无题 stl 二分
- 剑指offer(2):替换空格
- iOS如何设置按钮左文字右图片
- soj3172Fisherman_01背包装满
- @javax.annotation.Resource的使用以及和@Autowired的区别
- Spring注入中byType和byName的总结
- 通信原理--知识要点
- Android studio 打包混淆报错总结(第一节)
- Selenium2+Python2.0自动化测试【3】 元素定位