pku3663 Costume Party
http://poj.org/problem?id=3663
二分查找
#include <stdio.h>
#include <stdlib.h> int a[]; int bs(int l, int r, int v)
{
int m;
while(l < r)
{
m = (l + r) >> ;
if(a[m] < v)
{
l = m + ;
}
else
{
r = m;
}
}
return l;
} int cmp0(const void *a, const void *b)
{
return *(int *)a - *(int *)b;
} int main()
{
int n, s;
int i, count = ;
int temp;
scanf("%d%d", &n, &s);
for(i=; i<=n; i++)
{
scanf("%d", a+i);
}
qsort(a+, n, sizeof(a[]), cmp0);
a[n+] = (<<) - ;
for(i=; i<=n; i++)
{
if(a[i] < s)
{
temp = bs(i+, n+, s-a[i]+);
count += temp-i-;
//printf("%d %d\n", i, temp-i-1);
}
}
printf("%d\n", count);
return ;
}
pku3663 Costume Party的更多相关文章
- POJ 3663:Costume Party
Costume Party Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 12607 Accepted: 4977 De ...
- Lesson 17 Always young
Text My aunt Jennifer is an actress. She must be at least thirty-five years old. In spit of this, sh ...
- C#设计模式之建造者模式
建造者模式可以将部件本身和它们的组装过程分开,关注如何一步步创建一个包含多个组成部分的复杂对象,用户只需要指定复杂对象的类型即可得到该对象,而无须知道其内部的具体构造细节. 建造者模式:将一个复杂对象 ...
- Hollister Outlet Store
(link to hollisterco site), It's a major try. After a photographer's viewpoint, Which roughly splend ...
- Lightoj 题目1422 - Halloween Costumes(区间DP)
1422 - Halloween Costumes PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 ...
- Chinese culture
文房四宝 笔墨纸砚是中国古代文人书房中必备的宝贝,被称为“文房四宝”.用笔墨书写绘画在 中国可追溯到五千年前.秦(前221---前206)时已用不同硬度的毛和竹管制笔:汉代(前206—公元220) ...
- News common vocabulary
英语新闻常用词汇与短语 经济篇 accumulated deficit 累计赤字 active trade balance 贸易顺差 adverse trade balance 贸易逆差 aid 援助 ...
- [zz]The Royal Treatment
http://www.cgw.com/Publications/CGW/2012/Volume-35-Issue-4-June-July-2012/The-Royal-Treatment.aspx T ...
- 【Origin】jquery.barddialog.js
/// <reference path="jquery-2.1.1.min.js" /> /** * @license jquery.bardDialog 1.0.0 ...
随机推荐
- MySQL之Join
参见MySQL(以5.1为例)中官方手册:MySQL官方手册-JOIN 假设有以下几个表 t1 id book 1 java 2 c++ 3 php t2 id author 2 zhang 3 wa ...
- No resource found that matches the given name
XML里面明显已经定义了ID,可是android:layout_toLeftOf="@id/text_seller"报错,说没有定义,原来这玩意要写在相对位置对象声明的下面,是有顺 ...
- HTML中多媒体的应用_Flash/MP3/设置可以活动的文字
一.HTML中多媒体的应用_falsh动画(往网页中插入Flash动画) 1. Flash动画插入第一种方法:使用<embed>...</embed>标记动画会自动缩小 属性: ...
- java读取Properties文件
方法一.通过java.util.Properties读取 Properties p=new Properties(); //p需要InputStream对象进行读取文件,而获取InputStream有 ...
- DOM对象常用对象的方法和属性
HTML文档中的常用节点类型: 接口 nodeType 备注 Element 1 元素节点 Text 3 文本节点 Document 9 Document Comment 8 注释文本 Docum ...
- HDU 2026 首字母变大写
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; int ma ...
- 【英语】Bingo口语笔记(42) - Got系列
- Android 签名详解
Android 签名详解 AndroidOPhoneAnt设计模式Eclipse 在Android 系统中,所有安装 到 系统的应用程序都必有一个数字证书,此数字证书用于标识应用程序的作者和在应用程 ...
- 【转】Core Bluetooth框架之一:Central与Peripheral
原文网址:http://southpeak.github.io/blog/2014/07/29/core-bluetoothkuang-jia-zhi-%5B%3F%5D-:centralyu-per ...
- Android堆栈分析
在开发中,与界面跳转联系比较紧密的概念是Task(任务)和Back Stack(回退栈).activity的启动模式会影响Task和Back Stack的状态, 进而影响用户体验.除了启动模式之外,I ...