D - Problem D. Nothing is Impossible HDU - 6335
https://vjudge.net/contest/313233#problem/D
Input
The first line of the input contains an integer TT (1≤T≤100)(1≤T≤100) denoting the number of test cases.
Each test case starts with two integers n,m (1≤n≤100,1≤m≤109)(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 ( 1≤bi≤100,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 }