Title Link: http://acm.hdu.edu.cn/showproblem.php?pid=1789
1 /*2 Doing Homework again3 The most points of the first arrangement, arranged on the day of the absence of the Mission4 */5#include <iostream>6#include <algorithm>//void Sort (randomit first, Randomit last, Compare comp);7 using namespacestd;8 #defineMax_num 10059 Ten structHomework One { A intDay ; - intscore; - }homework[max_num]; the BOOLcmpstructHomework A,structHomework B) - { - returnA.score > B.score?1:0; - } + intMain () - { + intT; ACIN >>T; at while(t--) - { - intI, visit[max_num] = {0}, Homework_num =0, score =0, Max_score =0; -CIN >>Homework_num; - for(i =0; i < Homework_num; i++) -CIN >>Homework[i].day; in for(i =0; i < Homework_num; i++) - { toCIN >>Homework[i].score; +Max_score + =Homework[i].score; - } theSort (homework, homework +Homework_num, CMP); * for(i =0; i < Homework_num; i++) $ {Panax Notoginseng intD =Homework[i].day; - for(; d >=1; d--) the { + if(Visit[d] = =0) A Break; the } + if(Visit[d] = =0&& d >0)//is it possible to schedule this day - { $VISIT[D] =1; $Score + =Homework[i].score; - } - } thecout << (Max_score-score) << Endl;//minimum number of points to be deducted last - }Wuyi the return 0; -}
Greedy Doing Homework again