Doing Homework again 杭电 1789

#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;
			}
		}
	}
}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值