BestCoder Round #59 (div.2) HDU 5499 5500 5501

来源:互联网 发布:百分浏览器 知乎 编辑:程序博客网 时间:2024/06/06 08:31
Problem Description
The Annual National Olympic of Information(NOI) will be held.The province of Shandong hold a Select(which we call SDOI for short) to choose some people to go to the NOI.n(n100) people comes to the Select and there is m(m50) people who can go to the NOI.

According to the tradition and regulation.There were two rounds of the SDOI, they are so called "Round 1" and "Round 2", the full marks of each round is300.

All the n people take part in Round1 and Round2, now the original mark of every person is known. The rule of SDOI of ranking gets to the "standard mark". For each round there is a highest original mark,let's assume that isx.(it is promised that not all person in one round is 0,in another way,x>0). So for this round,everyone's final mark equals to his/her original mark(300/x).

After we got everyone's final mark in both round.We calculate the Ultimate mark of everyone as0.3round1s final mark + 0.7round2s final mark.It is so great that there were no two persons who have the same Ultimate mark.

After we got everyone's Ultimate mark.We choose the persons as followed:

To encourage girls to take part in the Olympic of Information.In each province,there has to be a girl in its teams.

1. If there is no girls take part in SDOI,The boys with the rank of first m enter the team.
2. If there is girls, then the girl who had the highest score(compared with other girls) enter the team,and other(boys and other girls) m-1 people with the highest mark enter the team.

Just now all the examination had been finished.Please write a program, according to the input information of every people(Name, Sex ,The original mark of Round1 and Round2),Output the List of who can enter the team with their Ultimate mark decreasing.
 

Input
There is an integer T(T100) in the first line for the number of testcases and followed T testcases.

For each testcase, there are two integers n and m in the first line(nm), standing for the number of people take part in SDOI and the allowance of the team.Followed withn lines,each line is an information of a person. Name(A string with length less than20,only contain numbers and English letters),Sex(male or female),the Original mark of Round1 and Round2 (both equal to or less than300) separated with a space.

 

Output
For each testcase, output "The member list of Shandong team is as follows:" without Quotation marks.

Followed m lines,every line is the name of the team with their Ultimate mark decreasing.
 

Sample Input
210 8dxy male 230 225davidwang male 218 235evensgn male 150 175tpkuangmo female 34 21guncuye male 5 15faebdc male 245 250lavender female 220 216qmqmqm male 250 245davidlee male 240 160dxymeizi female 205 1902 1dxy male 300 300dxymeizi female 0 0
 

Sample Output
The member list of Shandong team is as follows:faebdcqmqmqmdavidwangdxylavenderdxymeizidavidleeevensgnThe member list of Shandong team is as follows:dxymeiziHintFor the first testcase: the highest mark of Round1 if 250,so every one's mark times(300/250)=1.2, it's same to Round2.The Final of The Ultimate score is as followedfaebdc 298.20qmqmqm 295.80davidwang 275.88dxy 271.80lavender 260.64dxymeizi 233.40davidlee 220.80evensgn 201.00tpkuangmo 29.88guncuye 14.40For the second testcase,There is a girl and the girl with the highest mark dxymeizi enter the team, dxy who with the highest mark,poorly,can not enter the team.
 

Source
BestCoder Round #59 (div.2)

大体就是排序一下两种情况讨论。
#include <cstdio>using namespace std;#include <cstring>#include <algorithm>#include <iostream>typedef long long ll;struct node{    char name[1000];    char xingbie[1000];    double r1,r2;    double  num;} f[1005];bool cmp(node a,node b){    return a.num<b.num;}int main(){    int t;    scanf("%d",&t);    while(t--)    {        int n,m;        int nan=0;        int nv=0;        int i,j,k;        double sum1=-1;        double sum2=-1;        scanf("%d%d",&n,&m);        for(i=0; i<n; i++)        {            scanf("%s%s%lf%lf",f[i].name,f[i].xingbie,&f[i].r1,&f[i].r2);            if(strcmp(f[i].xingbie,"male")==0)                nan++;            else                nv++;            sum1=max(f[i].r1,sum1);            sum2=max(f[i].r2,sum2);        }        for(i=0; i<n; i++)        {            f[i].num=f[i].r1*(300.0/sum1)*0.3+f[i].r2*(300.0/sum2)*0.7;        }        sort(f,f+n,cmp);        int ans=0;        for(i=n-1,j=1; i>=0,j<=m; i--,j++)        {            if(strcmp(f[i].xingbie,"female")==0)            {                ans++;                break;            }        }        if(ans==1||nv==0)        {            printf("The member list of Shandong team is as follows:\n");            for(i=n-1,j=1; j<=m; j++,i--)            {                cout<<f[i].name<<endl;            }            continue;        }        for(i=n-1; i>=0; i--)        {            if(strcmp(f[i].xingbie,"female")==0)            {                k=i;                break;            }        }        printf("The member list of Shandong team is as follows:\n");        for(i=n-1,j=1; i>=0,j<=m-1; i--,j++)            cout<<f[i].name<<endl;        cout<<f[k].name<<endl;    }    return 0;}

 



 

