HDU6666 & HDU6667 2019 Multi-University Training Contest 8

                                      Quailty and CCPC

Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 47    Accepted Submission(s): 20

 

Problem Description

Considering the overall difficulty of other problems, we invite Quailty to propose an easy problem for this contest.

Quailty accidentally won both gold medal and silver medal in 2017 CCPC final. The reason is explained as follows. According to the official rule, the number of gold medals was 10\% of the number of participating teams, rounded to the nearest integer. This is ambiguous when the fractional part of the result is exactly 0.5. There were 115 participating teams, and the rank of Quailty's team was 12. The organizer originally decided to round down the number, so there were only 11 gold medals, and Quailty's team could only win the silver medal. Many people defended him against the organizer, saying that his team deserved a gold medal. Later, the organizer changed to round up the number, and Quailty's team finally won a gold medal.

Now, give you the scoreboard of a contest and the proportion of gold medal teams, could you determine whether there exists a team, such that they would win a gold medal were the number of gold medals rounded up when the fractional part is exactly 0.5, and silver medal if rounded down?

A team ranks before another if they solved more problems or both teams solved an equal number of problems but they had less penalty time.

(Disclaimer: the background is fictitious and the problem is prepared by Nanjing University ICPC Training Team, not Quailty.)

 

Input

The first line of input consists of a single integer T (1≤T≤120), denoting the number of test cases.

Each test case starts with a line of two integers n (1≤n≤105), denoting the number of participating teams, and d (0≤d≤9), denoting that the proportion of gold medal teams is 10d%. For the next n lines, each containing a string s and two integers p,t (0≤p,t≤109), denoting the name of the team, the number of problems solved and the penalty time of the team, respectively. The name of the each team contains at least 1 and at most 10 latin letters. The names are case sensitive. No two teams have the same name. No two teams have the same penalty time. The sum of n over all test cases does not exceed 106.

 

Output

For each test case, print the team name if there exists such team, or print Quailty is very great otherwise. It can be proved that there is at most one such team.

 

Sample Input

2 5 1

Ace 1000 0

Luffy 999 1

Sabo 998 2

Roronoa 997 3

Sanji 996 4

2 3

You 0 0

I 10 1

 

Sample Output

Ace

Quailty is very great

做过最简单的签到题,只需要判断小数后一位是否为5就可以了,这里我对小数后几位的判断是不必要的,因为最多只会产生一位小数。

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 0x3f3f3f3f
const int MAXN = 1e5 + 7;

struct node
{
    char s[20];
    int p, t;
}stu[MAXN];

bool cmp(node a, node b)
{
    if(a.p == b.p)
        return a.t < b.t;
    return a.p > b.p;
}
int main()
{
    ios::sync_with_stdio(0);
    int t, n, d;
    cin>>t;
    while(t--)
    {
        cin>>n>>d;
        for(int i = 0; i < n; i++)
        {
            cin>>stu[i].s>>stu[i].p>>stu[i].t;
        }
        sort(stu, stu+n, cmp);
        double x = n*(0.1*d);
        ll y = x*10;
        y %= 10;
        ll z = x*100000;
        z %= 10000;
        //cout<<x<<' '<<y<<' '<<z<<endl;
        if(y == 5 && z == 0)
        {
            cout<<stu[int(x)].s<<endl;
        }
        else cout<<"Quailty is very great"<<endl;
    }

    return 0;
}

 

                                 Roundgod and Milk Tea

Time Limit: 6000/6000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 89    Accepted Submission(s): 47

 

Problem Description

Roundgod is a famous milk tea lover at Nanjing University second to none. This year, he plans to conduct a milk tea festival. There will be n classes participating in this festival, where the ith class has ai students and will make bi cups of milk tea.

Roundgod wants more students to savor milk tea, so he stipulates that every student can taste at most one cup of milk tea. Moreover, a student can't drink a cup of milk tea made by his class. The problem is, what is the maximum number of students who can drink milk tea?

 

Input

The first line of input consists of a single integer T (1≤T≤25), denoting the number of test cases.

Each test case starts with a line of a single integer n (1≤n≤106), the number of classes. For the next n lines, each containing two integers a,b (0≤a,b≤109), denoting the number of students of the class and the number of cups of milk tea made by this class, respectively.

It is guaranteed that the sum of n over all test cases does not exceed 6×106.

 

Output

For each test case, print the answer as a single integer in one line.

 

Sample Input

1 2

3 4

2 1

 

Sample Output

3

不明真相的一道题。。。

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 0x3f3f3f3f
const int MAXN = 1e6 + 7;

struct node
{
    int x;
    int y;
}stu[MAXN];

int main()
{
    ios::sync_with_stdio(0);
    int t, n;
    ll sum, ans;
    cin>>t;
    while(t--)
    {
        ans = sum = 0;
        cin>>n;
        for(int i = 0; i < n; i++)
        {
            cin>>stu[i].x>>stu[i].y;
            sum += stu[i].y;
        }
        for(int i = 0; i < n; i++)
        {
            ans += min((ll)stu[i].x,sum - stu[i].y);
        }
        cout<<min(sum, ans)<<endl;
    }


	return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值