hdu 5101(思路题)
Select
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1599 Accepted Submission(s): 443
day, Dudu, the most clever boy, heard of ACM/ICPC, which is a very
interesting game. He wants to take part in the game. But as we all know,
you can't get good result without teammates.
So, he needs to select two classmates as his teammates.
In
this game, the IQ is very important, if you have low IQ you will
WanTuo. Dudu's IQ is a given number k. We use an integer v[i] to
represent the IQ of the ith classmate.
The sum of new two teammates' IQ must more than Dudu's IQ.
For some reason, Dudu don't want the two teammates comes from the same class.
Now, give you the status of classes, can you tell Dudu how many ways there are.
For each test case , the first line contains two integers, n and k, which means the number of class and the IQ of Dudu. n ( 0≤n≤1000 ), k( 0≤k<231 ).
Then,
there are n classes below, for each class, the first line contains an
integer m, which means the number of the classmates in this class, and
for next m lines, each line contains an integer v[i], which means there
is a person whose iq is v[i] in this class. m( 0≤m≤100 ), v[i]( 0≤v[i]<231 )
3 1
1 2
1 2
2 1 1
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
const int N = ;
const int M = ;
int v[M];
int v1[N*M];
int sum[N];
struct Node{
int num;
int v[N];
}node[N];
int main(){
int tcase,n;
int k;
scanf("%d",&tcase);
while(tcase--){
scanf("%d%d",&n,&k);
int cnt = ;
for(int i=;i<=n;i++){
scanf("%d",&node[i].num);
sum[i] = sum[i-]+node[i].num;
for(int j=;j<=node[i].num;j++){
scanf("%d",&v[j]);
v1[cnt++] = v[j];
}
sort(v+,v+node[i].num+);
for(int j=;j<=node[i].num;j++){
node[i].v[j] = v[j];
}
}
sort(v1+,v1+cnt);
long long ans = ;
for(int i=;i<=n;i++){
for(int j=;j<=node[i].num;j++){
int v = node[i].v[j];
int pos1 = node[i].v+node[i].num+ - lower_bound(node[i].v+,node[i].v++node[i].num,k-v+);
int pos2 = v1+cnt - lower_bound(v1+,v1+cnt,k-v+);
ans += pos2-pos1;
}
}
printf("%lld\n",ans/);
}
return ;
}
hdu 5101(思路题)的更多相关文章
- hdu 4908(思路题)
BestCoder Sequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...
- Proud Merchants HDU - 3466 (思路题--有排序的01背包)
Recently, iSea went to an ancient country. For such a long time, it was the most wealthy and powerfu ...
- hdu 5191(思路题)
Building Blocks Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)T ...
- hdu 5063(思路题-反向操作数组)
Operation the Sequence Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 32768/32768 K (Java/O ...
- hdu 4859(思路题)
Goffi and Squary Partition Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Ja ...
- hdu 4956(思路题)
Poor Hanamichi Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)To ...
- hdu 5400(思路题)
Arithmetic Sequence Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Othe ...
- HDU 1173 思路题
题目大意 有n个地点(坐标为实数)需要挖矿,让选择一个地点,使得在这个地方建造基地,到n个地点的距离和最短,输出基地的坐标. 题解+代码: 1 /* 2 把这个二维分开看(即把所有点投影到x轴上,再把 ...
- 51nod P1305 Pairwise Sum and Divide ——思路题
久しぶり! 发现的一道有意思的题,想了半天都没有找到规律,结果竟然是思路题..(在大佬题解的帮助下) 原题戳>>https://www.51nod.com/onlineJudge/ques ...
随机推荐
- Hibernate---实体类注释简介
1.类级别注解 @Entity:映射实体类 @Entity(name="tableName") - 必须,注解将一个类声明为一个实体bean. 属性: name - 可选,对应数据 ...
- JsBridge "Uncaught TypeError: Cannot call method 'callHandler' of undefined", source
h5和原生结合开发app越来越流行.其实就是webview 的js调用native的方法.也就是需要搭建一个桥.这样的桥早就有人搭建好了,那就是jsbridge. git地址: https://git ...
- DOM事件里封装方法eventUtil
var eventUtil={ //添加句柄 addHandler:function (element,type,handler) { //element相当于btn2,type此时用的是click类 ...
- URL地址传参中特殊符号的转码和解码
背景: URL传参在web开发中很常见,一般来说这种方式并不推荐,原因就是浏览器多种多样,各家浏览器对URL地址的解析的表现很不一样,特别是当参数有非ASCII字符.英文字母.阿拉伯数字时. 在CRM ...
- js模板引擎之 Handlebars 基本用法
模板引擎比较久远的一个技术,常见的模板引擎有 baiduTemplate(百度)\artTemplate(腾讯)\juicer(淘宝)\doT\ tmpl\ handlebars\ easyTempl ...
- python 学习分享-rabbitmq
一.RabbitMQ 消息队列介绍 RabbitMQ也是消息队列,那RabbitMQ和之前python的Queue有什么区别么? py 消息队列: 线程 queue(同一进程下线程之间进行交互) 进程 ...
- 孤荷凌寒自学python第五十六天通过compass客户端和mongodb shell 命令来连接远端MongoDb数据库
孤荷凌寒自学python第五十六天通过compass客户端和mongodb shell 命令来连接远端MongoDb数据库 (完整学习过程屏幕记录视频地址在文末) 今天是学习mongoDB数据库的第二 ...
- hnust 分蛋糕
问题 B: 分蛋糕 时间限制: 1 Sec 内存限制: 128 MB提交: 2430 解决: 966[提交][状态][讨论版] 题目描述 今天是DK生日,由于DK的朋友很多,所以DK在蛋糕店定制了 ...
- Windows 下开发.NET Core应用
一.使用Visual Studio 2015开发1.1 依次安装Visual Studio 2015 Update 3.NET Core 1.0.0 - VS 2015 Tooling Preview ...
- django orm 之makemigrations和migrate命令
makemigrations:将模型的更改生成迁移脚本文件.模型所在的app,必须放在settings.py中的INSTALLED_APPS列表中.这个命令有以下几个常用选项: 1.app_label ...