您的位置:首页 > 其它

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

2015-10-11 09:54 701 查看
[align=left]Problem Description[/align]
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(n≤100)
people comes to the Select and there is m(m≤50)
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 is
300.

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 is
x.(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 as
0.3∗round1′s
final mark + 0.7∗round2′s
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.

 

[align=left]Input[/align]
There is an integer T(T≤100)
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(n≥m),
standing for the number of people take part in SDOI and the allowance of the team.Followed with
n
lines,each line is an information of a person. Name(A string with length less than
20,only
contain numbers and English letters),Sex(male or female),the Original mark of Round1 and Round2 (both equal to or less than
300)
separated with a space.

 

[align=left]Output[/align]
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.
 

[align=left]Sample Input[/align]

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

 

[align=left]Sample Output[/align]

The member list of Shandong team is as follows:
faebdc
qmqmqm
davidwang
dxy
lavender
dxymeizi
davidlee
evensgn
The member list of Shandong team is as follows:
dxymeizi

Hint
For 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 followed
faebdc 298.20
qmqmqm 295.80
davidwang 275.88
dxy 271.80
lavender 260.64
dxymeizi 233.40
davidlee 220.80
evensgn 201.00
tpkuangmo 29.88
guncuye 14.40

For 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.

 

[align=left]Source[/align]
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

[b]Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)

Total Submission(s): 186    Accepted Submission(s): 129
[/b]

[align=left]Problem Description[/align]
dxy has a collection of a series of books called "The Stories of SDOI",There are
n(n≤19)
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.

 

[align=left]Input[/align]
There are several testcases.

There is an positive integer T(T≤30)
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,the
ith
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.
 

[align=left]Output[/align]
For each testcase,output one line for an integer standing for the minimum steps Evensgn would use to reorder the books.
 

[align=left]Sample Input[/align]

2
4
4 1 2 3
5
1 2 3 4 5

 

[align=left]Sample Output[/align]

3
0

 

一道模拟。
#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

[b]Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)

Total Submission(s): 207    Accepted Submission(s): 83
[/b]

[align=left]Problem Description[/align]
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(Ai≤106),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 the
ith
problem after x
minutes of the competition beginning. He/She will get
Ai−Bi∗x
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 spend
Ci(Ci≤t)
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.

 

[align=left]Input[/align]
There is an positive integer
T(T≤10)
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(1≤n≤1000)
and t(1≤t≤3000)
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.
 

[align=left]Output[/align]
For each testcase output a line for an integer, for the highest mark dxy will get in this competition.
 

[align=left]Sample Input[/align]

1
4 10
110 5 9
30 2 1
80 4 8
50 3 2

 

[align=left]Sample Output[/align]

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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ACM算法