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 ...
随机推荐
- ST-LINK JLINK JTAG SWD接线图
- Percona-Tookit工具包之pt-slave-restart
Preface Sometimes,the threads(especially the SQL_Thread) will be terminated by accident.The ...
- 四 Android Capabilities讲解
本文转自:http://www.cnblogs.com/sundalian/p/5629429.html Android Capabilities讲解 1.Capabilities介绍 可以看下之 ...
- JavaWeb项目中使用ajax上传文件
1.jsp $("#cxsc").click(function(){ var bankId = $("#bankId").val(); var formdata ...
- python学习笔记-参数带*
#!/usr/bin/python # -*- coding: utf-8 -*- def powersum (power,*args): #所有多余的参数都会作为一个元组存储在args中 s ...
- Thread 线程池
Thread 线程池: 当使用多个较短存活期的线程有利时,运用线程池技术可以发挥作用.运用这一技术时,不是为每个任务创建一个全新的线程,而可以从线程池中抽出线程,并分配给任务.当线程完成任务后,再把它 ...
- 【python】用python爬取中科院院士简介信息
018/07/09 23:43 项目名称:爬取中科院871个院士的简介信息 1.爬取目的:中科院871个院士的简介信息 2.爬取最终结果: 3.具体代码如下: import re # 不用安装(注意! ...
- 用Margin还是用Padding?
用margin还是用padding这个问题是每个学习CSS进阶时的必经之路. CSS边距属性定义元素周围的空间.通过使用单独的属性,可以对上.右.下.左的外边距进行设置.也可以使用简写的外边距属性同时 ...
- idea中新建的web项目不能新建servlet
============ ======================================================================== 在新建的“ java ”源文 ...
- 洛谷 P3349 [ZJOI2016]小星星 解题报告
P3349 [ZJOI2016]小星星 题目描述 小\(Y\)是一个心灵手巧的女孩子,她喜欢手工制作一些小饰品.她有\(n\)颗小星星,用\(m\)条彩色的细线串了起来,每条细线连着两颗小星星. 有一 ...