Doing Homework again 杭电 1789
2015-10-14 15:27
363 查看
#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; } } } }
相关文章推荐
- Why should we copy blocks rather than retain?
- HAIP
- sleep waitFor区别
- 2014taichuan D题
- iredmail下安装脚本分析(一)---get_all.sh 文件所在目录为PKGS
- OCIServerAttach failed ORA-12154: TNS:could not resolve the connect identifier specified
- cannot set user id: Resource temporarily unavailable
- LR Error: Failed to deliver a p2p message from son to parent process, reason - communication error.
- LR errorFunction two_way_comm_post_message / two_way_comm_post_message_ex failed.错误
- String painter(DP综合题:区间DP(两次DP))
- http://blog.csdn.net/defonds/article/details/46042809
- Saiku3.6构建过程
- POJ 1273 Drainage Ditches 最大流
- 2015/10/14 10:02:08 play.main(:570) ERROR Cannot connected to the database : Communications link fa
- http://blog.csdn.net/liuhongwei123888/article/details/6549825
- child process failed, exited with error number 100
- NSString和block的属性时copy,而不用retain 而容器类使用retain
- 今天在我导入一些安卓项目的源码的时候会出现style.xml 和MAIN.xml 等错误, 网上的方法试了各种clean各种fix等方法都是不能解决。最后去国外论坛得到解决
- Kafka错误3_kafka中 FailedToSendMessageException解决_集群启动问题
- Monitor vs WaitHandle