CodeForces 441 A. Valera and Antique Items

CodeForces 441 A. Valera and Antique Items

大家好,又见面了,我是全栈君,今天给大家准备了Idea注册码。

纯粹练JAVA….

A. Valera and Antique Items
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Valera is a collector. Once he wanted to expand his collection with exactly one antique item.

Valera knows n sellers of antiques, the i-th of them auctioned ki items. Currently the auction price of the j-th object of the i-th seller issij. Valera gets on well with each of the n sellers. He is perfectly sure that if he outbids the current price of one of the items in the auction (in other words, offers the seller the money that is strictly greater than the current price of the item at the auction), the seller of the object will immediately sign a contract with him.

Unfortunately, Valera has only v units of money. Help him to determine which of the n sellers he can make a deal with.

Input

The first line contains two space-separated integers n, v (1 ≤ n ≤ 50; 104 ≤ v ≤ 106) — the number of sellers and the units of money the Valera has.

Then n lines follow. The i-th line first contains integer ki (1 ≤ ki ≤ 50) the number of items of the i-th seller. Then go ki space-separated integers si1, si2, …, siki (104 ≤ sij ≤ 106) — the current prices of the items of the i-th seller.

Output

In the first line, print integer p — the number of sellers with who Valera can make a deal.

In the second line print p space-separated integers q1, q2, …, qp (1 ≤ qi ≤ n) — the numbers of the sellers with who Valera can make a deal. Print the numbers of the sellers in the increasing order.

Sample test(s)
input
3 50000
1 40000
2 20000 60000
3 10000 70000 190000

output
3
1 2 3

input
3 50000
1 50000
3 100000 120000 110000
3 120000 110000 120000

output
0

Note

In the first sample Valera can bargain with each of the sellers. He can outbid the following items: a 40000 item from the first seller, a20000 item from the second seller, and a 10000 item from the third seller.

In the second sample Valera can not make a deal with any of the sellers, as the prices of all items in the auction too big for him.


import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner cin=new Scanner(System.in);
		int n=cin.nextInt(),v=cin.nextInt();
		int count=0; 
		StringBuilder ans= new StringBuilder();
		for(int lll=0;lll<n;lll++)
		{
			int k=cin.nextInt();
			boolean flag=false;
			for(int i=0;i<k;i++)
			{
				int temp=cin.nextInt();
				if(temp<v)
				{
					flag=true;
				}
			}
			if(flag)
			{
				count++;
				ans.append((lll+1)+" ");
			}
		}
		System.out.println(count);
		System.out.println(ans.toString().trim());
	}
}

版权声明:来自: 代码代码猿猿AC路 http://blog.csdn.net/ck_boss

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/117206.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 震惊!2022 年秋招 Java 后端开发岗竟然一片红海!算法岗都不香了吗?

    据说,2022年算法岗遇冷,BAT暑期实习甚至收不到简历,Java反而爆炸。难道,Java的春天(映射Spring全家桶)又要来了吗?作为Java领域的优质创作者(见下图),又可以在CSDN横着走了吗?如何看待2022年秋招Java后端开发岗一片红海?这不仅让我想起脉脉上的一段话——来自某文豪。划重点:有后选后,无后选前无后无前,算法也甜条件允许,无脑后端前途无量,预定高管这里的后,Java后端敢称第二,没人敢称第一。为什么我敢这么肯定呢?从4个方面来说

    2022年4月14日
    108
  • js特殊符号正则表达式_js正则表达式判断特殊字符

    js特殊符号正则表达式_js正则表达式判断特殊字符JavaScript正则表达式功能:搜索、替换、判断JavaScript正则表达式格式:/正则表达式主体/修饰符JavaScript正则表达式的修饰符:i:忽略大小写g:全局匹配m:多行匹配JavaScript中正则表达式应用场景:搜索功能(字符串方法)search()方法参数为字符串或者是正则表达式返回结果为匹配成功的索引值,如果没有,返回-1替换功能(字符串方法)r…

    2022年9月13日
    0
  • matlab interp1 pchip,matlab多项式插值interp1深入研究(1)「建议收藏」

    matlab interp1 pchip,matlab多项式插值interp1深入研究(1)「建议收藏」学习matlab不久,遇到了多项式插值interp1,在网上没有找到研究其插值方法的文章,在此,对其中插值方法做了一些研究,属于matlab范畴之外,但是无聊研究一下总的来说不会有坏处。interp1的具体运用也比较低,个人理解主要属于样本丢失,补充样本用,所以最后还介绍了傅里叶增值法。正文:首先介绍一个多项式插值函数:Y=interp1(x,y,X,’mothod’)本文主要讨论’mothod…

    2022年4月30日
    127
  • Longest Common Prefix_LeetCode

    Longest Common Prefix_LeetCode1.思路:求strs数组的长度,当len==0,len==1分开考虑;i从1-min_len,以strs[0][i]作为对照,一旦出现strs[j][i]!=strs[0][i],结束循环,则输出之前判断好了的字符串。 classSolution:deflongestCommonPrefix(self,strs):""":typestrs…

    2022年5月6日
    42
  • python–xlsx文件的读写[通俗易懂]

    python–xlsx文件的读写[通俗易懂]文章目录xlsx文件的写入新建工作簿和新建工作表为工作表添加内容xlsx文件的读取最近碰到一个问题,需要读取后缀为xlsx的文件,因此在此总结一下python对于xlsx文件的读写。一般如果是后缀xls的话,用xlwt和xlrd进行读写;而后缀是xlsx的话,用openpyxl进行读写。在此主要介绍openpyxl库对xlsx的读写。参考链接:python之openpyxl模块xlsx文…

    2022年5月30日
    71
  • 全面了解 Nginx 到底能做什么

    全面了解 Nginx 到底能做什么

    2021年11月4日
    36

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号