Reorder the Books

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 186    Accepted Submission(s): 129


Problem Description
dxy has a collection of a series of books called "The Stories of SDOI",There aren(n19) books in this series.Every book has a number from 1 to n.

dxy puts these books in a book stack with the order of their numbers increasing from top to bottom. dxy takes great care of these books and no one is allowed to touch them.

One day Evensgn visited dxy's home, because dxy was dating with his girlfriend, dxy let Evensgn stay at home himself. Evensgn was curious about this series of books.So he took a look at them. He found out there was a story about "Little E&Little Q". While losing himself in the story,he disrupted the order of the books.

Knowing that dxy would be back soon,Evensgn needed to get the books ordered again.But because the books were too heavy.The only thing Evensgn could do was to take out a book from the book stack and and put it at the stack top.

Give you the order of the disordered books.Could you calculate the minimum steps Evensgn would use to reorder the books? If you could solve the problem for him,he will give you a signed book "The Stories of SDOI 9: The Story of Little E" as a gift.
 

Input
There are several testcases.

There is an positive integer T(T30) in the first line standing for the number of testcases.

For each testcase, there is an positive integer n in the first line standing for the number of books in this series.

Followed n positive integers separated by space standing for the order of the disordered books,theith integer stands for the ith book's number(from top to bottom).


Hint:
For the first testcase:Moving in the order of book3,book2,book1 ,(4,1,2,3)(3,4,1,2)(2,3,4,1)(1,2,3,4),and this is the best way to reorder the books.
For the second testcase:It's already ordered so there is no operation needed.
 

Output
For each testcase,output one line for an integer standing for the minimum steps Evensgn would use to reorder the books.
 

Sample Input
244 1 2 351 2 3 4 5
 

Sample Output
30
 

一道模拟。
#include <cstdio>using namespace std;#include <cstring>#include <algorithm>#include <iostream>typedef long long ll;int a[232];int main(){    int t;    scanf("%d",&t);    while(t--)    {        int n;        scanf("%d",&n);        int i;        int flag;        for(i=0; i<n; i++)        {            scanf("%d",&a[i]);            if(a[i]==n)                flag=i;        }        int x=n;        int x1=n;        while(flag>=0)        {            while(flag>=0 &&a[flag]!=x1)                flag--;            if(flag>=0 &&a[flag]==x1)            {                x--;                x1--;                flag--;            }        }        printf("%d\n",x);    }    return 0;}





The Highest Mark

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 207    Accepted Submission(s): 83


Problem Description
The SDOI in 2045 is far from what it was been 30 years ago. Each competition has t minutes and n problems.

The ith problem with the original mark of Ai(Ai106),and it decreases Bi by each minute. It is guaranteed that it does not go to minus when the competition ends. For example someone solves theith problem after x minutes of the competition beginning. He/She will get AiBix marks.

If someone solves a problem on x minute. He/She will begin to solve the next problem on x+1 minute.

dxy who attend this competition with excellent strength, can measure the time of solving each problem exactly.He will spendCi(Cit) minutes to solve the ith problem. It is because he is so godlike that he can solve every problem of this competition. But to the limitation of time, it's probable he cannot solve every problem in this competition. He wanted to arrange the order of solving problems to get the highest mark in this competition.
 

Input
There is an positive integer T(T10) in the first line for the number of testcases.(the number of testcases with n>200 is no more than 5)

For each testcase, there are two integers in the first line n(1n1000) and t(1t3000) for the number of problems and the time limitation of this competition.

There are n lines followed and three positive integers each line Ai,Bi,Ci. For the original mark,the mark decreasing per minute and the time dxy of solving this problem will spend.


Hint:
First to solve problem 2 and then solve problem 1 he will get 88 marks. Higher than any other order.
 

Output
For each testcase output a line for an integer, for the highest mark dxy will get in this competition.
 

Sample Input
14 10110 5 930 2 180 4 850 3 2
 

Sample Output
88
 



dp,类似HDU 2670


#include <bits/stdc++.h>using namespace std;typedef long long ll;int dp[3001];struct node{    int A,B,C;};bool cmp(node aaa,node bbb){    return (ll)aaa.C*bbb.B<(ll)bbb.C*aaa.B;}int main(){    int t;    scanf("%d",&t);    while(t--)    {        node f[1005];        memset(dp,0,sizeof(dp));        int n,m;        int i;        scanf("%d%d",&n,&m);        for(i=0; i<n; i++)            scanf("%d%d%d",&f[i].A,&f[i].B,&f[i].C);        sort(f,f+n,cmp);        for(i=0; i<n; i++)            for(int j=m; j>=f[i].C; j--)                dp[j]=max(dp[j],dp[j-f[i].C]+f[i].A-f[i].B*j);        int ans=0;        for(i=0; i<=m; i++)        {            ans=max(dp[i],ans);           // cout<<dp[i]<<endl;        }        printf("%d\n",ans);    }    return 0;}


0 0
原创粉丝点击