D

https://vjudge.net/contest/313233#problem/D

Input

The first line of the input contains an integer T(1T100)(1≤T≤100) denoting the number of test cases. 
Each test case starts with two integers n,m (1n100,1m109)(1≤n≤100,1≤m≤109), denoting the number of problems and the number of students. Each of next nn lines contains two integers ai,biai,bi ( 1bi100,ai=11≤bi≤100,ai=1), indicating the number of correct answers and the number of incorrect answers of the ii-th problem.

Output

For each test case, print an integer denoting the maximum size of SS. 
Sample Input

2	
3 5
1 3
1 3
1 3
5 50
1 1
1 3
1 2
1 3
1 5

Sample Output

1
3

题意:
N 个题 M 次作答(依次作答,每题可重复作答)
每个题的正确/错误答案分布在下面 N 行给出
每个题在取过所有的错误答案后才会有一个正确答案。
问最终选中正确答案的个数

要让一道题的所有错误答案都被选中,才能保证至少选对一个正确答案。

code
 1 #include <cstdio>
 2 #include <iostream>
 3 #include <algorithm>
 4 using namespace std;
 5 int main()
 6 {
 7     int t;
 8     int n , m;
 9     cin >> t;
10     while(t--)
11     {
12         cin >> n >> m;
13         int b[110] = {0};
14         for(int i = 0;i<n;i++)
15             scanf("%*d%d" , &b[i]);
16         sort(b , b+n);
17         int sum = 0;
18         for(int i = 0;i<n;i++)
19         {
20             if(m < b[i]+1)
21                 break;
22             m /= b[i]+1;
23             sum++;
24         }
25         cout << sum << endl;
26     }
27     return 0;
28 }
 

作者:YukiRinLL

出处:YukiRinLL的博客--https://www.cnblogs.com/SutsuharaYuki/

您的支持是对博主最大的鼓励,感谢您的认真阅读。

本文版权归作者所有,欢迎转载,但请保留该声明。

原文地址:https://www.cnblogs.com/SutsuharaYuki/p/11301260.html