CodeForces 441 A. Valera and Antique Items
2015-08-19 16:22
337 查看
纯粹练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
output
input
output
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.
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自动机+DP 改变字符串中的‘?’使得在字典中匹配到的次数最多 codechef Lucy and Question Marks
- IOS第11天(3:UIPickerView省市联动)
- Longest Ordered Subsequence(POJ--2533
- iOS基础-UIKit框架-多控制器管理-Modal
- UE4 Post Process Effects on Mobile Platforms
- Test Design Techniques - STATE BASED TESTING
- 安卓UI布局常见警告
- UUID的组成
- iOS开发学习之UIWindow
- UE4 Performance Guidelines for Mobile Devices
- java并发容器(Map、List、BlockingQueue)详解
- poj 1986——Distance Queries
- Web交互设计优化的简易check list
- IOS第11天(2:UIPickerView自定义国旗选择)
- 关于Bean的知识private static final long serialVersionUID = 1L
- hdu 3717 Rescue 二分加队列优化(技巧)
- Android UI学习 - 对话框
- IOS第11天(1:UIPickerView点餐)
- 2015 Multi-University Training Contest 6 hdu 5357 Easy Sequence
- 【POJ 1019】 Number Sequence