#include<stdio.h>
void bubble_sort(int score[],int number);
int expiry_day[1100];
int reduced_score[1100];
int can_got_score[1100];
int main()
{
int number_of_test_cases;
int number_of_subject;
while( scanf("%d",&number_of_test_cases)!=EOF )
{
while(number_of_test_cases--)
{
for(int index=0; index<1010; index++)
{
can_got_score[index]=0;
}
int max_expriy_day=0;
scanf("%d",&number_of_subject);
for(int index=0; index<number_of_subject; index++)
{
scanf("%d",&expiry_day[index]);
if(expiry_day[index]>max_expriy_day)
{
max_expriy_day=expiry_day[index];
}
}
int sum_subject_score=0;
for(int index=0; index<number_of_subject; index++)
{
scanf("%d",&reduced_score[index]);
sum_subject_score+=reduced_score[index];
}
bubble_sort(reduced_score,number_of_subject);
for(int now, index=0; index<number_of_subject; index++)
{
now=expiry_day[index];
for(; now>=0; now--)
{
if(can_got_score[ now ]==0)
{
can_got_score[ now ]=reduced_score[index];
break;
}
}
}
int sum_can_got_score=0;
for(int index=1; index<=max_expriy_day; index++)
{
sum_can_got_score+=can_got_score[index];
}
printf("%d\n",sum_subject_score-sum_can_got_score);
}
}
}
void bubble_sort(int score[],int number)
{
int t;
for(int i=1; i<number; i++)
{
for(int j=number-1; j>=i; j--)
{
if(score[j]>score[j-1])
{
t=reduced_score[j];
reduced_score[j]=reduced_score[j-1];
reduced_score[j-1]=t;
t=expiry_day[j];
expiry_day[j]=expiry_day[j-1];
expiry_day[j-1]=t;
}
}
}
}
Doing Homework again 杭电 1789
最新推荐文章于 2019-02-18 10:54:51 发布