HDU6335 多校第四场D题 Nothing is Impossible

【题目原文】
Problem Description

m students, including Kazari, will take an exam tomorrow.
The paper consists of exactly n problems, the i-th problem contains ai correct answers and bi incorrect answers, i.e. the i-th problem contains ai+bi candidates in total.
Each student should choose exactly one candidate as answer for each problem. If the answer to a certain problem is correct, then the student will get one point. The student who gets the most points wins.
Students only know the structure of the paper, but they are able to talk with each other during the exam. They decide to choose a subset S of all n problems, and they will only be able to submit answers on these problems.
They want to know the maximum size of S that the winner among them will solve all the problems in S if they take the optimal strategy.

For sample 1, students can choose S={1},and we need at least 4 students to guarantee the winner solve the only problem.

For sample 2, students can choose S={1,2,3}, and we need at least 24 students to guarantee the winner solve these three problems, but if |S|=4, we need at least 96 students, which is more than 50.

Input

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

Output

For each test case, print an integer denoting the maximum size of S.

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
【解题思路】
题目的大概讲的是 一堆单选题 题目给定选项数 给定学生总数目
让所有人合伙去蒙题 当然都选不一样的答案咯
所以读入选项数 一个sort排序 依次乘好 输出循环次数就好啦
【AC代码】

#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second

using namespace std;

const int N = 2e5 + 7;
const int M = 1e4 + 7;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + 7;
const double eps = 1e-10;
const double PI = acos(-1);

int err[110];

int main()
{
    int T;
    cin>>T;
    while(T--)
    {
        LL num_que,num_stu;
        cin>>num_que>>num_stu;
        for(int i=1;i<=num_que;i++)
        {
            int cc,cc2;
            cin>>cc>>cc2;
            err[i]=cc2+1;
        }
        sort(err+1,err+num_que+1);
        LL ans=1;
        int res;
        bool flo=1;
        for(int i=1;i<=num_que;i++)
        {
            ans*=err[i];
            res=i;
            if(ans>num_stu)
            {
                flo=0;
                break;
            }
        }
        if(!flo)
        cout<<res-1<<endl;
        else cout<<res<<endl;
    }
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章